TechBeamersTechBeamers
  • Learn ProgrammingLearn Programming
    • Python Programming
      • Python Basic
      • Python OOP
      • Python Pandas
      • Python PIP
      • Python Advanced
      • Python Selenium
    • Python Examples
    • Selenium Tutorials
      • Selenium with Java
      • Selenium with Python
    • Software Testing Tutorials
    • Java Programming
      • Java Basic
      • Java Flow Control
      • Java OOP
    • C Programming
    • Linux Commands
    • MySQL Commands
    • Agile in Software
    • AngularJS Guides
    • Android Tutorials
  • Interview PrepInterview Prep
    • SQL Interview Questions
    • Testing Interview Q&A
    • Python Interview Q&A
    • Selenium Interview Q&A
    • C Sharp Interview Q&A
    • PHP Interview Questions
    • Java Interview Questions
    • Web Development Q&A
  • Self AssessmentSelf Assessment
    • Python Test
    • Java Online Test
    • Selenium Quiz
    • Testing Quiz
    • HTML CSS Quiz
    • Shell Script Test
    • C/C++ Coding Test
Search
  • Python Multiline String
  • Python Multiline Comment
  • Python Iterate String
  • Python Dictionary
  • Python Lists
  • Python List Contains
  • Page Object Model
  • TestNG Annotations
  • Python Function Quiz
  • Python String Quiz
  • Python OOP Test
  • Java Spring Test
  • Java Collection Quiz
  • JavaScript Skill Test
  • Selenium Skill Test
  • Selenium Python Quiz
  • Shell Scripting Test
  • Latest Python Q&A
  • CSharp Coding Q&A
  • SQL Query Question
  • Top Selenium Q&A
  • Top QA Questions
  • Latest Testing Q&A
  • REST API Questions
  • Linux Interview Q&A
  • Shell Script Questions
© 2024 TechBeamers. All Rights Reserved.
Reading: How to Use Chrome for Running Webdriver Test Cases
Font ResizerAa
TechBeamersTechBeamers
Font ResizerAa
  • Python
  • SQL
  • C
  • Java
  • Testing
  • Selenium
  • Agile Concepts Simplified
  • Linux
  • MySQL
  • Python Quizzes
  • Java Quiz
  • Testing Quiz
  • Shell Script Quiz
  • WebDev Interview
  • Python Basic
  • Python Examples
  • Python Advanced
  • Python OOP
  • Python Selenium
  • General Tech
Search
  • Programming Tutorials
    • Python Tutorial
    • Python Examples
    • Java Tutorial
    • C Tutorial
    • MySQL Tutorial
    • Selenium Tutorial
    • Testing Tutorial
  • Top Interview Q&A
    • SQL Interview
    • Web Dev Interview
  • Best Coding Quiz
    • Python Quizzes
    • Java Quiz
    • Testing Quiz
    • ShellScript Quiz
Follow US
© 2024 TechBeamers. All Rights Reserved.
Selenium Tutorial

How to Use Chrome for Running Webdriver Test Cases

Last updated: Nov 05, 2023 6:09 pm
By Meenakshi Agarwal
Share
5 Min Read
How to Use Chrome for Running Webdriver Test Cases
How to Use Chrome for Running Webdriver Test Cases
SHARE

Whether we are working on a Webdriver project or building an online sample for learning, it’s the Firefox browser we mostly use to run the test cases. But it’s also a fact that it fails quite often due to an incompatible version of the Selenium Jar. So the next best alternative is to use Chrome for running Webdriver test cases.

Contents
1- How to set up Chrome driver in Selenium?2- Example: Using Chrome to run Webdriver Tests.2.1- Sample code for Running Webdriver Test Cases.2.2- Execution Summary.

You can use Firefox by merely adding the Selenium Jar, but you would need an additional driver module for Chrome to run test cases. Hence, in this tutorial, we thought to address this issue. So we came up with a practical example for running Webdriver test cases in Chrome.

However, we’d recently done a post on the Selenium TestNG interview questions where we gave tips to solve a similar type of issue. So you might also like to read it to know about these problems and their solution.

Firefox failing to run Webdriver is real. Also, you must believe that it’s not an imaginary issue with Firefox. We’d ourselves faced it with Firefox v47.0.0 and Selenium Jar 2.53.0. You may even check it on the Stackoverflow site where people make queries asking for a solution. Nonetheless, this issue now stands resolved in Firefox v47.0.1 and Selenium Jar 2.53.1. But this incident led us to choose Chrome for running Webdriver test cases.

How to Use Chrome for Running Webdriver Test Cases?

How to Use Chrome for Running Webdriver Test Cases

As we already mentioned above barring Firefox, Selenium requires other browsers to provide their driver modules for supporting Webdriver. These drivers are executable files that work as a server for the respective browser. Let’s now read the follow-up instructions to set up the Chrome driver for running web driver tests.

To run WebDriver in the Chrome browser, we require ChromeDriver which is a separate executable that Selenium WebDriver uses to control Chrome. ChromeDriver gets support from the Chromium team. It’s a standalone server that implements the WebDriver’s wire protocol for Chromium.

1- How to set up Chrome driver in Selenium?

1.1- First of all, download the latest version of the ChromeDriver server. You can download it by clicking the below link.

Download Latest Chrome Driver

1.2- You have to select the Chrome driver based on your working environment. If you are working on Windows, then click on the <Chromedriver_win32.zip>. After that save the downloaded file to your local machine.

1.3- Next, you’ve to set the property for Chrome driver in the WebDriver code. Here, you need to provide the location of the ChromeDriver executable. See the code given below.

System.setProperty("webdriver.chrome.driver", "pathofChromeDriveronlocalsystem\\chromedriver.exe");

Let’s see an example program written in Java. It’ll help you in running Webdriver test cases.

2- Example: Using Chrome to run Webdriver Tests.

In this example, the sample code would do the following.

1- While executing the below code, the Google Home Page will open in Chrome browser.

2- Then, we’ll validate the page title in our example.

2.1- Sample code for Running Webdriver Test Cases.

package com.techbeamers.exercises;

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.testng.Assert;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;

public class RunWebdriverInChrome {

	static String driverPath = "C:\\workspace\\tools\\selenium\\";
	public WebDriver driver;

	@BeforeClass
	public void setUp() {
		System.out.println("*******************");
		System.out.println("launching chrome browser");
		System.setProperty("webdriver.chrome.driver", driverPath + "chromedriver.exe");
		driver = new ChromeDriver();
		driver.manage().window().maximize();
	}

	@Test
	public void testGooglePageTitleInIEBrowser() {
		driver.navigate().to("http://www.google.com");
		String strPageTitle = driver.getTitle();
		System.out.println("Page title: - " + strPageTitle);
		Assert.assertTrue(strPageTitle.equalsIgnoreCase("Google"), "Page title doesn't match");
	}

	@AfterClass
	public void tearDown() {
		if (driver != null) {
			System.out.println("Closing chrome browser");
			driver.quit();
		}
	}
}

2.2- Execution Summary.

After you run the above code, it should give you the following output. Please refer to the below screenshot.

Running Webdriver Test Cases - Execution Report
Running Webdriver Test Cases – Execution Report.

Hopefully, you will also see the same results. If you fall into any runtime issues, then do write us for a solution.

If you want more such posts like this “How to Use Chrome for Running Webdriver Test Cases“, then please visit here more often.

All the Best,

TechBeamers.

You Might Also Like

20 Demo Sites for Automation Testing

Page Object Model (POM) and Page Factory Guide in Selenium Java

Selenium 4 Relative Locators Guide

Selenium Version 4 Features – What’s New?

How to Inspect Element in Safari, Android, and iPhone

TAGGED:Webdriver Exercises
Meenakshi Agarwal Avatar
By Meenakshi Agarwal
Follow:
Hi, I'm Meenakshi Agarwal. I have a Bachelor's degree in Computer Science and a Master's degree in Computer Applications. After spending over a decade in large MNCs, I gained extensive experience in programming, coding, software development, testing, and automation. Now, I share my knowledge through tutorials, quizzes, and interview questions on Python, Java, Selenium, SQL, and C# on my blog, TechBeamers.com.
Previous Article How to Use TestNG Assertions in Selenium How to Use TestNG Assertions to Verify Tests in Selenium
Next Article running webdriver tests using maven Use Maven and Eclipse to Run Webdriver Tests

Popular Tutorials

SQL Interview Questions List
50 SQL Practice Questions for Good Results in Interview
SQL Interview Nov 01, 2016
Demo Websites You Need to Practice Selenium
7 Sites to Practice Selenium for Free in 2024
Selenium Tutorial Feb 08, 2016
SQL Exercises with Sample Table and Demo Data
SQL Exercises – Complex Queries
SQL Interview May 10, 2020
Java Coding Questions for Software Testers
15 Java Coding Questions for Testers
Selenium Tutorial Jun 17, 2016
30 Quick Python Programming Questions On List, Tuple & Dictionary
30 Python Programming Questions On List, Tuple, and Dictionary
Python Basic Python Tutorials Oct 07, 2016
//
Our tutorials are written by real people who’ve put in the time to research and test thoroughly. Whether you’re a beginner or a pro, our tutorials will guide you through everything you need to learn a programming language.

Top Coding Tips

  • PYTHON TIPS
  • PANDAS TIPSNew
  • DATA ANALYSIS TIPS
  • SELENIUM TIPS
  • C CODING TIPS
  • GDB DEBUG TIPS
  • SQL TIPS & TRICKS

Top Tutorials

  • PYTHON TUTORIAL FOR BEGINNERS
  • SELENIUM WEBDRIVER TUTORIAL
  • SELENIUM PYTHON TUTORIAL
  • SELENIUM DEMO WEBSITESHot
  • TESTNG TUTORIALS FOR BEGINNERS
  • PYTHON MULTITHREADING TUTORIAL
  • JAVA MULTITHREADING TUTORIAL

Sign Up for Our Newsletter

Subscribe to our newsletter to get our newest articles instantly!

Loading
TechBeamersTechBeamers
Follow US
© 2024 TechBeamers. All Rights Reserved.
  • About
  • Contact
  • Disclaimer
  • Privacy Policy
  • Terms of Use
TechBeamers Newsletter - Subscribe for Latest Updates
Join Us!

Subscribe to our newsletter and never miss the latest tech tutorials, quizzes, and tips.

Loading
Zero spam, Unsubscribe at any time.
x