How can i run my scenario with chrome using junit4 and selenium webdriver How can i run my scenario with chrome using junit4 and selenium webdriver selenium selenium

How can i run my scenario with chrome using junit4 and selenium webdriver


First start selenium server with below command

java -Dwebdriver.chrome.driver=latest\chromedriver.exe -jar selenium-server-standalone-2.31.0.jar

And then use below logic to create chrome driver instance

System.setProperty("webdriver.chrome.driver", "D:\\selenium\\latest\\chromedriver.exe");DesiredCapabilities dc=new DesiredCapabilities();dc.setBrowserName("chrome");driver=new RemoteWebDriver(new URL("http://localhost:4444/wd/hub"),dc);

And run your test case using driver instance

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


try adding to the code before you initialize the Chromedriver:

  System.setProperty("webdriver.chrome.driver", "C:\\Users\\lenovo\\Desktop\\Projet\\chromedriver_win_26.0.1383.0\\chromedriver.exe");

EDITRegarding your comments. Try this:

  • Press Ctrl + Alt + Del
  • Choose Task Manager
  • Switch to Processes
  • Sort by Name
  • Kill all "chromedriver" processes
  • Optionally: Restart computer
  • Try again

BTW, do you have Chrome installed?

EDIT2Now I realised, that you are using RemoteWebDriver! So you have to start hub and node like this:

1st the hub:

 java -jar lib/selenium-server-standalone-2.31.0.jar -role hub

2nd the node:

java -jar selenium-server-standalone-2.31.0.jar -role node -hub http://localhost:4444/grid/register -maxSession 15 -browser browserName="chrome",version=ANY,platform=WINDOWS,maxInstances=15 -Dwebdriver.chrome.driver=C:\Users\lenovo\Desktop\Projet\chromedriver_win_26.0.1383.0\chromedriver.exe

And then run your test