selenium赢得了URL吗?

时间:2018-04-23 11:05:15

标签: java selenium firefox selenium-webdriver geckodriver

这个我的代码打开火狐并获取谷歌

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;


public class auto {


    public static void main(String[] args) {
        System.setProperty("webdriver.gecko.driver", "//root//Desktop//jarselenium//geckodriver-v0.20.1-linux64/geckodriver");
        WebDriver driver = new FirefoxDriver();
        driver.manage().window().maximize();
        //driver.get("https://www.easybooking.lk/login");
        //driver.manage().timeouts().implicitlyWait(25, TimeUnit.SECONDS); 
        driver.get("https://www.google.com");

    }

}

但是当我运行此代码时selenium打开火狐,但不会在linux中运行此代码的URL

1 个答案:

答案 0 :(得分:1)

根据 Selenium v​​3.11.0 的当前实现, GeckoDriver 0.20.1 我在您的代码块中看不到任何重大问题,也许跟踪日志会有帮助我们更好地了解您的问题。说完你需要按照下面提到的步骤:

  • 当您使用基于Linux的系统时,您需要在单个正斜杠中传递 GeckoDriver 绝对路径,即{ {1}}如下:

    /
  • GeckoDriver 以最大化模式打开 Firefox浏览器客户端时,您需要省略代码行:

    System.setProperty("webdriver.gecko.driver", "/root/Desktop/jarselenium/geckodriver-v0.20.1-linux64/geckodriver");