TestingDocs.com
Software Testing website
  • JBehave
  • Selenium
  • Testlink
  • Maven
  • Git
  • RAPTOR
  • Questions

Running Selenium Test in Google Chrome Browser

Tweet
Pin it

Document Contents

  • Introduction
  • Program Code
  • Explanation

Introduction

In this article, we will run a sample selenium test in the Google Chrome browser. To run the test in Chrome we need to set the system property to the path of chrome driver as shown below:

Environment: Chrome, Windows 10 OS

Steps to Download  Chrome are listed out here:

(https://www.testingdocs.com/questions/how-to-download-chrome-browser-on-windows/)

System.setProperty(“webdriver.chrome.driver”, “chromedriver.exe”);

Program Code

public class ChromeBrowserExample {
 private WebDriver driver;

@Test
 public void sampleTest() {
 driver.get("https://www.google.com");
 driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
 Assert.assertEquals(driver.getTitle(), "Google", 
"I'm verifying window title here in this test");

}

@BeforeClass
 public void beforeClass() {
 System.setProperty("webdriver.chrome.driver", "chromedriver.exe");
 driver = new ChromeDriver();
 }

@AfterClass
 public void afterClass() {
 if(driver != null)
 {
 driver.quit();
 }
 }

}

 


Explanation

The above sample TestNG test shown, opens the chrome browser with Google search page. It waits for 30 sec implicitly and verifies the title of the window. The before class annotated method initializes the chrome driver

Test annotated method navigates to google search home page. The after class annotated method kills the driver session at the end.

 

Selenium WebDriver Tutorials on this website can be found at:

https://www.testingdocs.com/selenium-webdriver-tutorial

For more details on the Selenium, visit the official website at:

https://www.selenium.dev/

Related Posts

Download Selenium Components

Selenium /

Getting Started with Selenium

Selenium /

Selenium 3.0 and Mozilla GeckoDriver

SauceLabs Website

Selenium /

SauceLabs : Running an Example Sample Test

Create a new Project in Selenium IDE

Selenium /

Create a new Project in Selenium IDE

NodeRegisteredCommandPrompt

Selenium /

Hub and Nodes Configuration

Tag Cloud

Agile Appium Tutorials C++ Eclipse Tutorials Git Tutorials IntelliJ Tutorials Java Java Tutorial JBehave Jenkins Jira Cloud JUnit Tutorial Maven Object-oriented Flowchart Python Tutorials Raptor Flowcharts Selenium IDE TestLink Tutorials

Random Posts

  • TestLink Bitnami Cloud Image
    Overview In this tutorial, we will see the steps

    Read more

  • Code Coverage Tools
    Overview Let’s look at some of the code coverage

    Read more

  • pCloudy Continuous Testing Cloud
    Overview pCloudy is a continuous testing cloud

    Read more

Latest Tweets

Tweets by @TestingDocs

Back to Top

TestingDocs.com

Privacy Policy

Cookie Policy

  • JBehave
  • Selenium
  • Testlink
  • Maven
  • Git
  • RAPTOR
  • Questions
www.TestingDocs.com | All Rights Reserved