我使用的是lang:java framework:testNG
我的系统安装了3-4个版本的Mozilla,如何打开Mozilla特定版本的实例。假设我安装了3.5,3.6 ......版本的Mozilla,我想打开3.6版本并进行测试。
答案 0 :(得分:10)
只需指定版本二进制文件的路径即可,例如 -
FirefoxBinary binary = new FirefoxBinary(new File("path_to_bin"));
FirefoxProfile profile = new FirefoxProfile();
WebDriver driver = new FirefoxDriver(binary, profile);
答案 1 :(得分:6)
只需将正确版本的firefox.exe路径指定给webdriver.firefox.bin属性。
System.setProperty("webdriver.firefox.bin", "c:\\path\\to\\firefox.exe");
答案 2 :(得分:5)
对于firefox
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();
答案 3 :(得分:1)
对于Ruby - Chrome
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
答案 4 :(得分: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");