selenium not reading javascript alert in c# - selenium

i am using selenium ide for testing my .net website. i am testing login for the website by using selenium. i recorded the steps and as i am testing the code in visual studio the test case is failing. my test case is:
selenium.Open("//login.aspx");
selenium.Type("fldUsername", "abc");
selenium.Type("fldPassword", "abc");
selenium.Click("btnLogin");
bool log1 = selenium.IsPromptPresent();
Assert.IsNull(log1);
selenium.WaitForPageToLoad("80000");
here username and password are incorrect and is giving a alert. but using selenium it is not getting that alert. please someone help me out..

Probably should have been migrated to sqa.stackexchange.com, but, either way.
Is there any reason why you're creating log1. It would be much for efficient to do something like: Assert.isFalse(selenium.IsPromptPresent());
I don't use Selenium 1 much, however, after a quick test, this seems to work.
Assert.IsTrue(Regex.IsMatch(selenium.GetAlert(), "regex to match"));
As for the regex matching, if you're going to make sure that the prompt is there, you might as well make certain that it's the correct prompt.

Related

How can I trigger a click from the console with Cypress?

I'm trying to run commands on cypress from the command line. For instance, selecting an element and clicking on it.
I'm trying to do this to try some tests without having to need to run all the previous steps at this point. I'm not sure if this is possible due to the sequential nature of cypress, but it would be really helpful if there was some way to do it. I assumed something like this would be possible from the developer tools console:
cy.get('[data-test="save button"]').click()
I'm aware this doesn't work, so I tried with now and then and some other weird strategies. Reading the documentation didn't help. At least the part I read. Any details are appreciated.
--- edit ---
The console is on the same chrome instance that contains the selector playground like shown in in the image below.

Using Selenium IDE for a test-case which includes backend call?

I add a new category in the admin panel and want to ensure that the category is available in the dropdown on the user's part of the website. Recorded test in the Selenium IDE works fine. But the thing is, the task that I execute is of course not a pure frontend thing - the category is saved in the database and is loaded from it to show it to the user. So if something goes wrong on the database-side, the test will fail.
My question is: is it bad practice to do such tests that depend on backend-behavior ? Should I go for Selenium Webdriver ?
If you use Selenium Webdriver, your test will not change in a main thing. It still will check database side. Selenium Webdriver is just anouther tool for testing that is more flexible and allows to make more complex test then in Selenium IDE.
I don't think that it is bad practice, because it is just one of the tests that chould be executed to enshure you that this part of your project works correctly. In this case I would check back-end part(get all categories from DB or admin's panel and check that there is no extra or missing ones) and than check user's panel(all categories are the same as set in DB and admin's panel).

Selenium-IDE href value without clicking

I am quite new to the Selenium. I tried to search for similar questions/issues, but did not find.
I need to create Test Case in Selenium IDE. Test case goes to a web page https://demo.centreon.com. It logs nicely in. But then I want the Selenium to check that the Down hosts count is for example 0.
The code when checking the elements is:
How should I configure it to Selenium IDE to show me error when the count is something else than 0?
In selenium you're going to want to utilize an assert. For your example it might be best select the URL and to assert the final URL e.g. main.php?p=20202&o=down&search=0 or whatever your case might be. More on that here: http://www.seleniumhq.org/docs/02_selenium_ide.jsp#assertion-or-verification
The downside is that using Selenium IDE can be limiting and eventually you're going to want to use a language binding e.g. python, java, ruby, etc. try using Selenium IDE to export the test in a language and experiment.

Automating registration flow using Selenium Web driver

I am new to web driver. I am supposed to test a registration form using selenium2. I am being told to use functional testing to test the form. I have to make tests like(enter username, password, confirm password and click on terms and conditions and only then the create account button gets enabled.I have to enter invalid username, password less than the specified length and for each test I have to assert if the create account button gets enabled.) Checked about functional testing but couldn't get the right information for my issue.
Appreciate help on this
Thanks
Java Beginner.
The fields which are present in the website are called as WebElements.
In Selenium, you can find the element and write string by using the code:
WebElement username = driver.findElement(By.id("your field ID"));
username.sendKeys("your value");
You can do the same thing for the password. Try using dataProvider concept in TestNG to pass different types of values to the same function.
For simple tests try Selenium IDE. Then select "Options -> Clipboard Format -> Java/Junit 4/Webdriver". Copy all the html code and paste in the framework you're using. It will allow you to understand basic workflow and syntax of the application.

Excluding Selenium-server URL in JMeter Proxy Server

I'm currently trying to get JMeter to record the steps my selenium tests so I can perform load testing with the same tests. The steps are recorded fine but my problem is that its also recording the steps performed in the "selenium-server" window (i.e. the extra windows that pop up when selenium runs).
I believe if I add something like *selenium-server* to the "URL Patterns to Exclude" List then it will ignore all these steps but they keep recording for every pattern I've tried.
Can someone please tell me the pattern which will lead to these steps getting ignore?
An example url is: /selenium-server/driver/?retry=true.
Thanks.
Try adding the following to 'URL Patterns to Exclude'
^/selenium-server/.*
If you're trying to use your Selenium tests to generate load, you might also want to look at BrowserMob. It's a company I started that runs actual Selenium browsers en masse in the cloud.
You could try to add the following to 'URL Patterns to Exclude'
.*/selenium-server/.*