1

我正在使用 Selenium 构建一个关于自动化测试的项目,但我对这些代码行有一些问题:

String exePath = "Browser\\firefox5.0.1\\firefox.exe";
var firefoxProfile = new FirefoxProfile();
m_browser = new FirefoxDriver(new FirefoxBinary(exePath), firefoxProfile);

m_browser.Navigate().GoToUrl(url);

我无法使用这些代码设置 firefox url。但如果我改用 InternetExplorer,我可以设置 IE url。我不知道问题出在哪里

请帮助我。太感谢了!

4

1 回答 1

1

如果要使用 chrome 驱动程序,则必须按如下方式设置属性 -

System.setProperty("webdriver.chrome.driver","chrome driver path");

您可以从以下位置为您的操作系统下载 chromedriver.exe - http://code.google.com/p/chromedriver/downloads/list

要设置 firefox 驱动程序,假设 Firefox 二进制文件位于特定操作系统(例如 windows)的默认位置 - %PROGRAMFILES%\Mozilla Firefox\firefox.exe(参考 - http://code.google.com/p/selenium/wiki/FirefoxDriver

如果 firefox 位于其默认位置,则无需指定 firefox 二进制路径。但如果想这样做,请查看此链接 - FirefoxBinary(java.io.File pathToFirefoxBinary)以确保您的构造函数是正确的。

于 2012-06-30T02:51:24.020 回答