Jenkins Selenium Tutorial

Reading Time

Jenkins Selenium Tutorial for beginners. In this video we will go through setting up a job in Jenkins and we will do this by first writing a simple Selenium JUnit test and then running it via Jenkins.

Jenkins Selenium Tutorial

Let’s begin by writing a simple Selenium JUnit test.

Before writing the script we will need to download the Chrome Driver which can be found at the URL below:

https://sites.google.com/a/chromium.org/chromedriver/downloads

You may also need to import your selenium dependency if your using Maven:

http://docs.seleniumhq.org/download/maven.jsp

Here is a simple code for a quick Selenium JUnit test script:

public class SampleTest {
 
private WebDriver driver;
 
@Before
public void setUp() {
System.setProperty("webdriver.chrome.driver", "chromedriver.exe");
driver = new ChromeDriver();
}
 
@After
public void tearDown() {
driver.quit();
}
 
@Test
public void shouldLoadQAShahinYouTubePage() {
driver.navigate().to("https://www.youtube.com/user/GlassBoxt");
String title = driver.getTitle();
assertTrue(title.contains("QAShahin"));
}
 
}

Once you have the above script let’s make sure that we are able to run it via maven. Lets do this by opening a terminal and typing in ‘mvn test’. Now go to Jenkins and create a simple job as the previous blog and simple pass the ‘test’ maven goal and supply the location to the pom.xml file.

For a more detailed view of this blog you can follow the YouTube video below.

Video Tutorial on YouTube

Jenkins Selenium Tutorial

Direct Video Link

Mo

I am a passionate tester, father, husband and gamer. I love to write blogs about Software Testing and generally contribute back to the Software Testing world.

More Posts - Twitter - Facebook

Published by

Mo

I am a passionate tester, father, husband and gamer. I love to write blogs about Software Testing and generally contribute back to the Software Testing world.