Error in Selenium webDriver Junit Test? - selenium-webdriver

I am getting following error in my script
does that mean i am missing any jar file which i need to include in liabrary or something else.

Looks like you need to include the jmeter library in your project.

Include all jars from the following JMeter folders:
/lib
/lib/ext
into your project classpath as well as Selenium libraries.
By the way, are you aware of existing WebDriver Sampler which integrates JMeter and Selenium so you won't have to recompile your JUnit code in case of any changes on Selenium side of things.

Related

Selenium - WebDriver & Chrome Driver

I have newly setup the selenium in my pc.
I have installed 9.0.4 Java and installed the eclipse oxygen. I have configured the environment variables and downloaded chrome driver is placed in my folders.
I have downloaded the selenium jar files configured those as well.
But, when I type the webdriver in the selenium code, I am getting the error prompt at left side as per the attached snap in this message.
Can some one please look into this and suggest to proceed further ?
Thanks,
Venkat
Have you put your jar file outside the project , if you have done , you have to set Deployment Assembly along with build path. Just right click on project , go to properties and set this.
1)selenium jar is missing in library folder so You can do one thing... Create a folder into your project and and copy selenium jar, and build path the project and select selenium jar, you will get entry into library folder.
2)Refresh the project or restart your eclipse

How to use TestNG in Eclipse

I have successfully installed TestNG in eclipse through Help->Install New Softwares but while configuring build path, it is not visible in Add Libraries.
The TestNG option is not even visible to create TestNG class.
I think you are confusing two different things. The TestNG that you can install from Eclipse the way you described is installing the TestNG plugin for eclipse. If you want to actually use TestNG to run your tests, you need the TestNG library.
You can download it and manually add to your classpath or, if you are using Maven, add it as a dependency to your pom file.

Importing Selenium files to Jmeter

In Ubuntu OS, using Eclipse I have written Selenium - Junit code and I have exported the files from Eclipse (jar files) and pasted it to lib > junit folder of Jmeter
But Jmeter is not identifying the jar files in junit sampler. Request you to suggest best methods if any I can use
Thank you
I got the solution, hope it will be helpful to other:
Lib Files of Selenium needs to be placed / replaced in the Lib folder of Apache jemter

TestNG Executable JAR files

Is the TestNG Executable JAR files alone is enough to work with TestNG framework or the TestNG plugin is essential? I have the JAR files, can i add to my library and work with TestNG?
Plugin just simplifies running things. You do not need it so to say. But, if you say want to run a single test or a suite file - a plugin would give you a simple way to right click and trigger it off. But with no plugin you will have to run with the java run command or through maven command if that's what you are running.
So the answer is yes - you can run but the plugin will always help while you are developing your tests.

How can one import the whole webDriver project in an executable form so that anybody else can run the suite by just a click.?

I am relatively new to Selenium WebDriver and a self learner. I have created a webDriver project which consists of different packages and have made use of Page Factory concepts extensively. I use TestNg framework to run the suite to generate my report. So my test cases are also following the TestNG framework concepts.
Now my team wants to use my script to be run at every build to test the sanity. The build team just wants to run my whole script by just a click. It can be shell script command or .exe or jar. Build team uses linux m/c and they dont have Ecplise , TestNg installed in their machine. Their intention is whenever build is given they want to run my script by just a click or a command in Command Prompt.( it has to be that simple for them) and a report should be generated in some location in hdfs
My script runs on FF version 32 and Selenium webDriver 2.44.0
Would really appreciate if someone could give me a solution that actually works for my requirement.
I found a similar query from someone but i am not sure if the answer still suits.
How to make Java executable Jar file of WebDriver project
Could somebody please give me a solution. Or the solution mentioned in the above link stil is the best?
Regards
There are few ways to do it:
Use CI tool (Jenkins): You can set up your project in Jenkins and it will allow you to run the project in single click. Jenkins also provides you an option to run the tests periodically so you can configure it in such a way that it will always get executed after certain time period.Jenkins is also capable to trigger the execution if there is any changes in source code of tests. I'd suggest to use this tool. https://jenkins-ci.org/
Use .bat or .sh file: I am not sure if you are using any build tool like ANT or Maven, if you are using any one of them then you can write a .bat or .sh file to run the tests. ANT
If you are not using any build tool then start using, it will help to run the tests in simplest way.For me to run entire suite, I just type below command in terminal from root directory of project
ant run -Dsuite=all
If you are more concerned about system configuration for e.g. the system which will be used by build team does not have a specific version of browser or specific required library. Then I'd suggest to keep all essentials like browser installation files, libraries in your project directory. This is not a good practice but yes it will help others to run the tests smoothly.
I would suggest just exporting a jar file for your project. All the libraries will be packaged together in the jar files(including TestNG) and you can simply double click on the jar file to start your tests.
External resources (if any), will have to be available for the jar file though. So, you can provide the jar file and the external resources together. The external resources might include your test data (if any) or Portable Firefox(if you are using the portable version).
Steps:
Right click on Project -> Export -> Runnable jar file
Give a name and file path for the jar file
Select option - Extract required libraries into generated JAR
And Finish
Troubleshooting:
Check the java version for the machines that you will be running your jar file on. Programs compiled with java 7 will mostly not run if the machine has java 6. Either compile with java 6 or update the jre on the target machines.
If the jar file does not launch, try using Jarfix.

Resources