Automated way of converting Selenium HTML tests to JUnit? - selenium

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.

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

Running multiple testcases (TestNG cases) in a single browser using maven build tool?

I am new to testing and I was given on automating a registration page. I need to validate each field in separate test-case. If I am validating first-name, all other fields need to be of valid values and that goes on for other fields validation. I have nearly 10 test-cases (10 #Test methods) and each test-case is opening in a new browser and it is very odd to show the results as a demo automation. Is there any way so that I can run all the test-cases in a single browser. any examples would be of great help.. Thanks in advance. - Dev
The question is: Where do you open your browser? I assume in #BeforeMethod ? The best solution is to put the setup (selenium ?) into the #BeforeSuite method which can be defined in a base class for all Test classes.

In selenium is it possible to give Common path for all capture screenshots

Hi is it possible to give some common path for the captureEntirePageScreenshot, I am creating a test suit using selenium and phpunit which will execute all the selenium test cases from the particular folder, but if user has given some different path for captureEntirePageScreenshot function in any testcase I wanted to override that path.
Please let me know if anybody has did this before,
Thanks
Finally I had solved this issue,
I have to set this path in drivers.php file of selenium, and it will override users input parameters.

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