Selenium 这是WebDriver服务器的初始起始页
相同的代码在firefox中运行,但它没有在IE9中执行,并显示字符串消息“这是WebDriver服务器的初始起始页”,而在其他浏览器上未发现错误Selenium 这是WebDriver服务器的初始起始页,selenium,selenium-webdriver,testng,Selenium,Selenium Webdriver,Testng,相同的代码在firefox中运行,但它没有在IE9中执行,并显示字符串消息“这是WebDriver服务器的初始起始页”,而在其他浏览器上未发现错误 public void setUp() throws Exception { File file = new File("C:/Users/Sunil.Wali/Desktop/Softwares/IEDriverServer_Win32_2.37.0/IEDriverServer.exe"); System.set
public void setUp() throws Exception {
File file = new File("C:/Users/Sunil.Wali/Desktop/Softwares/IEDriverServer_Win32_2.37.0/IEDriverServer.exe");
System.setProperty("webdriver.ie.driver", file.getAbsolutePath());
driver = new InternetExplorerDriver();
// driver = new FirefoxDriver();
baseUrl = "https://tssstrpms501.corp.trelleborg.com:12001";
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
}
@Test
public void testLogin() throws Exception {
driver.get(baseUrl + "/ProcessPortal/login.jsp");
driver.findElement(By.id("username")).clear();
driver.findElement(By.id("username")).sendKeys("sunil.wali");
driver.findElement(By.id("password")).clear();
driver.findElement(By.id("password")).sendKeys("Trelleborg@123");
driver.findElement(By.id("log_in")).click();
driver.findElement(By.id("processPortalUserDropdown")).click();
driver.findElement(By.id("dijit_MenuItem_56_text")).click();
}
@After
public void tearDown() throws Exception {
driver.quit();
String verificationErrorString = verificationErrors.toString();
if (!"".equals(verificationErrorString)) {
fail(verificationErrorString);
}
}
输出:-
已启动InternetExplorerDriver服务器(32位)
2.37.0.0
在端口31651上侦听,确保每个区域的保护模式设置值相同。参考 更新:将
忽略缩放设置
和忽略保护模式设置
功能设置为真
在您无权更改设置时会有所帮助
如果您正在使用,可以按以下方式设置功能:
driver.name=iexplorerDriver
iexplorer.additional.capabilities={'ignoreProtectedModeSettings':true,'ignoreZoomSetting':true,'nativeEvents':false,'acceptSslCerts':true}
- 在Windows Vista或Windows 7上的IE 7或更高版本上,必须设置 每个区域的保护模式设置应为相同的值。价值 可以打开或关闭,只要每个区域都相同。设置 在保护模式设置中,从中选择“Internet选项…” “工具”菜单,然后单击“安全”选项卡。对于每个区域,将有 在标签底部有一个复选框,标记为“启用受保护” 模式”李>
- 此外,IE 10必须禁用“增强保护模式” 更高。此选项位于Internet的“高级”选项卡中 选项对话框
/*
* This is an implementation of the Local Driver Provider.
* It is responsible for setting up the account object, tearing
* it down, and setting up the driver correctly.
*
* TODO - it would be nice to do this in the launcher phase,
* so that we only start the local selenium once per entire launch.
* ------Modified by Jonathan Arias mail: jab504@gmail.com-----------
*/
var util = require('util'),
log = require('../logger.js'),
path = require('path'),
remote = require('selenium-webdriver/remote'),
fs = require('fs'),
q = require('q'),
DriverProvider = require('./driverProvider');
var LocalDriverProvider = function(config) {
DriverProvider.call(this, config);
this.server_ = null;
};
util.inherits(LocalDriverProvider, DriverProvider);
/**
* Helper to locate the default jar path if none is provided by the user.
* @private
*/
LocalDriverProvider.prototype.addDefaultBinaryLocs_ = function() {
if (!this.config_.seleniumServerJar) {
log.debug('Attempting to find the SeleniumServerJar in the default ' +
'location used by webdriver-manager');
this.config_.seleniumServerJar = path.resolve(__dirname,
'../../selenium/selenium-server-standalone-' +
require('../../config.json').webdriverVersions.selenium + '.jar');
}
if (!fs.existsSync(this.config_.seleniumServerJar)) {
throw new Error('No selenium server jar found at the specified ' +
'location (' + this.config_.seleniumServerJar +
'). Check that the version number is up to date.');
}
if (this.config_.capabilities.browserName === 'chrome') {
if (!this.config_.chromeDriver) {
log.debug('Attempting to find the chromedriver binary in the default ' +
'location used by webdriver-manager');
this.config_.chromeDriver =
path.resolve(__dirname, '../../selenium/chromedriver');
}
// Check if file exists, if not try .exe or fail accordingly
if (!fs.existsSync(this.config_.chromeDriver)) {
if (fs.existsSync(this.config_.chromeDriver + '.exe')) {
this.config_.chromeDriver += '.exe';
} else {
throw new Error('Could not find chromedriver at ' +
this.config_.chromeDriver);
}
}
}
if (this.config_.capabilities.browserName === 'internet explorer') {
if (!this.config_.IEDriverServer) {
log.debug('Attempting to find the Internet explorer binary in the default ' +
'location used by webdriver-manager');
this.config_.IEDriverServer =
path.resolve(__dirname, '../../selenium/IEDriverServer');
}
// Check if file exists, if not try .exe or fail accordingly
if (!fs.existsSync(this.config_.IEDriverServer)) {
if (fs.existsSync(this.config_.IEDriverServer + '.exe')) {
this.config_.IEDriverServer += '.exe';
} else {
throw new Error('Could not find IEDriverServer at ' +
this.config_.IEDriverServer);
}
}
}
};
/**
* Configure and launch (if applicable) the object's environment.
* @public
* @return {q.promise} A promise which will resolve when the environment is
* ready to test.
*/
LocalDriverProvider.prototype.setupEnv = function() {
var deferred = q.defer(),
self = this;
this.addDefaultBinaryLocs_();
log.puts('Starting selenium standalone server...');
// configure server
if (this.config_.chromeDriver) {
this.config_.seleniumArgs.push('-Dwebdriver.chrome.driver=' +
this.config_.chromeDriver);
}
if (this.config_.IEDriverServer) {
this.config_.seleniumArgs.push('-Dwebdriver.ie.driver=' +
this.config_.IEDriverServer);
}
this.server_ = new remote.SeleniumServer(this.config_.seleniumServerJar, {
args: this.config_.seleniumArgs,
port: this.config_.seleniumPort
});
//start local server, grab hosted address, and resolve promise
this.server_.start().then(function(url) {
log.puts('Selenium standalone server started at ' + url);
self.server_.address().then(function(address) {
self.config_.seleniumAddress = address;
deferred.resolve();
});
});
return deferred.promise;
};
/**
* Teardown and destroy the environment and do any associated cleanup.
* Shuts down the drivers and server.
*
* @public
* @override
* @return {q.promise} A promise which will resolve when the environment
* is down.
*/
LocalDriverProvider.prototype.teardownEnv = function() {
var self = this;
var deferred = q.defer();
DriverProvider.prototype.teardownEnv.call(this).then(function() {
log.puts('Shutting down selenium standalone server.');
self.server_.stop().then(function() {
deferred.resolve();
});
});
return deferred.promise;
};
// new instance w/ each include
module.exports = function(config) {
return new LocalDriverProvider(config);
};
还要确保将缩放设置为100%。使用下面的代码解决“这是WebDriver服务器的初始起始页”类型的问题。我的机器运转良好
System.setProperty("webdriver.ie.driver", "\\IEDriverServer.exe path");
DesiredCapabilities capabilities = DesiredCapabilities.internetExplorer();
// this line of code is to resolve protected mode issue capabilities.setCapability(InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS, true);
capabilities.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);
driver=new InternetExplorerDriver();
下面的代码为我解决了这个问题
DesiredCapabilities capability = DesiredCapabilities.internetExplorer();
capability.setCapability(InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS, true);
capability.setCapability(InternetExplorerDriver.IGNORE_ZOOM_SETTING, true);
甚至我也有同样的问题。当我确保这里的两条评论都正确完成后,它就开始工作了
非常感谢以上两条评论 尝试使用旧版本的IEDriverServer。我尝试了所有的方法,比如启用保护模式和100%缩放,但仍然停留在本地主机页面上。所以我下载并使用了一个旧版本的iedriver 3.4,瞧,它成功了。使用64位IEDriverServer为我解决了这个问题
DesiredCapabilities capability = DesiredCapabilities.internetExplorer();
capability.setCapability(InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS, true);
capability.setCapability(InternetExplorerDriver.IGNORE_ZOOM_SETTING, true);
我尝试了所有的功能,但仍然失败,最后64位IE服务器修复。所以它只是停留在该页面上,不做任何其他事情?链接指向Selenium Google代码存档,该存档不再包含配置信息,接受的答案具有正确的链接。