How schedule Selenium WebDriver script execution - java

Please help me on this. I just want to run my selenium webdriver-Java Script at regular intervals using batch file in windows.

You can do it using jenkins. I feel it's a best way
Setup Jenkins first by refer my below answer in SO:-
How to Run TestNG Tests on Jenkins
Then set the setting of scheduler using jenkins as below:-
How to schedule jobs in Jenkins?
Hope it will help you :)

Related

How do I limit simultaneous Selenium browsers being run by Jenkins?

I have a Jenkins project that runs more than a hundred Cucumber feature files. Each test scenario uses Selenium because I need to test the UI of my website. The problem is that Jenkins tries to run them almost all at once hence I get an explosion of Selenium Google Chrome browsers trying to pop up all at once. This leads to my machine running out of memory and only a few Selenium browsers being responsive.
Is there a way for me to limit the number of Selenium browsers being active at one time? It could be on Jenkins or in Selenium but I'd rather stay away from Selenium Grid.
I've already tried looking into limiting it in Jenkins but it seems like you can only just limit the number of parallel builds. My problem is that I only have one build and it's executing all tests almost all at once.
As for Selenium Grid, the command that is used in the build step of Jenkins explicitly says NOT to use Selenium Grid.
Under Jenkins, for the Execute Windows batch command:
cd folderLocation
mvnw clean verify -Dgui.feature.tags=#test -Dbrowser=chrome -Dforked.jvm.count=3 -Duse.selenium.grid=false
With this command, the test runners are created to specify all scenarios to be run and the location of the results JSON files.
The codebase for Selenium, Java, and Maven are copied from another machine. When you run the Jenkins project manually, they have a limit of active Selenium browsers at a time on that machine. However on the new machine, we re-did the setup of Jenkins and if you run the build, it will try to start all the Selenium browsers all at once and most browsers ended up being unresponsive. After a while, it will end up in an error memory dump.
I repeat, is there a way for me to limit the number of Selenium browsers open?
Two solutions:
There is option "Build Trigger"
Build after other projects are built use this.
Or merge all your UI automation into single job if possible, so that, at the time you can have one build.

Selenium-java,TestNG and jenkins on CentOS

I have recently setup integration of Selenium (Java bindings) with TestNG and Jenkins in a Windows environment, which is running absolutely fine.
I have created a batch file of TestNG and executed it through Jenkins using Windows batch file command. Now the situation is that I have to run these Selenium test cases on a Linux (Centos 7) environment as the Jenkins is setup there.
I am not quite sure how I should approach that. I have gone through some articles, but really could not find anything related to this for Selenium/Java things.
I have already done some initial steps, but I'm stuck after that:
I have setup CentOS 7;
Installed Java on it;
Installed Jenkins on it;
I have also installed xvfb as it would be required for headless execution.
From here I need some guidance in terms of how to proceed further, or put all things together. For example, should I move Selenium/Java project on VM and somehow run the TestNG file through Jenkins? (but not sure how to do that need some steps to follow or are there any more prerequisite to it). Or some other approach which is better.
It would be great if someone can guide me towards any article or can explain here with steps.
Here's what you can try doing to get this working:
You need a version control system(VCS) such as GIT/SVN, wherein you would need to push in your test code. That way, your Jenkins Instance will be able to pull in code from the VCS.
Once you have pushed in your code into the VCS, you can create a build job which would pull code from your VCS, build it using a build tool such as Maven/Gradle/Ant and then execute your tests (again using the build tool)
To learn how to setup your Jenkins instance with Git (One of the popular VCS flavors), please refer to this blog.
To learn how to go about setting up a Continuous Integration system with Selenium, you can also refer to this blog post of mine.

parallel execution in selenium without using testng

Till now I am running multiple scripts in parallel in selenium using testNG framework. Now I have to run these scripts in parallel using only java with out using any framework. Is there any possible way?
Firstly, You have to do is to set Global env. variable "ClassPath", in which you have to mention path of all classes(Selenium Jars and other classes also if used) which is used in Selenium Script.
Then you can run multiple Selenium Scripts from CMD at same time and to make process easy you can also create BAT files. You can also schedule Selenium Script with BAT files.
Hope my answer will help you.
Thank You,
Ed D, India.

How to set up test suite using selenium webdriver eclipse and test NG

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!

Launch selenium webdriver test from terminal in linux

I wrote a simple regression test for a website with a little GUI to launch the test. Works fine in eclipse but for some reason it will stall after pressing the launch button on the GUI when I try to run it from the terminal. The web driver will launch firefox but the page stays blank when its supposed to go to the URL of the site I'm testing. I believe this has to do with error in configuring the classpath, I have the following in a shell script
javac -classpath ":ojdbc6.jar:selenium-server-2.33.0.jar:selenium-server-standalone-2.33.0.jar" Test.java
java -classpath ":ojdbc6.jar:selenium-server-2.33.0.jar:selenium-server-standalone-2.33.0.jar" Test
Why does it stall and how to fix it?
I use the Junit ant task to run my tests. It will run my tests and print a nice looking html report at the other end for clear results.
Use Ant or Maven build tool with Junit or TestNG framework as both framework has capability of running test from terminal and generating nice html formated report. Here is a sample project with ant build script you can get from my github account.

Categories

Resources