Is it possible to programmatically, in java, convert Selenium HTML file to JUnit test source code?
I need my own program which gets only resources of these html files, converts them to java code and automatically runs the JUnit test. Is there any way to do that?
In Selenium IDE, it is possible to export test cases to JUnit, I know that, but I don't want to use IDE, I need to do this programmatically as I said once before.
I believe that someone needed this before and someone can help me...
How about http://code.google.com/p/selenium4j/ ??
How does Selenium4j work?
In short Selenium4j translates the HTML tests to Java JUnti tests.
UPDATE
Maven port of this project available through https://github.com/willwarren/selenium-maven-plugin:
<dependency>
<groupId>com.gbi.maven</groupId>
<artifactId>selenium-maven-plugin</artifactId>
<version>1.0.2</version>
<scope>test</scope>
</dependency>
Also it mirrored at warious MVN repos:
http://mojo.codehaus.org/selenium-maven-plugin/
There exists a Firefox plugin for the Selenium IDE called Test Suite Batch Converter which can convert batches of HTML files to any export format the IDE supports.
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.
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
Related
I used extent report with java selenium for the automation testing but I would like to try allure reporting. Can anyone please explain to me how to setup Allure+ TestNG+ selenium in eclipse for automation?
Does it supports only maven based projects or even for java projects as well we can do it? Thanks
There is no pom.xml file in my current java project ...so this is a doubt if I can implement
It's fairly simple. If you don't have a pom that means you are possibly using ant to build your tests. That's not an issue. What you can do is, download the allure .jar file. Add it to your project and off you go. With allure, there is no setup required. You will, however, need to implement annotations in your classes where you would like allure yo log things.
Here is an example :
Allure will then log your tests and steps as you would suspect natively. If you want screenshots and all the other goodies you would need to implement it. The docs can help with this part.
Here is the link to the jar file for allure - https://jar-download.com/artifact-search/allure-testng
Have a nice day!
If you are not using pom, then based on latest version which is available at the time you need following JAR files to be added in build path of your project in eclipse .
In my example I would be using version 2.9.0
allure-testng-2.9.0.jar
allure-model-2.9.0.jar
allure-java-commons-2.9.0.jar
allure-descriptions-javadoc-2.9.0.jar
sl4j-api-1.x.x.jar
Finally you need allure-commandline-2.9.0.zip .choose same version which you have downloaded above files.
Extract and set the path as described in the link -https://docs.qameta.io/allure/#_manual_installation
Hope It helps! Thanks
I have a Java based web application which have few ReST endpoints exposed. I want to check the code coverage in running VM. Is there any tool or plugin I can use for this purpose?
I tried looking into jacoco but It looks like it provides code coverage only if you have configured unit/integration tests.
Sometimes, it becomes very difficult to write testcases for all possible scenarios. So, is there a way I can get code coverage without test cases?
Thanks a ton in advance. :)
After doing more search on internet, I have found a very good link which fulfill my requirements:
https://automationrhapsody.com/code-coverage-of-manual-or-automated-tests-with-jacoco/
In short, follow below steps to generate code coverage report without testcases:
Install Jacoco Eclipse plugin: EclEmma Java Code Coverage
Download jacocoagent.jar and put it some location on your computer e.g.
C:\JoCoCo\jacocoagent.jar
Run your application with this VM arguments: -
javaagent:C:\JaCoCo\jacocoagent.jar=output=tcpserver
Import coverage reports:File -> Import -> Coverage Session -> select Agent
address radio button but leave defaults -> enter some name and select code
under test.
I have pretty standard Maven multi-modules project (with JUnit, Arquillian and Selenium tests). I have Sonar 6.2 installed on a server. And on my project on Sonar the Code Coverage metric indicates 0.0%. But I know it's wrong as I do have some test coverage.
I found this Generic Test Data documentation page that explains that since 6.2 Sonar is supporting code coverage out of the box and that I have to pass a comma-delimited list of report paths to a parameter sonar.coverageReportPaths (I guess provided either in my pom or in command line).
I'm fine with that. But I cannot find out an example on how to setup this for a pretty classical Java project. What kind of file do I need to give in the list ? The relative paths to each of my Surefire/Failsafe reports ? Do I need to generate Jacoco reports in addition ? Can I give a "generic" path like report.xml if all of my reports have the same name ?
For standard Java project is it probably the easiest to use JaCoCo to generate coverage data and then feed it to SonarJava (SonarQube's plugin to analyze Java code). You can find documentation here
https://docs.sonarqube.org/display/PLUG/Code+Coverage+by+Unit+Tests+for+Java+Project
You might find mentions of separation between unit tests and integration tests, this has been deprecated and now there is only single kind of coverage.
Don't hesitate to reach out to mailing list or ask question if something is not clear, we are in the process of improving this documentation.
I am new to selenium and so i want to seek advice for setting up my framework.
What i want to achieve is i want a test suite setup using selenium webdriver and eclipse in testNG format. I am looking for a test suite that runs through all the test listed in there (I will record and export script to java/test NG format using IDE and tweak as needed). So that on single click i can run through a series of tests for regression testing. And generate a report stating what passed and what failed
Any ideas how to do it or set it up or any small code required to invoke that whole test will be appreciated.
Thanks
The following is a good tutorial on how to set up selenium webdriver and testNG framework.
http://www.toolsqa.com/selenium-webdriver/download-and-install-java/
Hope it helps!
how can I generate the report after executing test cases in the selenium web driver. I am trying Test NG for generating report but I have to write different code to get the report?
If you use Maven with Surefire plugin (which I strongly recommend), report is always located in target/surefire-reports/index.html. If that is not enough for your than you can use ReportNG library which is supposed to have more convenient reports in HTML format.