我正试图通过selenium打开IE 计划:
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.ie.InternetExplorerDriver;
public class testnew
{
public static void main(String...args)
{
System.out.println("hi");
WebDriver driver=new InternetExplorerDriver();
driver.get("http://www.google.com");
//driver.close();
}
}
错误:
输出显示如下,之后是错误。你能 请告诉我这是什么错误。
Started InternetExplorerDriver server (32-bit)
2.44.0.0
Listening on port 27138
log4j:WARN No appenders could be found for logger (org.apache.http.client.protocol.RequestAddCookies).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
Exception in thread "main" 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.17 seconds
Build info: version: '2.46.0', revision: '87c69e2', time: '2015-06-04 16:17:10'
System info: host: 'TCCD3140', ip: '172.17.22.99', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0_40'
Driver info: org.openqa.selenium.ie.InternetExplorerDriver
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:204)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:162)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:605)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:242)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:227)
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 testnew.main(testnew.java:11)
系统:
64位
答案 0 :(得分:0)
您谈到的错误:
log4j:WARN No appenders could be found for logger (org.apache.http.client.protocol.RequestAddCookies).
这是WARNING
,无论如何都不会造成伤害。您之所以看到它,是因为您已使用同一项目中的程序配置了Log4j Logger Module
类。由于此特定脚本/程序未配置Log4j Logger Module
,因此您会看到错误。
但你的主要错误是:
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)
要摆脱这种情况,你必须这样做:
IEDriverServer
可执行文件必须为downloaded并放入您的系统中。Protected Mode
设置设置为相同的值。值可以是 ON
或 OFF
,只要每个区域都相同即可。要设置 Protected Mode settings
,请从 Internet Options...
中选择 Tools menu
,然后点击 Security tab
即可。对于每个区域,选项卡底部都会显示一个标记为 "Enable Protected Mode"
的复选框。Enhanced Protected Mode
。此选项位于 Advanced Tab
对话框的 Internet Options
中。Browser Zoom Level
必须设置为 100%
,以便将原生鼠标事件设置为正确的坐标。Change the size of text, apps, and other items
中将 100%
设置为 Display settings
Registry Entry
,以便驱动程序可以维护与其创建的Internet Explorer实例的连接。对于32位Windows安装,您必须在注册表编辑器中检查的密钥是 HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BFCACHE
。对于64位Windows安装,密钥为 HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BFCACHE
。请注意, FEATURE_BFCACHE subkey
可能存在也可能不存在,如果不存在,则应创建 DWORD
。重要提示:在此密钥中,创建名为 iexplore.exe
的 0
值,其值为 setProperty("")
您自己的代码经过简单的调整(添加System.setProperty("webdriver.ie.driver", "C:\\your_directory\\IEDriverServer.exe");
WebDriver driver = new InternetExplorerDriver();
driver.get("https://www.google.co.in");
System.out.println("Google Home Page Opened");
driver.quit();
System.out.println("Driver Closed");
行)将如下所示:
IEDriverServer.exe
当您提供 /
的绝对路径时,请使用单个前斜杠\\
或使用转义后斜杠Instance is not managed
Waiting for device mounted to come online : /dev/xvdf
Volume /dev/sdf has failed to attach - aborting
Warning: ec2-startup did not complete successfully
Check the error logs for details
Starting MarkLogic: [FAILED]
。< / p>