我写了一小段代码,使用 Selenium WebDriver 在 Firefox 上打开一个网站。它打开了浏览器窗口,但没有导航到给定的 URL,而是暂时显示一个空白页面。
代码 :-
WebDriver wd = new FirefoxDriver();
System.setProperty("webdriver.firefox.bin","C:\\Program Files\\MozillaFirefox\\Firefox.exe");
wd.navigate().to("https://www.google.co.in/");
wd.manage().timeouts().implicitlyWait(50,TimeUnit.SECONDS);
String Handle1 = wd.getWindowHandle();
System.out.println("Window handle 1 is :- "+Handle1);
错误日志如下:-
Exception in thread "main" org.openqa.selenium.UnsupportedCommandException: Bad request
Command duration or timeout: 1.58 seconds
Build info: version: '2.25.0', revision: '17482', time: '2012-07-18 21:09:54'
System info: os.name: 'Windows XP', os.arch: 'x86', os.version: '5.1', java.version: '1.7.0'
Driver info: driver.version: FirefoxDriver
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:188)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:145)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:498)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:182)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:110)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:185)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:178)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:174)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:92)
at Example1.main(Example1.java:15)
我的设置是:- Mozilla:- 17.0.1 Eclipse:- Helios (3.6) Selenium Java 绑定:- 2.25.0 操作系统:- Windows xp SP3
帮帮我,伙计们。. . 提前致谢。如果有人帮助我理解为什么会发生这种情况,我们将不胜感激。