後使用Selenium版本2.44和IE版本11.0.9600.17728IEDriverServer可執行仍然硒失敗
如果驅動程序構造失敗,因爲保護模式的設置,EXE保持運行。
似乎退出調用會清理所有工作時的事情,但由於驅動程序從未構建過,因此無法使用。
當構造函數拋出異常時,可以停止EXE嗎?
import org.openqa.selenium.ie.InternetExplorerDriver;
public class SeleniumTest
{
public static void main(String[] args)
{
System.setProperty("webdriver.ie.driver", "C:\\IEDriverServer_Win32_2.44.0.exe");
try
{
InternetExplorerDriver driver = new InternetExplorerDriver();
driver.get("http://www.google.com");
Thread.sleep(10 * 1000);
driver.quit();
}
catch (Exception e)
{
/*
* To cause this, change the following IE settings:
*
* On tab: Internet Options->Security
*
* Make sure the four zones do not have the same value for "Enabled Protected Mode"
*/
System.err.println("Failed making the driver");
e.printStackTrace();
}
System.exit(0);
}
}
我看到,當我運行上面的代碼的輸出:
Started InternetExplorerDriver server (32-bit)
2.44.0.0
Listening on port 9550
Failed making the driver
org.openqa.selenium.remote.SessionNotFoundException: Unexpected error launching Internet Explorer. Protected Mode settings are not the same for all zones. Enable Protected Mode must be set to the same value (enabled or disabled) for all zones. (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 1.67 seconds
Build info: version: '2.44.0', revision: '76d78cf323ce037c5f92db6c1bba601c2ac43ad8', time: '2014-10-23 13:11:40'
System info: host: 'T7610', ip: '192.168.0.11', os.name: 'Windows 7', os.arch: 'x86', os.version: '6.1', java.version: '1.8.0_31'
Driver info: org.openqa.selenium.ie.InternetExplorerDriver
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:408)
at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:204)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:162)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:599)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:240)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:225)
at org.openqa.selenium.ie.InternetExplorerDriver.run(InternetExplorerDriver.java:182)
at org.openqa.selenium.ie.InternetExplorerDriver.<init>(InternetExplorerDriver.java:174)
at org.openqa.selenium.ie.InternetExplorerDriver.<init>(InternetExplorerDriver.java:146)
at SeleniumTest.main(SeleniumTest.java:23)
在我的環境中,驅動程序沒有實例化。實例化過程中發生故障。因此,我沒有司機要求退出(正如原帖所述)。 – bigleftie
那麼你可以提供確切的堆棧跟蹤嗎? – Saifur