- Selenium features
- Selenium XPATH Java
- Selenium take screenshot on failure
- Selenium on Linux server
- How to handle the error popup
- Selenium Grid project
- How to Install TestNG in Eclipse
- Selenium grid hub and node configuration
- Apache poi selenium
Selenium and Jenkins
Selenium features as below
Selenium supports Cross Browser Testing. The Selenium tests can be run on multiple browsers and multiple machines and multiple Operating systems.
Supports several scripting languages like Java, Python, C#, and PHP.
Selenium uses Browser native commands. It locates and actions applied on UI elements,
Reporting are very easy and extensible.
TestNG quick summary:
TestNG’s is Selenium + reporting features. It is easy to generate reports using Listeners and Reporters in TestNG
Features of TestNG includes the following,
1) Annotations – please refer my annotation blog Annotation – TestNG’s test case priority
2) Supports parameterization/ data driven testing
3) Test cases can be grouped and parallel testing is allowed.
Automaton testing using Cucumber – Behavior driven development (BDD)
Application behavior is the main focus on BDD. The requirements are written in English which gives more readability and understandability of the requirement.
So any roles in the company (Tester, developer, end user, and techno functional person) can read it and understand it. Also this will reduce the complication in terms of missing requirement or misrepresenting or misunderstanding requirements between different roles (Developer /tester / end user)
Gherkin is a business readable language – refer below for an example. Below feature file is integrated with Selenium and are having user stories as below.
Please refer below – “feature, Scenario, Given, When, And, Then “are the Keywords below to understand on how to write a feature file.
Selenium jenkins integration steps are as below:
Jenkin related steps:
1) start jenkins by running command in DOS prompt (detailed steps in here )
2) then make sure you are able to access url : localhost:8080
3) then you need to configure jenkins to run the selenium scripts – for that click on “Manage Jenkins”
4) then click on Configure systems
5) Find out the jdk files are installed (usually in C:\ program files … folder path) and copy paste the path in JDK section “JDK Installations” in ” Configure systems” which you are already in.
6) Give JDK name “JAVA_HOME” and provide Java path below in the next field.Selenium related steps:
3) Open eclipse IDE and start new Java project
4) make sure you added selenium jars (Selenium server standalone jar file which you can download add to new project) to support selenium framework for your automation testing.
5) then create a simple selenium script – make sure it is running and completing successfully in Eclipse.
6) Also create a xml file give a name “Xml1.xml” Make sure Run “Xml1.xml” as “TestNG Suite” is working fine in Eclipse. Also notedown the xml file path in selenium project. create a lib folder in that and add all jar files which are required.Commmand prompt:
7) navigate to that project folder in command prompt and set all required classpath like bin and lib etc which are already in xml file folder in selenium project which you got from selenium project in eclipse.
8) then type command “Java org.testng.testNG Xml1.xml” which will display results in command prompt/DOS screen
9) now create a batch file “Batch1.bat” which contains the above command and also a command for compiling as e.g “java -cp bin;lib/* org.testng.testNG Xml1.xml”Jenkins setup to build and run the file:
10) in Jenkins, create a “new item” with selection of “Freestyle project”
11) then select “Advance options” and put the Selenium project home directory path in there.
12) the build trigger section, select Batch file execution option in there, then put the batch file name “Batch1.bat”
13) click and save the new item
14) click on “Build Now” and verify the “Console output”
How to configure Hub & Node machines for selenium parallel test execution
Configuring Hub machine
1) Start the command prompt/DOS prompt
2) Navigate to the folder location where the Selenium server jar file is kept.
3) Type java –jar selenium-server-standalone-[VERSION].jar –role hub
Note: [VERSION] is the one your downloaded version of selenium-server-standalone Jar file.
Your will see the below screen
4) Now type: http://localhost:4444 in browser
Your will see the below screen
5) Now type: http://localhost:4444/console in browser
You will see the below screen
Configuring Node machines
Follow the same steps 1 to 2 in node machines
Then type,
Java –jar selenium-server-standalone-[VERSION].jar –role node –hub http://yourHUBmachineIP:4444/grid/register
What is TestRunner in Cucumber
In order to link Cucumber with Selenium WebDriver, you need to start a Java project in eclipse IDE.
Then, add both Cucumber and Selenium jar files
Write test runner code and execute the same . Please refer BDD testing details on Selenium Cucumber