量角器browser.get()在IE11中抛出异常

时间:2015-01-11 19:15:22

标签: angularjs testing protractor internet-explorer-11 end-to-end

我正试图在Win 8.1上的IE11中运行一个简单的量角器测试。

我的测试:

it("should navigate to from the homepage to the add contact page", function () {
    browser.get("http://localhost:4000/");
    // ... it already crashes here
});

我的配置:

exports.config = {
// run in multiple browsers
multiCapabilities:[    
    {
       'browserName': 'internet explorer',
    }
],

specs: ['./**/*js'],

// Options to be passed to Jasmine-node.
jasmineNodeOpts: {
    showColors: true,
    defaultTimeoutInterval: 30000
},

onPrepare: function () {
    require('jasmine-reporters');
    jasmine.getEnv().addReporter(
        new jasmine.JUnitXmlReporter('xmloutput', true, true)
    );
}
};

错误:

Starting selenium standalone server...
[launcher] Running 1 instances of WebDriver
Selenium standalone server started at http://169.254.80.80:31289/wd/hub
[31mF[0m

Failures:

  1) add new contact page should navigate to from the homepage to the add contact page
   Message:
     [31mUnknownError: JavaScript error (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 63 milliseconds
Build info: version: '2.44.0', revision: '76d78cf', time: '2014-10-23 20:02:37'
System info: host: 'Florian-Lenovo', ip: '169.254.80.80', os.name: 'Windows 8.1', os.arch: 'amd64', os.version: '6.3', java.version: '1.8.0_25'
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:22540/, takesScreenshot=true, javascriptEnabled=true, ignoreProtectedModeSettings=false, enableElementCacheCleanup=true, cssSelectorsEnabled=true, unexpectedAlertBehaviour=dismiss}]
Session ID: 2b2e9619-3eb8-493f-bc9d-5354a91f7f8b[0m
   Stacktrace:
     UnknownError: JavaScript error (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 63 milliseconds
Build info: version: '2.44.0', revision: '76d78cf', time: '2014-10-23 20:02:37'
System info: host: 'Florian-Lenovo', ip: '169.254.80.80', os.name: 'Windows 8.1', os.arch: 'amd64', os.version: '6.3', java.version: '1.8.0_25'
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:22540/, takesScreenshot=true, javascriptEnabled=true, ignoreProtectedModeSettings=false, enableElementCacheCleanup=true, cssSelectorsEnabled=true, unexpectedAlertBehaviour=dismiss}]
Session ID: 2b2e9619-3eb8-493f-bc9d-5354a91f7f8b
    at new bot.Error (C:\Users\Florian\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\atoms\error.js:113:18)
    at Object.bot.response.checkResponse (C:\Users\Florian\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\atoms\response.js:106:9)
    at C:\Users\Florian\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\webdriver\webdriver.js:362:20
    at C:\Users\Florian\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\goog\base.js:1582:15
    at [object Object].webdriver.promise.ControlFlow.runInNewFrame_ (C:\Users\Florian\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\webdriver\promise.js:1654:20)
    at notify (C:\Users\Florian\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\webdriver\promise.js:465:12)
    at notifyAll (C:\Users\Florian\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\webdriver\promise.js:442:7)
    at resolve (C:\Users\Florian\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\webdriver\promise.js:420:7)
    at [object Object].fulfill (C:\Users\Florian\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\webdriver\promise.js:535:5)
    at C:\Users\Florian\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\webdriver\promise.js:1520:10
==== async task ====
Protractor.get(http://localhost:4000/) - reset url
    at [object Object].webdriver.WebDriver.schedule (C:\Users\Florian\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\webdriver\webdriver.js:345:15)
    at [object Object].Protractor.executeScript_ (C:\Users\Florian\AppData\Roaming\npm\node_modules\protractor\lib\protractor.js:223:22)
    at [object Object].Protractor.get (C:\Users\Florian\AppData\Roaming\npm\node_modules\protractor\lib\protractor.js:440:8)
    at [object Object].<anonymous> (C:\OneDrive\Projects\Gyst\Gyst.Web\Scripts\tests\e2e\contacts\addNewContactSpecs.ts:10:17)
    at C:\Users\Florian\AppData\Roaming\npm\node_modules\protractor\node_modules\jasminewd\index.js:94:14
    at [object Object].webdriver.promise.ControlFlow.runInNewFrame_ (C:\Users\Florian\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\webdriver\promise.js:1654:20)
    at [object Object].webdriver.promise.ControlFlow.runEventLoop_ (C:\Users\Florian\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\webdriver\promise.js:1518:8)
==== async task ====
Asynchronous test function: it()
    at [object Object].<anonymous> (C:\Users\Florian\AppData\Roaming\npm\node_modules\protractor\node_modules\jasminewd\index.js:93:33)
    at [object Object].<anonymous> (C:\Users\Florian\AppData\Roaming\npm\node_modules\protractor\node_modules\minijasminenode\lib\async-callback.js:45:37)
    at [object Object].jasmine.Block.execute (C:\Users\Florian\AppData\Roaming\npm\node_modules\protractor\node_modules\minijasminenode\lib\jasmine-1.3.1.js:1174:17)
    at [object Object].jasmine.Queue.next_ (C:\Users\Florian\AppData\Roaming\npm\node_modules\protractor\node_modules\minijasminenode\lib\jasmine-1.3.1.js:2209:31)
    at onComplete (C:\Users\Florian\AppData\Roaming\npm\node_modules\protractor\node_modules\minijasminenode\lib\jasmine-1.3.1.js:2205:18)
    at [object Object].jasmine.WaitsForBlock.execute (C:\Users\Florian\AppData\Roaming\npm\node_modules\protractor\node_modules\minijasminenode\lib\jasmine-1.3.1.js:2704:5)
    at [object Object]._onTimeout (C:\Users\Florian\AppData\Roaming\npm\node_modules\protractor\node_modules\minijasminenode\lib\jasmine-1.3.1.js:2718:12)
Error
    at [object Object].<anonymous> (C:\OneDrive\Projects\Gyst\Gyst.Web\Scripts\tests\e2e\contacts\addNewContactSpecs.ts:9:5)
    at [object Object].jasmine.Env.describe_ (C:\Users\Florian\AppData\Roaming\npm\node_modules\protractor\node_modules\minijasminenode\lib\jasmine-1.3.1.js:913:21)
    at [object Object].jasmine.Env.describe (C:\Users\Florian\AppData\Roaming\npm\node_modules\protractor\node_modules\minijasminenode\lib\jasmine-1.3.1.js:898:15)
    at describe (C:\Users\Florian\AppData\Roaming\npm\node_modules\protractor\node_modules\minijasminenode\lib\jasmine-1.3.1.js:658:27)
    at Object.<anonymous> (C:\OneDrive\Projects\Gyst\Gyst.Web\Scripts\tests\e2e\contacts\addNewContactSpecs.ts:1:34)

Finished in 1.015 seconds
[31m1 test, 1 assertion, 1 failure
[0m
Shutting down selenium standalone server.
[launcher] 0 instance(s) of WebDriver still running
[launcher] internet explorer #1 failed 1 test(s)
[launcher] overall: 1 failed spec(s)
[launcher] Process exited with error code 1

我对量角器仍然很陌生,我不知道如何处理这个问题。 我的测试在Chrome和Firefox中运行良好。 有什么想法吗?

3 个答案:

答案 0 :(得分:2)

试试这个,对我来说,它有一个类似的错误A Jasmine spec timed out. Resetting the WebDriver Control Flow.

量角器-conf.js

{"browserName": "internet explorer",
    "ie.forceCreateProcessApi": true,
    "ie.browserCommandLineSwitches": "-private",
    "ie.ensureCleanSession": "true",
    "seleniumAddress": 'http://10.0.1.XXX:4444/wd/hub'
}

确保设置路径TabProcGrowth" = dword: 00000000中的HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main

答案 1 :(得分:1)

IEExplorerDriver应该实现异步脚本执行,除了有几个已知问题,驱动程序可能很慢并且经常超时等待页面加载:

http://angular.github.io/protractor/#/browser-setup

https://github.com/angular/protractor/issues/1052

根据您提供的日志,在您的情况下,行以某种方式指示已发生超时。

对于Protactor团队来说,这仍然是一个悬而未决的问题,希望他们能尽快找到解决方案。

可能需要考虑的另一件事是,Protactor使用Promise来异步执行脚本,这在浏览器支持方面目前仍处于IE11的预览版本中

https://status.modern.ie/promiseses6

答案 2 :(得分:0)

对于没有角度的站点而不是driver.get,请使用以下代码。

browser.driver.get(“ https://www.npmjs.com/package/use-debounce”);

还可以在IE> IE选项中访问Internet选项,并为所有区域启用保护模式

我设法通过配置js中的以下功能解决了这个问题

 onPrepare: function () {
        browser.driver.ignoreSynchronization = true;// for non-angular set true. default value is false 
        browser.waitForAngularEnabled(false);   // for non-angular set false. default value is true  
      browser.driver.manage().window().setSize(1280, 1024);

       }, 
 capabilities: {
     browserName: 'internet explorer',
     platform: 'ANY',
     version: '11'
    },