Como uso o executável gecko com selênio

0

Eu uso o Ubuntu 16.10, e eu configurei o Selenium 3.0.1. Eu instalei o geckodriver e usei o seguinte

    WebDriver driver = new FirefoxDriver();

    System.setProperty("webdriver.gecko.driver", "/home/myacc/eclipse/jee-neon2/eclipse/geckodriver");

    driver.get("www.google.co.in");

No entanto, ainda recebo o seguinte erro:

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
    at com.google.common.base.Preconditions.checkState(Preconditions.java:199)
    
por beegee Assem 07.12.2016 / 15:40

1 resposta

0

Inicialize a instância do driver depois de definir a propriedade do sistema.

    System.setProperty("webdriver.gecko.driver",  "/home/myacc/eclipse/jee-
    neon2/eclipse/geckodriver");
    
por Vinoth Kumar Sevagamurthy 26.02.2018 / 15:56