Getting exception with grid WebDriverException The path to the driver executable must be set

0 votes

I'm trying to set up a Grid with tests running on my ChromeDriver.

So I started my the hub and node using this command: java -jar selenium-server-standalone-2.45.0.jar -role hub java -jar selenium-server-standalone-2.45.0.jar -role node -hub http://localhost:4444/grid/register

And below is my code where I feel there is some issue: 

public class ChromeDriverTest 
{
    private WebDriver driver = null;
    String  BaseURL,NodeURL;

@Before
public void before() throws Exception
{
    BaseURL="http://www.google.com";
    NodeURL="http://localhost:4444/wd/hub";
    File file = new File("C:\\Users\\pushkaryova\\Desktop\\chromedriver.exe");
    System.setProperty("webdriver.chrome.driver", file.getAbsolutePath());
    DesiredCapabilities capa =DesiredCapabilities.chrome();
    capa.setBrowserName("chrome");
    capa.setPlatform(Platform.ANY);
    driver=new RemoteWebDriver(new URL(NodeURL),capa);
}

@Test
public void GoogleSearch() throws Exception 
{
    driver.get("http://www.google.com");
    WebElement searchBox = driver.findElement(By.xpath("//div[3]/div/input[1]"));
    hightlight(searchBox);
    driver.findElement(By.xpath("//div[3]/div/input[1]")).clear();
    driver.findElement(By.xpath("//div[3]/div/input[1]")).sendKeys("Test");
    driver.findElement(By.xpath("//button")).click();
}

public void hightlight(WebElement webElement) throws InterruptedException 
{
    for (int i = 0; i < 2; i++) 
    {
        JavascriptExecutor js = (JavascriptExecutor) driver;
        js.executeScript(
                "arguments[0].setAttribute('style', arguments[1]);",
                webElement, "color: red; border: 3px solid red;");
    }
}
}

The error that I get is this:

org.openqa.selenium.WebDriverException: The path to the driver executable must be set by the webdriver.chrome.driver system property

So, where is this problem? I'v set the driver path correctly!

Apr 13, 2018 in Selenium by kappa3010
• 2,090 points
1,088 views

1 answer to this question.

0 votes

You should start the hub and node separately, even if your executing from the same machine. And while starting them, set the path to executable.
If your hub and node is in the same machine, then open a new cmd prompt and execute the command for starting node separately.
For starting the hub, use this command: 

java -jar selenium-server-standalone-3.4.0.jar -role hub

For starting the nodes, use this: 

java -Dwebdriver.chrome.driver=E:\chromedriver.exe -jar selenium-server-standalone-3.4.0.jar -role node -hub http://192.168.0.11:4444/grid/register

Now when you try to execute your code, there shouldn't be any problem, i'm sure.

answered Apr 13, 2018 by nsv999
• 5,500 points

Related Questions In Selenium

0 votes
1 answer

getting java.lang.IllegalStateException: The path to the driver executable must be set by the webdriver.chrome.driver system property

Hi Sivaranjani, to resolve your issue, Driver path ...READ MORE

answered Sep 3, 2019 in Selenium by Abha
• 28,060 points
5,709 views
+1 vote
1 answer
0 votes
2 answers

Finding WebDriver element with Class Name in java

The better way to handle this element ...READ MORE

answered Apr 10, 2018 in Selenium by nsv999
• 5,500 points
6,218 views
0 votes
2 answers

Problem while using InternetExplorerDriver in Selenium WebDriver

enable trusted connection  in internet explorer by ...READ MORE

answered Aug 31, 2020 in Selenium by Sri
• 3,190 points
6,575 views
0 votes
1 answer

Geo-location microphone camera pop up

To Allow or Block the notification, access using Selenium and you have to ...READ MORE

answered May 11, 2018 in Selenium by Samarpit
• 5,890 points
4,200 views
0 votes
2 answers

How to use such xpath to find web elements

xpath are two types. 1) Absolute XPath:    /html/b ...READ MORE

answered Sep 3, 2020 in Selenium by Sri
• 3,190 points
5,205 views
0 votes
1 answer

Saving data to the same xls file with Robot Framework ExcelLibrary

The documentation of the library states that, ...READ MORE

answered Mar 27, 2018 in Selenium by nsv999
• 5,500 points
4,732 views
0 votes
1 answer