6

相同的代码在 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.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

4

9 回答 9

8

确保每个区域的保护模式设置值相同。请参阅IE 所需的配置

更新:设置ignoreZoomSettingignoreProtectedModeSettings功能true 在您无权更改设置时提供帮助。

如果您使用的是qaf,您可以设置如下功能:

driver.name=iexplorerDriver
iexplorer.additional.capabilities={'ignoreProtectedModeSettings':true,'ignoreZoomSetting':true,'nativeEvents':false,'acceptSslCerts':true}
于 2013-11-14T14:29:18.250 回答
5
  • 在 Windows Vista 或 Windows 7 上的 IE 7 或更高版本上,您必须将每个区域的保护模式设置设置为相同的值。该值可以打开或关闭,只要每个区域都相同。要设置保护模式设置,请从“工具”菜单中选择“Internet 选项...”,然后单击“安全”选项卡。对于每个区域,标签底部都会有一个标记为“启用保护模式”的复选框。
  • 此外,对于 IE 10 及更高版本,必须禁用“增强保护模式”。此选项位于 Internet 选项对话框的高级选项卡中。

http://code.google.com/p/selenium/wiki/InternetExplorerDriver#Required_Configuration

于 2014-06-19T21:00:01.793 回答
3

还要确保您的缩放设置为 100%。

于 2015-07-03T10:18:18.730 回答
2

尝试使用旧版本的 IEDriverServer。我尝试了一切,比如启用保护模式并放大 100%,但仍然卡在 localhost 页面上。所以我下载并使用了旧版本的 iedriver 3.4 并且它工作正常。

于 2017-10-06T11:02:41.077 回答
1

解决方案:

修改文件 ..\node_modules\protractor\lib\driverProviders\local.js

 /*
 * 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);
};
于 2014-12-10T14:31:16.597 回答
1

即使我有同样的问题。当我确保这里的两条评论正确完成时,它就开始工作了

  1. 确保每个区域的保护模式设置值相同

  2. 确保您的缩放设置为 100%。

非常感谢以上两条评论。

于 2016-06-20T07:00:05.510 回答
1

使用 64 位 IEDriverServer 为我解决了这个问题。

我尝试了所有功能,仍然失败,最后修复了 64 位 IE 服务器。

于 2018-12-10T13:06:00.010 回答
0

使用下面的代码来解决“这是 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();
于 2016-01-15T14:20:00.257 回答
0

下面的代码为我解决了这个问题。

DesiredCapabilities capability = DesiredCapabilities.internetExplorer();
capability.setCapability(InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS, true);
capability.setCapability(InternetExplorerDriver.IGNORE_ZOOM_SETTING, true);
于 2016-03-30T09:33:16.663 回答