使用css选择器查​​找元素== #link返回了意外错误

时间:2015-04-06 22:32:45

标签: protractor

运行带有量角器的文件时出现此错误:

$ ./protractor config.js 
Using the selenium server at http://ie11.dev:4444/wd/hub
[launcher] Running 1 instances of WebDriver
F

Failures:

  1) test a simple mouseMove() it should show a popup
   Message:
     UnknownError: Finding elements with css selector == #linkreturned an unexpected error (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 301 milliseconds
Build info: version: '2.44.0', revision: '76d78cf', time: '2014-10-23 20:02:37'
System info: host: 'WIN-A0RAN2MRA9O', ip: '172.16.196.133', os.name: 'Windows 7', os.arch: 'x86', os.version: '6.1', java.version: '1.8.0_31'
Driver info: org.openqa.selenium.ie.InternetExplorerDriver
Capabilities [{browserAttachTimeout=0, enablePersistentHover=true, ie.forceCreateProcessApi=false, ie.usePerProcessProxy=false, ignoreZoomSetting=false, handlesAlerts=true, version=11, platform=WINDOWS, nativeEvents=true, ie.ensureCleanSession=false, elementScrollBehavior=0, ie.browserCommandLineSwitches=, requireWindowFocus=false, browserName=internet explorer, initialBrowserUrl=http://localhost:33476/, takesScreenshot=true, javascriptEnabled=true, ignoreProtectedModeSettings=false, enableElementCacheCleanup=true, cssSelectorsEnabled=true, unexpectedAlertBehaviour=dismiss}]
Session ID: d59ae082-5864-4734-9df1-5f0dff04bb7b
   Stacktrace:
     UnknownError: Finding elements with css selector == #linkreturned an unexpected error (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 301 milliseconds
Build info: version: '2.44.0', revision: '76d78cf', time: '2014-10-23 20:02:37'
System info: host: 'WIN-A0RAN2MRA9O', ip: '172.16.196.133', os.name: 'Windows 7', os.arch: 'x86', os.version: '6.1', java.version: '1.8.0_31'
Driver info: org.openqa.selenium.ie.InternetExplorerDriver
Capabilities [{browserAttachTimeout=0, enablePersistentHover=true, ie.forceCreateProcessApi=false, ie.usePerProcessProxy=false, ignoreZoomSetting=false, handlesAlerts=true, version=11, platform=WINDOWS, nativeEvents=true, ie.ensureCleanSession=false, elementScrollBehavior=0, ie.browserCommandLineSwitches=, requireWindowFocus=false, browserName=internet explorer, initialBrowserUrl=http://localhost:33476/, takesScreenshot=true, javascriptEnabled=true, ignoreProtectedModeSettings=false, enableElementCacheCleanup=true, cssSelectorsEnabled=true, unexpectedAlertBehaviour=dismiss}]
Session ID: d59ae082-5864-4734-9df1-5f0dff04bb7b
==== async task ====
WebDriver.findElements(By.cssSelector("#link"))
==== async task ====
Asynchronous test function: it()
Error
    at [object Object].<anonymous> (/home/xxxxxxxxxxxx/protractortest/test.js:6:25)
Error
    at [object Object].<anonymous> (/home/xxxxxxxxxxxx/protractortest/test.js:2:3)
    at Object.<anonymous> (/home/xxxxxxxxxxxx/protractortest/test.js:1:63)

Finished in 2.04 seconds
1 test, 1 assertion, 1 failure

[launcher] 0 instance(s) of WebDriver still running
[launcher] internet explorer11 #1 failed 1 test(s)
[launcher] overall: 1 failed spec(s)
[launcher] Process exited with error code 1

test.js

describe('test a simple mouseMove()', function() {
  it('it should show a popup', function() {
      browser.ignoreSynchronization = true;
      browser.driver.get('file:///C:/Users/xxxxxxxx/Documents/protractortest/index.html');
      browser.sleep(1000);
      expect($("#link").isDisplayed()).toBeTruthy();
      // expect(element(by.id("link")).isDisplayed()).toBeTruthy();
      // browser.actions().mouseMove(element(by.id("link"))).perform();
      // browser.sleep(5000);
      // expect($("#hover-div").isDisplayed()).toBeTruthy();
  });
});

的index.html

http://pastie.org/private/mm4xedyqsw0vrpmm5gqwiw

硒:2.44 量角器:1.7.0 使用IE11和Win7的VM

此测试的全部目的是检查mouseMove()是否在IE11下工作。但我无法选择元素。

顺便说一句,IE11在另一个项目中运行良好,所以在这个例子中我可能缺少配置中的一些东西。但另一个项目过于复杂,而且配置非常庞大。

1 个答案:

答案 0 :(得分:0)

我认为问题在于我使用的是file://协议。我改为http://(在我的主机上安装Apache等,并从VM访问它),它工作正常。我想这是因为IE 11中的某种安全设置。我希望有一个更具描述性的错误。