Selenium-IDE href value without clicking - selenium

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.

Related

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 not reading javascript alert in c#

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.

Can I tell Selenium to record in DOM mode instead of element ID mode?

I have been using Selenium in my DEV environment. When I go to try some of my recorded tests on my Test environment, I find that the elements have different IDs (they are generated by the web framework). I can change the test manually to use
document.forms[2].elements[3]
instead of by id, which looks like this:
ellaMform:j_id77
I'm looking for a way to tell selenium to record the dom:index value for the controls so that tests will be the same between DEV and TEST.
Similar question on SO points to a plugin but is not exactly what I need:
Make Selenium record IDs, not paths
IDE already has locator builders for several DOM styles (e.g., dom:index, which matches your model, or dom:name, which is less position-oriented). By default, they are prioritized lower than ID locators, but you can choose which locator you want to use when you record the test.

Automated way of converting Selenium HTML tests to JUnit?

I'm using Selenium IDE 1.0.10 for Firefox on Mac 10.6.6. Our QA department has created some HTML tests for Selenium that I need to convert to Junit. In the IDE, I can do that by going to the File menu and choosing export. What is an automated/scriptable way to do this same task?
Thanks, - Dave
Try this add in. I have not used it, but it is described just as you need it. Addin
Try this addon which converts Selenium HTML scripts to Java .
Selenium4J
Look at the selenese4J-maven-plugin. Similar to selenium4j (https://github.com/RaphC/selenese4j-maven-plugin).
Provides many features :
Selenium 1/2 (WebDriver) conversion
Test Suite generation
Internationalisation of your html file
Possibility to use snippet into your html file for specific test (e.g : computing working day, write custom generation of values, handle dynamic values ...)
Use of tokenized properties
I took the selenium4j project and turned it into a maven plugin for those who want to take the html test cases and automatically have them run with your maven test phase. You can also separate the tests out using a profile override with surefire.
Readme is here: https://github.com/willwarren/selenium-maven-plugin
The short version of the readme:
Converts this folder structure:
./src/test/selenium
|-signin
|-TestLoginGoodPasswordSmoke.html
|-TestLoginBadPasswordSmoke.html
|-selenium4j.properties
Into
./src/test/java
|-signin
|-firefox
|-TestLoginGoodPasswordSmoke.java
|-TestLoginBadPasswordSmoke.java
This is only tested on windows with Firefox and Chrome.
I couldn't get the IE version to pass a test, but I'm new to selenium so hopefully, if you're a selenium guru, you can get past this.

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/.*