无法启动IE浏览器在硒webdriver
我写了一个示例代码启动IE browser
并加载谷歌页面。无法启动IE浏览器在硒webdriver
public class Sample {
public static void main(String[] args)
{
// TODO Auto-generated method stub
System.setProperty("webdriver.ie.driver","H:/IEDriverServer.exe");
WebDriver driver=new InternetExplorerDriver();
driver.manage().window().maximize();
driver.manage().timeouts().implicitlyWait(10,TimeUnit.SECONDS);
driver.get("http://www.google.com");
}
}
但是,当我不提示任何错误运行此脚本,它将启动浏览器,它就会立即关闭(少于2秒)和脚本不会终止。
这是我可以控制台屏幕上看到:
Started
InternetExplorerDriver
server (32-bit)2.53.1.0
Listening on port 46974
Only local connections are allowed
任何一个可以帮助我在这个问题上?
尝试:
public static void main(String[] args)
{
try
{
string path = @"H:\IEDriverServer.exe";
WebDriver driver = new InternetExplorerDriver(path);
driver.manage().timeouts().implicitlyWait(10,TimeUnit.SECONDS);
driver.manage().window().maximize();
driver.get("http://www.google.com");
}
catch(Exception ex)
{
}
}
如果您IE
版本,有以下步骤来解决它: -
- 32位和64位的注册表项。
创建DWORD值与名称“IEXPLORE.EXE”和在下面的项
for 32-bit Windows :- HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BFCACHE
for 64-bit Windows :- HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BFCACHE
- 的 值的0调整 “保护模式” 是相同的通过浏览设置 - > Internet选项 - >安全
- 取消选中“启用保护模式”为所有区域
- 甚至重新启动。
如果仍然得到问题,在“Internet选项”,即加入域的“受信任的站点”列表(HTTPS到受信任的站点,和http以本地Intranet)。
希望它会帮助你.. :)
package tests;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.ie.InternetExplorerDriver;
public class Sample {
public static void main(String[] args) {
System.setProperty("webdriver.ie.driver","C:\\Automation Workspace\\ComplianceDashboardProject\\Vendor\\IEDriverServer.exe");
WebDriver driver=new InternetExplorerDriver();
driver.manage().window().maximize();
driver.manage().timeouts().implicitlyWait(10,TimeUnit.SECONDS);
driver.get("http://www.google.com");
driver.quit();
}
}
我做以上,并得到它的工作。也许尝试将您的驱动程序文件移动到另一个位置,以确保没有某个安全问题。
我完全同意sandeep的解决方案以及将缩放级别设置为100%的永久性解决方案,因为我在添加少量代码行时遇到了问题以便进行设置。
这些是代码行,我发现后,我浏览为缩放等级100%的误差:
System.setProperty("webdriver.ie.driver", "C:/Drivers/IEDriverServer.exe");
DesiredCapabilities capabilities = DesiredCapabilities.internetExplorer();
capabilities.setCapability("ignoreZoomSetting", true);
driver= new InternetExplorerDriver(capabilities);
driver.manage().window().maximize();
对于安全设置通过IE来执行代码:按照本link.` 'http://www.seleniumeasy.com/selenium-tutorials/how-to-run-webdriver-in-ie-browser步骤“
希望这解决方案可帮助你.... :)
在IE中执行代码需要设置一些安全设置你的浏览器: 1)打开IE 转到工具 - 选择互联网选项 - 选择安全 将所有区域(互联网,本地互联网,可信站点,受限站点)设置为相同的保护模式(启用或禁用无关) 2)将缩放设置为100% :在右上角的iE浏览器中选择设置符号。选择缩放。设置缩放到100%(你想要什么像125,200等)关闭IE浏览器。 3)如果你想看到缩放显示在页面上: 在浏览器的右上角,右键单击你会得到一些选项,启用状态栏。然后,您将能够在页面的右侧底部看到缩放。
提供的驱动程序是最新的? –
是它的IEDriver 2.53.1 – Suraj