0

I am Using Cucumber Selenium Framework for Test Execution. And I have set system Properties correctly because the same script was running fine but now it is throwing "The path to the driver executable must be set by the webdriver.chrome.driver system property;" exception

Here is my Code:


WebDriver driver = new ChromeDriver();
JavascriptExecutor js = (JavascriptExecutor) driver;



@Given("^I am at Kogan Consumer Portal Login page$")
public void i_am_at_Kogan_Consumer_Portal_Login_page() throws Throwable {

    System.setProperty("webdriver.chrome.driver", 
    "C:\\Users\\Shreya\\Desktop\\CucumberFramework\\CucumberFramework\\src\\test\\java\\CucumberFramework\\resources\\chromedriver.exe");
    driver.manage().window().maximize();
    driver.get("http://testing-palm-frontend.solvup.com");
    if (driver.findElements(By.xpath("//input[@formcontrolname='caseNumber']")).size() != 0 && driver.findElements
            (By.xpath("//input[@formcontrolname='taxInvoiceNumber']")).size()!= 0) {

        System.out.println("Successfully Redirected to Kogan Consumer Portal Login Page");

    }
    else {

        Assert.fail("Failed to Redirect to Kogan Consumer Portal Login Page");
    }

}}

What am i doing wrong?

0

You need to set the property BEFORE you instantiate the driver, otherwise if the chromedriver is not in your system path it won't be able to find it.

WebDriver driver;
JavascriptExecutor js = (JavascriptExecutor) driver;



@Given("^I am at Kogan Consumer Portal Login page$")
public void i_am_at_Kogan_Consumer_Portal_Login_page() throws Throwable {

    System.setProperty("webdriver.chrome.driver", 
    "C:\\Users\\Shreya\\Desktop\\CucumberFramework\\CucumberFramework\\src\\test\\java\\CucumberFramework\\resources\\chromedriver.exe");
    driver = new ChromeDriver();
    driver.manage().window().maximize();
    driver.get("http://testing-palm-frontend.solvup.com");
    if (driver.findElements(By.xpath("//input[@formcontrolname='caseNumber']")).size() != 0 && driver.findElements
            (By.xpath("//input[@formcontrolname='taxInvoiceNumber']")).size()!= 0) {

        System.out.println("Successfully Redirected to Kogan Consumer Portal Login Page");

    }
    else {

        Assert.fail("Failed to Redirect to Kogan Consumer Portal Login Page");
    }

}}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.