• Skip to main content
  • Skip to primary sidebar
  • Skip to footer
  • Home
  • Programming Languages
    • Java Tutorials
    • Python Tutorials
    • JavaScript Tutorials
  • Automation Tools and Different Tools
    • Web Automation
      • Selenium with Java
        • Selenium Basic
        • Selenium Advance
        • Selenium Realtime
        • Framework
        • Selenium Interview
        • Selenium Videos
        • Selenium with Docker
      • Selenium with Python
      • WebdriverIO
        • Selenium Webdriver C# Tutorial
      • Cypress
      • Playwright
    • TestNG
    • Cucumber
    • Mobile Automation
      • Appium
    • API Testing
      • Postman
      • Rest Assured
      • SOAPUI
    • testRigor
    • Katalon
    • TestProject
    • Serenity BDD
    • Gradle- Build Tool
    • RPA-UiPath
    • Protractor
    • Windows Automation
  • Automation For Manual Testers
  • Services
  • Online Training
  • Contact us
  • About me
  • Follow us
    • Linkedin
    • Facebook Group
    • Facebook Page
    • Instagram

Automation

Selenium WebDriver tutorial Step by Step

You are here: Home / Basic Selenium / How to execute Selenium Webdriver in Chrome Browser

How to execute Selenium Webdriver in Chrome Browser

November 20, 2017 by Ritika Gulati 149 Comments

Robot class in Selenium Webdriver

Hello Welcome to Selenium Tutorial, today we will discuss Launch Chrome Browser using Selenium Webdriver.

Selenium Webdriver by default support firefox browser only that is the reason we did not face any issue while working with Firefox.In order to execute your script in the different browser like chrome, IE etc.

If you are working with IE browser then you should know the challenges as well which you will face while working with IE browser. This is one of the most important question in interviews as well.
We have to download separate drivers and we have to specify the path as well with the location of the driver.
Note- Selenium Webdriver supports chrome latest version.

 

 

You can refer complete YouTube video

 

 

Step 1: Download Chrome Drive

Open any browser and open http://www.seleniumhq.org/download/
Here you will get third party driver section and you can get all the external driver for different browsers.
Click on 2.22 link
Note- Latest chrome version is 2.22 so you will get the latest version

Launch Chrome Browser using Selenium Webdriver

 

Here you will get the driver zip file which you can extract, after extraction, you will get chromedrive.exe file

 

Note- Selenium provides only 32 bit but you can use the same for 64-bit machines as well. Practically I tried and it works fine

Launch Chrome Browser using Selenium Webdriver

 

Program for Run Selenium Webdriver in chrome Browser

package demotc;

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.testng.annotations.Test;
public class Openchrome {

@Test
public void test12() throws Exception{

// Initialize browser
WebDriver driver=new ChromeDriver();

// Open Google
driver.get("http://www.google.com");

// Close browser
driver.close();
}

}

 

Output:-

Launch Chrome Browser using Selenium Webdriver
Script in ChromeBrowser

Your test case will fail and you will get IllegalStateException which says we need to specify the chrome driver path where it resides.

If you notice Selenium also gives a very meaningful message that we need to add some chrome variable also while running the script.

Variable name is – webdriver.chrome.driver

In Java to set variable we use setProperty method of System class so let us add the same in our program

Sample Program for Launch Chrome Browser using Selenium Webdriver

import org.openqa.selenium.WebDriver;

import org.openqa.selenium.chrome.ChromeDriver;

public class TestChrome {

public static void main(String[] args) {

System.setProperty("webdriver.chrome.driver", "path of the exe file\\chromedriver.exe");

// Initialize browser
WebDriver driver=new ChromeDriver();

// Open facebook
driver.get("http://www.facebook.com");

// Maximize browser

driver.manage().window().maximize();

}

}

 

Thanks for visiting my blog. Keep reading. Have a nice day 🙂

 

Filed Under: Basic Selenium Tagged With: Chrome browser execution, How to Run Webdriver in chrome browser

Reader Interactions

Comments

  1. pradeep kharade says

    August 26, 2022 at 5:44 PM

    public static void main(String[] args) throws InterruptedException
    {
    System.setProperty(“webdriver.chrome.driver”,”C:\\Users\\Pradeep\\Downloads\\Selenium Driverch\\chromedriver.exe”);
    WebDriver driver=new ChromeDriver();
    driver.get(“https://www.facebook.com/”);
    driver.close();
    }
    }
    But facing same issue
    error occurred during initialization of boot layer
    java.lang.module.FindException: Module format not recognized: C:\Users\Pradeep\Downloads\Selenium Driverch\chromedriver_win32.zip

    Reply
    • Mukesh Otwani says

      August 26, 2022 at 10:14 PM

      Hi Pradeep,

      Please check whether chromedriver being given is correct or not. Enable Show File extensions in Windows explorer settings and reconfirm file path

      Reply
  2. Shaheen says

    January 25, 2021 at 4:11 PM

    Hello Mukesh !

    I am not getting the “import( from openqa…..)” option when I hover the mouse over WebDriver.

    Hope you can help.

    Thanks!

    Reply
    • Mukesh Otwani says

      January 25, 2021 at 5:46 PM

      Hi Shaheen,

      Check whether you are able to see Selenium dependency into the project build path. Also, there shouldn’t any duplication for the same under build path.

      Reply
  3. Priyanka Mohapatra says

    November 19, 2020 at 8:52 PM

    Exception in thread “main” java.lang.IllegalStateException: The driver executable does not exist: C:\Users\sourav\Desktop\chromedriver_win32.exe

    i am getting this; error

    Reply
    • Mukesh Otwani says

      November 19, 2020 at 11:05 PM

      Hi Priyanka,

      Kindly check whether you have given the correct file path and key as “webdriver.chrome.driver” because this is case sensitive

      Reply
  4. Nidhi says

    July 9, 2020 at 3:17 PM

    Hi,
    I am getting below error ;

    Exception in thread “main” java.lang.IllegalStateException: The driver executable is a directory: C:\Users\hp\Downloads\chromedriver_win32 (1)

    Reply
    • Mukesh Otwani says

      July 9, 2020 at 6:30 PM

      Hi Nidhi,

      Path which you have given C:\Users\hp\Downloads\chromedriver_win32 (1) is not driver.exe path. Kindly check it again

      Reply
  5. Ritu says

    April 11, 2020 at 11:21 AM

    Hello Mukesh,

    First of all thanks for the tutorials, your contents are easy to understand.

    I just installed the most recent version of Eclipse and added the Jars.

    I tried launching Chrome and Firefox Browsers and getting following error with both.

    Error: Unable to initialize main class ChromeBrowser.LaunchChrome
    Caused by: java.lang.NoClassDefFoundError: org/openqa/selenium/WebDriver.

    Thanks,
    Ritu

    Reply
    • Mukesh Otwani says

      April 11, 2020 at 12:15 PM

      Hi Ritu,

      Hope you are using Java 8, if not the install it

      Reply
  6. Alejandro says

    January 6, 2020 at 5:31 PM

    Hi, Good day,
    I’ve got the foolowing message:
    Starting ChromeDriver 80.0.3987.16 (320f6526c1632ad4f205ebce69b99a062ed78647-refs/branch-heads/3987@{#185}) on port 3438
    Only local connections are allowed.
    Please protect ports used by ChromeDriver and related test frameworks to prevent access by malicious code.
    Jan 06, 2020 12:47:35 PM org.openqa.selenium.remote.ProtocolHandshake createSession
    INFO: Attempting bi-dialect session, assuming Postel’s Law holds true on the remote end
    Jan 06, 2020 12:47:36 PM org.openqa.selenium.remote.ProtocolHandshake createSession
    INFO: Falling back to original OSS JSON Wire Protocol.
    Jan 06, 2020 12:47:37 PM org.openqa.selenium.remote.ProtocolHandshake createSession
    INFO: Detected dialect: OSS

    I had tried to open Google or other different browsers, it open a blank browser, but then immediately closes.
    I have installed jdk1.8.0_231 and selenium-server-standalone-3.0.1.jar.
    What do you think?

    Reply
    • Mukesh Otwani says

      January 6, 2020 at 8:14 PM

      Hi Alejandro,

      Kindly check whether your chrome browser is also on the same version(i.e. 80.0.3987.16) as mentioned above.
      Moreover, could you please try with Selenium 3.141.59.

      Reply
    • Elias Valderrama says

      February 7, 2020 at 11:27 PM

      Tuve el mismo problema y se debía a que la versión del ChromeDriver (v84) era más actual que la versión de mi navegador Google Chrome (v80).
      Solución: Actualicé el navegador Google Chrome.

      Reply
      • Mukesh Otwani says

        February 8, 2020 at 10:02 AM

        Hi Elias,

        Kindly mention in English so that everybody can understand your thoughts…:)

        Reply
  7. k.lalitesh says

    December 20, 2019 at 3:27 PM

    sir, from past 10 days i tried different websites scripts to launch a browser it did not work finally it worked with your simple srcipt thank u for this

    Reply
    • Mukesh Otwani says

      December 20, 2019 at 6:09 PM

      You’re welcome lalitesh…
      Feel free to drop your doubts in comment section…:)

      Reply
  8. Shalu says

    August 27, 2019 at 2:43 PM

    Hi , What code I have write here when i need to ask user to enter URL manually instead of directly passing in csript

    Reply
    • Mukesh Otwani says

      August 27, 2019 at 3:27 PM

      Hi Shalu,

      There are multiple ways to handle this requirement. As it looks interactive then you user has to pass url in runtime through cmd/terminal.
      If you are using maven project then using surefire plugin, we can pass url value as parameter. Other way is to provide url as parameter from terminal which should be accepted by java main class as arguments later on passed to your actual script.

      Reply
  9. Revathy says

    July 30, 2019 at 12:36 AM

    Hi Mukesh,
    when i executed the above code ,I am getting the below error even though I mentioned the correct path of chrome driver.

    Exception in thread “main” java.lang.IllegalStateException: The driver executable does not exist:

    can you please let me know why I am getting this.

    Thank you.

    Reply
    • Mukesh Otwani says

      July 30, 2019 at 7:33 PM

      Hi Revathy,

      I hope you have mentioned full path of driver executable which includes extension too…

      Reply
      • Revathy says

        July 30, 2019 at 11:43 PM

        After watching your YouTube video I resolved my mistake and it’s working fine.
        Thank you for the response.

        Reply
        • Mukesh Otwani says

          July 31, 2019 at 10:15 AM

          Hi Revathy,

          Great…:)

          Reply
  10. Lakshmi says

    July 25, 2019 at 10:38 AM

    Thanks..Now it’s working.

    Reply
    • Mukesh Otwani says

      July 25, 2019 at 10:14 PM

      Cheers…!!!

      Reply
  11. Lakshmi says

    July 24, 2019 at 11:14 PM

    Thanks Mukesh for your prompt response.
    I’ll check and update you in case of any issues

    Reply
    • Mukesh Otwani says

      July 25, 2019 at 10:34 AM

      Sure…:)

      Reply
  12. Lakshmi says

    July 24, 2019 at 8:45 PM

    Hi Mukesh,

    While executing below code I am getting below mentioned error message
    Error: Unable to initialize main class ChromeBrowser.LaunchApplication
    Caused by: java.lang.NoClassDefFoundError: org/openqa/selenium/WebDriver

    Currently I have installed Java 1.9.0.4 along with “selenium-java-3.141.59” version.
    Kindly suggest if any alternative solution for the same.
    Immediate response would be highly appreciated.

    Reply
    • Mukesh Otwani says

      July 24, 2019 at 9:42 PM

      Hi Lakshmi,

      Better uninstall JDK 9 -> Restart your machine -> Install JDK 8 -> Then run your code

      Reply
  13. jibay says

    July 9, 2019 at 7:45 AM

    Thank you so much Mukesh Otwani.
    It’s working now, don’t get tired of helping us…GOD Bless You 🙂

    Reply
    • Mukesh Otwani says

      July 9, 2019 at 11:11 AM

      Hi Jibay,

      You’re welcome…:)

      Reply
  14. jibay says

    July 4, 2019 at 4:15 PM

    Hi,
    I’m having this error, dunno what to do I’m beginner in Selenium.
    Thank you for the help,

    Chrome Version : Version 75.0.3770.100 (Official Build) (64-bit)
    – this is the drive that i download for my version
    -If you are using Chrome version 75, please download ChromeDriver 75.0.3770.90

    Java Version : jdk-12.0.1_windows-x64_bin
    —–
    Exception in thread “main” java.lang.Error: Unresolved compilation problems:
    WebDriver cannot be resolved to a type
    ChromeDriver cannot be resolved to a type
    By cannot be resolved
    By cannot be resolved

    at co.jibz.selenium.demo/co.jibz.selenium.demo.Demo.main(Demo.java:11)

    Reply
    • Mukesh Otwani says

      July 4, 2019 at 6:02 PM

      Hi Jibay,

      It would be better if you use JDK 8. Steps are below
      1. Uninstall Java 12
      2. Restart your computer(for better safety)
      3. Install JDK 8, latest version
      And run your script

      Reply
  15. PRAKASH says

    June 21, 2019 at 11:25 PM

    Hi,

    I have receiving this error,
    the type org.openqa.selenium.chrome.chromedriver is not accessible
    how do i fix this?

    Reply
    • Mukesh Otwani says

      June 23, 2019 at 9:42 PM

      Hi Prakash,

      Which version of java are you using?

      Reply
  16. venkat says

    June 21, 2019 at 12:22 PM

    Hi sir,
    I’m not able to launch chrome using selenium.
    public class Demo {
    public static void main(String[] args) {
    System.setProperty(“webdriver.chrome.driver”, “C:\\Users\\WIN8\\chromedriver.exe”);
    WebDriver driver = ChromeDriver(); //showing error in this line
    driver.get(“http://google.com”);
    }
    }
    ERROR :
    Exception in thread “main” java.lang.Error: Unresolved compilation problem:
    The method ChromeDriver() is undefined for the type Demo
    at intro.Demo.main(Demo.java:14)

    Reply
    • Mukesh Otwani says

      June 21, 2019 at 2:21 PM

      Hi Venkat,

      You have written wrong way to initialize ChromeDriver object. Write it as WebDriver driver = new ChromeDriver();

      Reply
      • venkat says

        June 21, 2019 at 2:41 PM

        TQ for ur response sir

        Reply
        • Mukesh Otwani says

          June 21, 2019 at 2:44 PM

          You’re welcome…:)

          Reply
  17. swamy says

    June 19, 2019 at 2:47 PM

    Hi

    this is swami My browser opening through the code but in google required URL not opened.
    its showing blank.

    Reply
    • Mukesh Otwani says

      June 19, 2019 at 4:33 PM

      Hi Swamy,

      Assuming that your code is good, are you using compatible version of chromedriver with Chrome browser version. If not, kindly check this link http://chromedriver.chromium.org/downloads

      Reply
  18. priya says

    June 12, 2019 at 3:17 PM

    hi sir i am not able to launch this program Version 75.0.3770.80 (Official Build) (64-bit)

    Reply
    • Mukesh Otwani says

      June 13, 2019 at 3:33 PM

      Hi Priya,

      What exception/erro message are you getting while launching Chrome browser through Selenium? Also mention which Chrome browser and ChromeDriver version you used.

      Reply
  19. milind gaikwad says

    May 31, 2019 at 6:53 PM

    Hi I am not able to launch Chrome using above code and getting below error

    org.openqa.selenium.os.OsProcess checkForError
    SEVERE: org.apache.commons.exec.ExecuteException: Process exited with an error: 1 (Exit value: 1)

    Reply
    • Mukesh Otwani says

      May 31, 2019 at 10:00 PM

      Hi Milind,

      Kindly mention which version of Chrome browser & Chrome Driver are you using ?

      Reply
  20. Rans says

    May 29, 2019 at 2:45 PM

    Hi,
    Thanks for the detailed explanation. I have downloaded chrome exe file in my PC and given the path in program. But it shows the below error, pls correct me:

    “Starting ChromeDriver 74.0.3729.6 (255758eccf3d244491b8a1317aa76e1ce10d57e9-refs/branch-heads/3729@{#29}) on port 32753
    Only local connections are allowed.
    Please protect ports used by ChromeDriver and related test frameworks to prevent access by malicious code.”

    Reply
    • Mukesh Otwani says

      May 29, 2019 at 5:38 PM

      Hi Rans,

      These are not error but chromedriver logs which are usual while launching Chrome browser. Just want to know that whether Chrome launched or not?

      Reply
  21. Girish says

    May 15, 2019 at 1:45 PM

    Hey Mukesh, in my PC there’s an issue in loading Chrome, on single click is there any way to open from Selenium.

    i’ll prefer to use ChromeBrowser.

    Reply
    • Mukesh Otwani says

      May 15, 2019 at 6:18 PM

      Hi Girish,

      If in your machine chrome is not properly installed then kindly reinstall it otherwise it will affect Selenium execution too.

      Reply
  22. Benitto says

    April 30, 2019 at 11:53 PM

    working..

    Reply
    • Mukesh Otwani says

      May 1, 2019 at 12:53 PM

      Cheers Benitto

      Reply
  23. prabhakar says

    April 22, 2019 at 12:03 PM

    hi Mukesh sir
    explain how to write the code in POM multiple check box available in the webpage select one check box.

    Reply
    • Mukesh Otwani says

      April 23, 2019 at 12:35 AM

      Hi Prabhakar, you can write for loop or while loop inside page which will select check box depends on the condition.

      Reply
  24. Raghava says

    April 21, 2019 at 3:57 PM

    Hello Mukesh,

    Please help me…

    I am trying to execute my first selenium script..
    1. I am downloaded JDK 12 Version.
    2. I am using latest chromeversion 73
    3. I am using Selenium- java 3.141.59
    4. I am using Chrome Driver 73.0.3683.68

    When I try to invoke the browser I am getting below error

    Error: Unable to initialize main class practice
    Caused by: java.lang.NoClassDefFoundError: org/openqa/selenium/WebDriver

    Please help me o resolve the issue

    Reply
    • Mukesh Otwani says

      April 23, 2019 at 12:01 AM

      Hi Raghava please use Java 8 for Selenium

      Reply
      • Raghava says

        May 1, 2019 at 12:43 PM

        Yes it is working fine with Java 8…Thank you so much

        Reply
        • Mukesh Otwani says

          May 1, 2019 at 12:54 PM

          Great Raghava

          Reply
  25. Anitha says

    April 19, 2019 at 5:55 PM

    Hi Mukesh, thank you for sharing this information.

    I have doubt on setProperty statement in TestNG framework. Where should I place below line of code in testNG, is it Before or afrer @Test annotation?

    System.setProperty(“webdriver.chrome.driver”, “path of the exe file\\chromedriver.exe”);

    Please help me on this. I am getting error. Below is program.

    package TestNG;
    import org.testng.annotations.Test;
    import org.testng.AssertJUnit;
    import org.testng.Assert;

    import org.openqa.selenium.By;
    import org.openqa.selenium.WebDriver;
    import org.openqa.selenium.WebElement;
    import org.openqa.selenium.chrome.ChromeDriver;

    @Test
    public class NewTestNG2 {

    System.setProperty(“webdriver.chrome.driver”,”D:\\PracticeJava\\chromedriver.exe”); //getting error here
    WebDriver driver = new ChromeDriver();
    String AppUrl= “https://www.facebook.com/”;

    public void f() {

    driver.get(AppUrl);
    driver.manage().window().maximize();
    String ActTile=driver.getTitle();
    System.out.println(ActTile);
    String ExpTitle=”Facebook – log in or sign up”;

    AssertJUnit.assertEquals(ActTile, ExpTitle);

    WebElement username=driver.findElement(By.name(“email”));
    WebElement pwd=driver.findElement(By.name(“pass”));
    username.clear();
    username.sendKeys(gmailID);
    pwd.clear();
    pwd.sendKeys(pwd);

    driver.findElement(By.id(“loginbutton”)).click();

    String FBTile=driver.getTitle();

    driver.close();

    }
    }

    Reply
    • Mukesh Otwani says

      April 23, 2019 at 12:31 AM

      Hi Anita, you can follow my framework code https://www.youtube.com/playlist?list=PL6flErFppaj0WwNOMFeXPVlNCDuJyPYFi

      Reply
  26. Leela says

    April 16, 2019 at 3:59 PM

    Im getting the below error….please help me

    Exception in thread “main” java.lang.Error: Unresolved compilation problems:
    WebDriver cannot be resolved to a type
    ChromeDriver cannot be resolved to a type

    Reply
    • Mukesh Otwani says

      April 16, 2019 at 8:40 PM

      Hi Leela,

      Have you imported WebDriver and ChromeDriver libraries, if not kindly do it.

      Reply
  27. qa says

    April 15, 2019 at 12:13 PM

    Hi Mukesh

    I have a small doubt, i have done an automation for login page when it loads to firefox browser and launches the login page. In URL tab a robot logo is displaying, when i move cursor on it, it is showing message as Browser under remote control.
    So what it means ?
    Whether i’m using Selenium RC or it is just showing message?

    Reply
    • Mukesh Otwani says

      April 15, 2019 at 1:56 PM

      Hi Qa,

      It is informational message and it doesn’t affect your test automation. It is informing that browser is being handled without human intervention…:)

      Reply
  28. Prachi Gupta says

    March 19, 2018 at 11:26 AM

    Hi Mukesh,
    I am currently working on revamping the existing code using Chrome Driver(It was written for firefox earlier).Only recently I have started getting this error while loating elements, it was working fine till now:
    org.openqa.selenium.WebDriverException: unknown error: Element … is not clickable at point (375, 58). Other element would receive the click: …

    Can you please suggest me how to get this resolved? Do I need to use javascript executor for every element identification from now on?

    Reply
    • Mukesh Otwani says

      March 20, 2018 at 12:35 PM

      Hi Prachi,

      Kindly go through this link http://learn-automation.com/how-to-solve-element-is-not-clickable-at-pointxy-in-selenium/

      Reply
  29. Rishma says

    February 20, 2018 at 8:52 PM

    Hello
    I am Getting below exception for this code while running chrometest

    Exception in thread “main” java.lang.IllegalStateException: The driver executable does not exist: F:\Programs\Selenium Programs\Java\‪F:\Softwares Installed\chromedriver_win32\chromedriver.exe
    at com.google.common.base.Preconditions.checkState(Preconditions.java:199)
    at org.openqa.selenium.remote.service.DriverService.checkExecutable(DriverService.java:121)
    at org.openqa.selenium.remote.service.DriverService.findExecutable(DriverService.java:116)

    Reply
    • Mukesh Otwani says

      February 21, 2018 at 7:33 PM

      Hi Rishma,

      Kindly check the path of chromedriver.exe

      Reply
  30. saeed says

    February 19, 2018 at 11:02 AM

    can anyone get me help using selenium with nodjs

    Reply
    • Mukesh Otwani says

      February 23, 2018 at 9:20 AM

      Hi Saeed,

      Please check this link http://webdriver.io/

      Reply
  31. Sebastian says

    February 14, 2018 at 5:58 PM

    Hi mukesh,
    How to capture live http request and response using selenium.

    Reply
    • Mukesh Otwani says

      February 17, 2018 at 11:38 AM

      Hi Sebastian,

      You can try this http://www.seleniumeasy.com/selenium-tutorials/browsermob-proxy-selenium-example

      Reply
  32. Aparajita says

    February 7, 2018 at 7:17 AM

    Hi Mukesh,
    I am getting the following exception.
    org.openqa.selenium.SessionNotCreatedException: session not created exception
    from tab crashed
    (Session info: chrome=62.0.3202.62)
    (Driver info: chromedriver=2.35.528161 (5b82f2d2aae0ca24b877009200ced9065a772e73),platform=Windows NT 6.1.7601 SP1 x86_64) (WARNING: The server did not provide any stacktrace information)
    Command duration or timeout: 2.78 seconds
    Build info: version: ‘2.35.0’, revision: ‘8df0c6bedf70ff9f22c647788f9fe9c8d22210e2’, time: ‘2013-08-17 12:46:41’
    System info: os.name: ‘Windows 7’, os.arch: ‘amd64’, os.version: ‘6.1’, java.version: ‘1.8.0_161’
    Driver info: org.openqa.selenium.chrome.ChromeDriver
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
    at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:191)
    at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:145)
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:554)
    at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:216)
    at org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:111)
    at org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:115)
    at org.openqa.selenium.chrome.ChromeDriver.(ChromeDriver.java:161)
    at org.openqa.selenium.chrome.ChromeDriver.(ChromeDriver.java:107)
    at au.com.westpac.test.servlet.cases.GetJwtTest.main(GetJwtTest.java:16)

    Reply
    • Mukesh Otwani says

      February 7, 2018 at 9:42 AM

      Hi Aparajia,

      Please upgrade your chrome browser and try it once again.

      Reply
  33. Vineet says

    February 2, 2018 at 6:13 PM

    Thank U for such a nice article.

    Reply
    • Mukesh Otwani says

      February 3, 2018 at 1:30 PM

      Hi Vineet,

      Thanks for your overwhelming comment…:)

      Reply
  34. sebastian says

    February 1, 2018 at 6:19 PM

    I execute your given code, open window but not going to the website.occur this error. How to solve this problem. I need the code for open private(incognito) window in chrome

    Starting ChromeDriver (v2.8.241075) on port 2352
    Feb 01, 2018 6:15:33 PM org.openqa.selenium.remote.ProtocolHandshake createSession
    INFO: Detected dialect: OSS
    Exception in thread “main” org.openqa.selenium.WebDriverException: unknown error: Runtime.executionContextCreated has invalid ‘context’: {“auxData”:{“frameId”:”

    Reply
    • Mukesh Otwani says

      February 1, 2018 at 6:42 PM

      Hi Sebastian,

      First of all, chromedriver version which you’ve used is too old. Version 2.35 is latest one. Secondly, if you want to open chrome browser default in incognito mode then kindly use ChromeOptions with argument as –incognito

      Reply
      • Sebastian says

        February 2, 2018 at 10:24 AM

        hi mukesh,
        I will write this code but not open private window.

        import org.openqa.selenium.WebDriver;
        import org.openqa.selenium.chrome.ChromeDriver;
        import org.openqa.selenium.chrome.ChromeOptions;
        import org.openqa.selenium.remote.DesiredCapabilities;
        public class Selenium
        {
        public static void main(String args[])
        {
        System.setProperty(“webdriver.chrome.driver”, “C:\\chrome driver.chromedriver.exe”);
        WebDriver driver=new ChromeDriver();
        DesiredCapabilities capabilities = DesiredCapabilities.chrome();
        ChromeOptions options = new ChromeOptions();
        options.addArguments(“incognito”);
        capabilities.setCapability(ChromeOptions.CAPABILITY, options);
        driver.get(“http://www.javatpoint.com”);
        System.out.println(driver.getTitle());
        }
        }

        Reply
        • Mukesh Otwani says

          February 2, 2018 at 11:31 AM

          Hi Sebastian,

          You have to pass chromeoptions as argument to webdriver.

          Reply
          • Sebastian says

            February 3, 2018 at 1:42 PM

            Hi mukesh,thank you

            I get private window. I will given two url in open two tabs but two urls opened with single tab.how do you get two tabs in chrome .

            driver.get(“http://google.com”);
            System.out.println(driver.getTittle());
            driver.findElement(By.cssSelector(“body”)).sendkeys(keys.CONTROL + “t”);
            driver.get(“http://bing.com”);
            System.out.println(driver.getTittle());
            driver.findElement(By.cssSelector(“body”)).sendkeys(keys.CONTROL + “\t”);
            System.out.println(driver.getTittle());

          • Mukesh Otwani says

            February 3, 2018 at 2:26 PM

            Hi Sebastian,

            Use robot class to open another tab http://learn-automation.com/robot-class-in-selenium-webdriver/ then switch driver control to new tab

  35. Prashant Thyagaraju says

    January 21, 2018 at 8:09 PM

    Hi,
    I tried running selenium with Chrome, however, getting the pop up as Google Chrome has stopped working. How to resolve this issue? Please help

    Reply
    • Mukesh Otwani says

      January 23, 2018 at 3:49 PM

      Hi Prashant,

      Kindly ensure that you are using latest Chrome and Chromedriver version in corresponding machine.

      Reply
  36. suraj says

    January 17, 2018 at 6:08 PM

    Hi mukesh,
    I have one question but its not related to above topic.
    actually i want to check weather my test case is pass or fail using listener in MS-test for selenium C#.

    Reply
    • Mukesh Otwani says

      January 18, 2018 at 11:55 AM

      Hi Suraj

      Apologies, I don’t support C#. But if it comes from Java then obviously TestNG help you.

      Reply
  37. Rakesh K H says

    January 5, 2018 at 1:48 PM

    Hi mukesh,
    I have query on xpath’s
    currently we are writing script with one xpath. if xpath is wrong or something changes in the application my script will fail. so i have scenario like i have to pass two xpaths where if one xpath fails find element method should take second xpath. is there any logic to do like this?
    ??

    Reply
    • Mukesh Otwani says

      January 5, 2018 at 2:24 PM

      Hi Rakesh,

      Use ‘or’ logic in while building xpath. Like //input[@value=’submit’ or @class=’submit_class’ or @title=’Submit’ or @type=’submit_button’]

      Reply
      • Rakesh K H says

        January 5, 2018 at 3:35 PM

        Thanks for reply mukesh, you gave great idea but when we use following-siblings ,indexing or will not work know

        Reply
        • Mukesh Otwani says

          January 5, 2018 at 5:09 PM

          Hi Rakesh,

          You can give a try to text in your application also. You need to confirm with application ui developer that which all properties remain stable in ui. Because automation is carried out for regression testing and ui properties should be stable.

          Reply
  38. Shrikant says

    December 26, 2017 at 10:25 PM

    Hi Mukesh, in your “How to handle Element is no Clickable….” tutorial you haven’t used System.setProperty(); line. How to provide this particular functionality or have you done some pre-execution setting…????

    Reply
    • Mukesh Otwani says

      December 28, 2017 at 10:23 AM

      Hi Shrikant,

      In my blogpost, there are two things which you need to observe, Code snippet and video. I would suggest you to go through video first.

      Reply
  39. Akshay says

    December 25, 2017 at 7:48 PM

    How to automate browser settings using selenium?
    i have scenario like i want automate chrome browser settings->search proxy -> LAN btn-> Automatic Configuration->uncheck 1st checkbox-> select 2nd checkbox -> add address in Text box….? can we do it by using selenium?

    Reply
    • Mukesh Otwani says

      December 28, 2017 at 10:18 AM

      Hi Akshay,

      You can access Settings of chrome browser just like we do any web application.

      Reply
  40. Rajesh says

    December 20, 2017 at 7:44 AM

    Hi Mukesh, ur videos are very understandable and helps a new person to learn.
    I am facing a issue I have recently installed selenium in my system and had run a basic script for which I am getting “Disable developer mode pop up is displayed due to which my case is getting failed.

    Reply
    • Mukesh Otwani says

      December 20, 2017 at 4:50 PM

      Hi Rajesh,

      Please go through this http://learn-automation.com/disable-developer-mode-extension-in-chrome-selenium/

      Reply
  41. satya says

    December 18, 2017 at 11:07 PM

    Hi
    Nice article on Selenium, would like to know, how to handle captcha with selenium, any third party libraries are available for this?

    Reply
    • Mukesh Otwani says

      December 19, 2017 at 11:45 AM

      Hi Satya,

      Captcha is being added so that no automation and bot can get through authentication window/gateway. when you are testing any application, captchas have to be removed.

      Reply
      • rajesh says

        December 21, 2017 at 4:57 PM

        thank you mukesh i am able to solve the issue with the help of ur artical

        Reply
        • Mukesh Otwani says

          December 22, 2017 at 2:23 PM

          Kudos…!!!

          Reply
  42. yasodhta says

    December 11, 2017 at 3:46 PM

    Exception in thread “main” java.lang.IllegalStateException: The path to the driver executable must be set by the webdriver.gecko.driver system property; for more information, see https://github.com/mozilla/geckodriver. The latest version can be downloaded from https://github.com/mozilla/geckodriver/releases

    Reply
    • Mukesh Otwani says

      December 13, 2017 at 2:06 PM

      Hi Yasodhta,

      Please provide gecko driver path. for more info, kindly check this link http://learn-automation.com/use-firefox-selenium-using-geckodriver-selenium-3/

      Reply
  43. Haripriya says

    December 11, 2017 at 2:30 PM

    Hi Mukesh,
    Its very good to see your blog and it is having a good concepts of automation with very clear explanation.
    Please keep on posting new concepts.

    Reply
    • Mukesh Otwani says

      December 13, 2017 at 11:40 AM

      Hi Haripriya,

      Sure…:)

      Reply
  44. sekhar u says

    December 10, 2017 at 7:37 PM

    the way u explained really awesome.thanks mukesh

    Reply
    • Mukesh Otwani says

      December 13, 2017 at 11:37 AM

      Hi Sekhar,

      Thanks for your comments. You are always welcome to my bog…:)

      Reply
  45. Namani Prashanth says

    February 16, 2017 at 4:39 PM

    Which chrome browser version is supported for selenium.

    Reply
    • Mukesh Otwani says

      February 16, 2017 at 7:15 PM

      Hi Namani,

      As such there is no specific details for same. Only thing is, always use latest version of chromedriver.

      Reply
  46. Pavithra says

    February 12, 2017 at 11:21 PM

    Very good information I got from this forum and thank you so much mukesh for all your patience in answering in everyone’s query.

    Reply
    • Mukesh Otwani says

      February 13, 2017 at 9:27 PM

      Hi Pavithra,

      Happy to read from you.

      Reply
  47. Sonu says

    February 8, 2017 at 9:41 PM

    if i run the code in chrome than its showing plz enable the developer mode how to fix this issues

    Reply
    • Mukesh Otwani says

      February 8, 2017 at 10:13 PM

      Hi Sonu,

      Is it a pop up on right corner of screen ? If so then use chrome options as follows
      ChromeOptions opts = new ChromeOptions();
      opts.addArguments(“–disable-extensions”);
      driver = new ChromeDriver(opts);

      Reply
  48. ZORO says

    February 4, 2017 at 8:50 PM

    Hi Mukesh,
    First-of-all,a big thanks on such a simple yet informative post.
    Actually I am a beginner in Selenium/Automation, and I am trying to execute a simple script using Eclipse IDE on chrome browser to open up a page “google.co.in” as mentioned in the code below-:

    import org.openqa.selenium.chrome.ChromeDriver;

    public class TestChrome {

    public static void main(String[] args) {

    System.setProperty(“webdriver.chrome.driver”, “C:C:\\Users\\inpdhawan\\Downloads\\chromedriver_win32”);

    // Initialize browser
    ChromeDriver driver=new ChromeDriver();
    }
    But on Running the Script , even though Eclipse IDE shows no error but no webpage is poened up in the browser.
    Can you please provide a solution to this.I am stuck here from past one week.

    Regards
    ZORO

    Reply
    • Mukesh Otwani says

      February 5, 2017 at 2:41 PM

      Hi Zoro,

      If I am seeing correctly then you have given an unappropriate path for chromedriver.exe. I can observe C drive in path mentioned twice. Moreover also add .exe at end of chromedriver_win32.

      Reply
      • ZORO says

        February 5, 2017 at 5:14 PM

        Hi Mukesh,
        The workaround provided nailed the problem
        🙂
        Thanks a ton for your prompt reply

        Reply
        • Mukesh Otwani says

          February 5, 2017 at 6:43 PM

          Cheers..!!!

          Reply
  49. Sanjay says

    January 26, 2017 at 3:32 PM

    Thank u mukesh,
    What u said abt clearing history is correct but
    I want to clear browser history. fllowing is the scenario
    1.open browser
    2.enter url (facebook)
    3.navigate to gmail
    4.clear history(facebook,gmail) which is currently opened by selenium web driver
    how to automate this test script.I am used Actions class and key board events but i am not getting

    Reply
    • Mukesh Otwani says

      January 26, 2017 at 10:15 PM

      Hi Sanjay,

      Can you try with keyboard shortcut for clear history using robot class.

      Reply
  50. Sanjay says

    January 21, 2017 at 9:05 PM

    Hello Mukesh,
    I want to clear chrome browser history.How to clear browser history

    Reply
    • Mukesh Otwani says

      January 21, 2017 at 10:01 PM

      Hi Sanjay,

      Selenium always opens new profile/fresh instance of browser by default along with no addons/extensions. So there is no need to clear history separately.

      Reply
  51. Nitin says

    January 18, 2017 at 10:03 AM

    Hi forum,
    public static void main(String[] args) {
    WebDriver driver;
    System.setProperty(“webdriver.chrome.driver”,”E://Selenium//Selenium Webdriver//chromedriver.exe”);
    driver = new ChromeDriver();

    driver.manage().window().maximize();
    driver.get(“http://localhost:2424/login.do”);

    Output-Browser is loaded but URL is not open
    Error Message-Starting ChromeDriver (v2.9.248315) on port 20915
    Exception in thread “main” org.openqa.selenium.remote.UnreachableBrowserException: Error communicating with the remote browser. It may have died.

    Reply
    • Mukesh Otwani says

      January 19, 2017 at 11:54 AM

      Hi Nitin,

      Which version of chromedriver and selenium are you using?
      Its better if you giv a try to chromedriver.exe of 2.27 version and selenium 2.53.0

      Reply
  52. thejaswini says

    November 6, 2016 at 2:09 AM

    Hi Mukesh,
    I’m getting error as
    Starting ChromeDriver 2.24.417431 (9aea000394714d2fbb20850021f6204f2256b9cf) on port 14722
    Only local connections are allowed.
    Exception in thread “main” org.openqa.selenium.WebDriverException: unknown error: cannot find Chrome binary

    Reply
    • Mukesh Otwani says

      November 6, 2016 at 10:09 AM

      Hi,

      Kindly use chrome driver 2.25 version which will fix your issue.

      Link for driver- Get 25 version only

      https://chromedriver.storage.googleapis.com/index.html

      Reply
  53. sharath says

    November 1, 2016 at 1:51 PM

    Hi Mukesh,

    I am getting following error

    Exception in thread “main” org.openqa.selenium.SessionNotCreatedException: session not created exception
    from unknown error: Runtime.executionContextCreated has invalid ‘context’: {“auxData”:{“frameId”:”9552.1″,”isDefault”:true},”id”:1,”name”:””,”origin”:”://”}
    (Session info: chrome=54.0.2840.71)
    (Driver info: chromedriver=2.21.371459 (36d3d07f660ff2bc1bf28a75d1cdabed0983e7c4),platform=Windows NT 6.1 SP1 x86_64) (WARNING: The server did not provide any stacktrace information)
    Command duration or timeout: 1.48 seconds
    Build info: version: ‘2.53.1’, revision: ‘a36b8b1’, time: ‘2016-06-30 17:32:46

    Reply
    • Mukesh Otwani says

      November 4, 2016 at 2:39 AM

      Hi Sharath,

      kindly use 2.25 version of chrome driver.

      Reply
  54. naresh says

    September 13, 2016 at 2:00 PM

    Hello,

    I am not able to launch browser yet and getting error..(http://prntscr.com/chffda)

    please help me , how to fix this ?

    public class Sep13 {

    public static void main(String[] args) {

    System.setProperty(“webdriver.chrome.driver”,”C:\\Users\\naresh\\Downloads\\selenium-java-3.0.0-beta2\\chromedriver.exe”);

    WebDriver driver= new ChromeDriver

    driver.get(“http://www.google.com”);

    driver.manage().window().maximize();

    driver.getTitle();

    Reply
    • Mukesh Otwani says

      September 15, 2016 at 5:17 PM

      Can you try with Selenium 2.53.1 http://selenium-release.storage.googleapis.com/index.html

      Reply
  55. Div_QueenBee (@bug_huntress) says

    August 3, 2016 at 12:10 PM

    It worked fine for me, thanks 🙂

    Reply
  56. Rahul says

    July 9, 2016 at 2:41 AM

    Hi Mukesh,

    Apart from this is there any method to invoke chrome browser?

    Reply
    • Mukesh Otwani says

      July 9, 2016 at 10:59 AM

      Hi Rahul,

      Another way is you can set chromedriver path in env variables and then everytinme it will start with driver.

      Reply
      • Dilshad Randhawa says

        August 17, 2016 at 2:32 AM

        Hi Mukesh,
        Can you please tell from Selenium IDE how this will work to work on multiple browsers? Let’s say for example I test a web application/webpage and I want to run it in Chrome and IE, please explain step by step process with Python

        Reply
        • Mukesh Otwani says

          August 18, 2016 at 9:37 AM

          Hi Dilshad,

          For Java try below http://learn-automation.com/cross-browser-testing-using-selenium-webdriver/

          Reply
      • Swetha says

        November 18, 2016 at 2:34 PM

        Apart from this is there any method to invoke chrome browser?

        Reply
        • Mukesh Otwani says

          November 23, 2016 at 3:25 PM

          Hi Swetha,

          You can set driver in path variable then you don’t have to mention path in test scripts.

          Reply
      • Gaurav Khurana says

        December 2, 2016 at 12:40 PM

        I created a system variable with the name as ‘webdriver.chrome.driver’ and value as ‘D:\software\chromedriver64’

        then in the system path variable i have added in the front %webdriver.chrome.driver%

        Is this the right way ? Do We need to mention chroredriver.exe also somewhere

        its not working the above way

        Reply
        • Mukesh Otwani says

          December 6, 2016 at 12:24 PM

          Hi Gaurav if you keep driver path in System variable then it will work.

          Reply
  57. Mitali Singh says

    April 14, 2016 at 1:03 PM

    Hi,

    I have provided the path for chromedriver in my code.

    System.setProperty(“webdriver.chrome.driver”,”C:\\Users\\mitngh01\\Desktop\\Driver\\chromedriver.exe”);
    System.out.println(“zxcv”);
    WebDriver d = new ChromeDriver();

    Still getting error as

    Exception in thread “main” java.lang.NoClassDefFoundError: com/google/common/base/Function
    at Selenium1.main(Selenium1.java:10)
    Caused by: java.lang.ClassNotFoundException: com.google.common.base.Function
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    … 1 more

    kindly suggest.

    Reply
    • Mukesh Otwani says

      April 14, 2016 at 2:05 PM

      Hi Mitali,

      Selenium server is missing please add the jar and run again.

      Reply
  58. sara says

    April 4, 2016 at 11:43 AM

    Apr 04, 2016 11:36:33 AM org.openqa.selenium.os.UnixProcess checkForError
    SEVERE: org.apache.commons.exec.ExecuteException: Execution failed (Exit value: -559038737. Caused by java.io.IOException: Cannot run program “D:\sele_matter\chromedriver_win32.zip” (in directory “.”): CreateProcess error=193, %1 is not a valid Win32 application)

    got this error???

    Reply
    • Mukesh Otwani says

      April 4, 2016 at 11:44 PM

      is it fixed Sara?

      Reply
  59. Aarohi says

    March 7, 2016 at 12:29 PM

    Hi Mukesh,

    I’m getting error as Cannot run program “D:\Selenium driver\chromedriver_mac32\chromedriver” (in directory “.”): CreateProcess error=193, %1 is not a valid Win32 application). could you please suggest any solution??

    Reply
    • Mukesh Otwani says

      March 11, 2016 at 6:39 PM

      Hi Aarohi,

      is this fixed?

      Reply
  60. Manjunath says

    November 30, 2015 at 8:16 PM

    Hi,
    In Case of Maven Project, We are adding dependencies. So How to specify path for Chrome Driver?

    Reply
    • Mukesh Otwani says

      November 30, 2015 at 9:04 PM

      Hi Manjunath,

      In case of Chrome driver you can keep driver in resource folder then specify the path

      Reply
  61. Gajendra says

    October 4, 2015 at 12:47 PM

    Thanks Mukesh for your time and solution provided.

    Reply
    • Mukesh Otwani says

      October 5, 2015 at 11:32 PM

      Your most welcome Gajendra 🙂

      Reply
  62. Gajendra says

    October 2, 2015 at 8:23 AM

    HI,

    How would you make a test script to run on different versions of a web browser.

    Say, i have a TC to be verified with chome 32 version only and same should work on ie 9, 10 and 11, or may be with little alterations.

    i think i need to have different node machines with these versions of web browsers installed there.

    Please clarify me on the best practice on this query.

    Thanks in advance.
    Gajendra

    Reply
    • Mukesh Otwani says

      October 4, 2015 at 12:37 PM

      Hi Gajendra,

      You can use https://saucelabs.com/ or https://www.browserstack.com/ which do the same thing.

      If you want to implement the same in your local system then you should have different machines with different configurations.

      Hope its clear for you 🙂

      Thanks
      Mukesh

      Reply
      • Sagar says

        May 5, 2021 at 3:51 PM

        Invalid port exiting …..

        How to overcome this error

        Reply
        • Mukesh Otwani says

          May 5, 2021 at 8:23 PM

          Hi Sagar,

          If you using Java other than version 8 then uninstall the existing one -> Restart your system -> Install Java 8 and try the same once again.

          Reply

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Primary Sidebar

Free Selenium Videos

https://www.youtube.com/watch?v=w_iPCT1ETO4

Search topic

Top Posts & Pages

  • Selenium Webdriver tutorial for beginners
  • How To Fix Eclipse Autocomplete Or Code Suggestion In Eclipse
  • Selenium Webdriver C# Tutorial
  • WHAT ARE YOUR EXPECTATIONS FROM US?

Stay connected via Facebook

Stay connected via Facebook

Archives

Footer

Categories

Recent Post

  • Syllabus For Playwright Online Training Program
  • API Testing Using Postman And RestAssured
  • Disable Personalise Your Web Experience Microsoft Edge Prompt In Selenium
  • How To Fix Error: No tests found In Playwright
  • How To Fix Eclipse Autocomplete Or Code Suggestion In Eclipse

Top Posts & Pages

  • Selenium Webdriver tutorial for beginners
  • How To Fix Eclipse Autocomplete Or Code Suggestion In Eclipse
  • Selenium Webdriver C# Tutorial
  • WHAT ARE YOUR EXPECTATIONS FROM US?