5

我正在使用 lang :java 框架:testNG

我的系统安装了 3-4 个版本的 Mozilla,我如何打开特定版本的 Mozilla 实例。假设我安装了 3.5、3.6、.... 版本的 Mozilla,我想打开 3.6 版本并执行我的测试。

4

5 回答 5

10

Just specify the path to the binary of the version..may be, like-

FirefoxBinary binary = new FirefoxBinary(new File("path_to_bin"));
FirefoxProfile profile = new FirefoxProfile();
WebDriver driver = new FirefoxDriver(binary, profile);
于 2013-06-08T10:31:29.613 回答
6

只需将正确版本的 firefox.exe 的路径分配给 webdriver.firefox.bin 属性。

System.setProperty("webdriver.firefox.bin", "c:\\path\\to\\firefox.exe");
于 2013-06-08T16:27:07.223 回答
5

对于火狐

 System.setProperty("webdriver.gecko.driver","path of geckodriver.exe");
 WebDriver driver = new FirefoxDriver();

来自 Chrome 浏览器

     File file = new File("D:\\selnium webdriver\\driver\\chromedriver.exe");
     System.setProperty("webdriver.chrome.driver", file.getAbsolutePath() );
      WebDriver driver = new ChromeDriver();

对于 Internet Explorer

           File file = new File("D:\\selnium webdriver\\driver\\IEDriverServer.exe");
    System.setProperty("webdriver.ie.driver", file.getAbsolutePath());
       WebDriver driver = new InternetExplorerDriver();
于 2013-06-10T06:15:52.980 回答
1

对于红宝石 - 铬

  caps = Selenium::WebDriver::Remote::Capabilities.chrome("desiredCapabilities" => "chromeOptions" => {"binary" => "/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome"})
  @driver = Selenium::WebDriver.for :chrome, desired_capabilities: caps
于 2017-08-07T12:18:32.563 回答
0
System.setProperty("webdriver.chrome.driver", "./chromedriver.exe");  //for chrome
driver = new ChromeDriver();
driver.manage().window().maximize();
driver.get("WebsiteURL");


System.setProperty("webdriver.gecko.driver", "./geckodriver.exe");  //for firefox
driver=new FirefoxDriver();
driver.manage().window().maximize();
driver.get("WebsiteURL");
于 2018-12-07T17:18:24.717 回答