量角器运行时错误失败:脚本超时:量角器:进程退出,错误代码为1

时间:2019-02-07 22:27:44

标签: angularjs jasmine protractor

尝试使用getText()方法验证文本,但是量角器由于无法找到对象而使测试失败

尝试1:通过id,xpath和名称获取元素

尝试2: element(by.xpath(“ // * [@ id ='dropdownMenuLink']”))。getText()。then(function(text){console.log(text);     });

尝试3:通过给出预期结果获取文本 Expect(element(by.xpath(“ // [@ id ='dropdownMenuLink']”))。getText())。toBe(“ expectedresult”);         });

describe('Website FUSW001', function()
        {

    it('Login', function() 
        {
        browser.get('angularwebsite');   
                element(by.name('user')).sendKeys('myvalidusername');    
                element(by.name('pass')).sendKeys('mypassword');
        element(by.name('login')).click();
        browser.driver.manage().window().maximize().then(function()
        {
        element(by.xpath("//[@id='dropdownMenuLink']")).getText().then(function(text)
    {
    console.log(text); // log will display myvalidusername
    });

     });

   });

});
Error Message :

    16:08:53] I/launcher - Running 1 instances of WebDriver
    [16:08:53] I/hosted - Using the selenium server at http://localhost:4444/wd/hub
    Started
     [31mF [0m



Failures:

        1) Website FUSW001 Login
        Message:
     [31m    Failed: script timeout: result was not received in 11 seconds
    (Session info: chrome=72.0.3626.96)
    (Driver info: chromedriver=2.46.628402 (536cd7adbad73a3783fdc2cab92ab2ba7ec361e1),platform=Windows NT 10.0.17763 x86_64) [0m
    Stack:

        ScriptTimeoutError: script timeout: result was not received in 11 seconds
        (Session info: chrome=72.0.3626.96)
        (Driver info: chromedriver=2.46.628402 (536cd7adbad73a3783fdc2cab92ab2ba7ec361e1),platform=Windows NT 10.0.17763 x86_64)
        at Object.checkLegacyResponse



(C:\Protractor\ProtractorWebTest\protractor\node_modules\selenium-webdriver\lib\error.js:546:15)

    at parseHttpResponse (C:\Protractor\ProtractorWebTest\protractor\node_modules\selenium-webdriver\lib\http.js:509:13)
    at doSend.then.response (C:\Protractor\ProtractorWebTest\protractor\node_modules\selenium-webdriver\lib\http.js:441:30)


     at process._tickCallback (internal/process/next_tick.js:68:7)
        From: Task: Protractor.waitForAngular() - Locator: By(xpath, //*[@id='dropdownMenuLink'])
        at thenableWebDriverProxy.schedule (C:\Protractor\ProtractorWebTest\protractor\node_modules\selenium-webdriver\lib\webdriver.js:807:17)
            at ProtractorBrowser.executeAsyncScript_ (C:\Protractor\ProtractorWebTest\protractor\built\browser.js:425:28)
            at angularAppRoot.then (C:\Protractor\ProtractorWebTest\protractor\built\browser.js:456:33)
            at ManagedPromise.invokeCallback_ (C:\Protractor\ProtractorWebTest\protractor\node_modules\selenium-webdriver\lib\promise.js:1376:14)
            at TaskQueue.execute_ 

        (C:\Protractor\ProtractorWebTest\protractor\node_modules\selenium-webdriver\lib\promise.js:3084:14)
        at TaskQueue.executeNext_ 

    (C:\Protractor\ProtractorWebTest\protractor\node_modules\selenium-webdriver\lib\promise.js:3067:27)
        at asyncRun (C:\Protractor\ProtractorWebTest\protractor\node_modules\selenium-webdriver\lib\promise.js:2927:27)
        at C:\Protractor\ProtractorWebTest\protractor\node_modules\selenium-webdriver\lib\promise.js:668:7
        at process._tickCallback (internal/process/next_tick.js:68:7)Error
        at ElementArrayFinder.applyAction_ (C:\Protractor\ProtractorWebTest\protractor\built\element.js:459:27)
        at ElementArrayFinder.(anonymous function).args [as getText] (C:\Protractor\ProtractorWebTest\protractor\built\element.js:91:29)
        at ElementFinder.(anonymous function).args [as getText] (C:\Protractor\ProtractorWebTest\protractor\built\element.js:831:22)
        at C:\Protractor\ProtractorWebTest\spec1.js:12:57
        at ManagedPromise.invokeCallback_ (C:\Protractor\ProtractorWebTest\protractor\node_modules\selenium-webdriver\lib\promise.js:1376:14)
        at TaskQueue.execute_ (C:\Protractor\ProtractorWebTest\protractor\node_modules\selenium-webdriver\lib\promise.js:3084:14)
        at TaskQueue.executeNext_ (C:\Protractor\ProtractorWebTest\protractor\node_modules\selenium-webdriver\lib\promise.js:3067:27)
        at asyncRun (C:\Protractor\ProtractorWebTest\protractor\node_modules\selenium-webdriver\lib\promise.js:2927:27)
        at C:\Protractor\ProtractorWebTest\protractor\node_modules\selenium-webdriver\lib\promise.js:668:7
        at process._tickCallback (internal/process/next_tick.js:68:7)
        From: Task: Run it("Login") in control flow
        at UserContext.<anonymous> (C:\Protractor\ProtractorWebTest\protractor\node_modules\jasminewd2\index.js:94:19)
        From asynchronous test:
        Error
        at Suite.<anonymous> (C:\Protractor\ProtractorWebTest\spec1.js:4:4)
        at Object.<anonymous> (C:\Protractor\ProtractorWebTest\spec1.js:1:63)
        at Module._compile (internal/modules/cjs/loader.js:689:30)
        at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
        at Module.load (internal/modules/cjs/loader.js:599:32)
        at tryModuleLoad (internal/modules/cjs/loader.js:538:12)

        1 spec, 1 failure
        Finished in 21.934 seconds

        [16:09:17] I/launcher - 0 instance(s) of WebDriver still running
        [16:09:17] I/launcher - chrome #01 failed 1 test(s)
        [16:09:17] I/launcher - overall: 1 failed spec(s)
        [16:09:17] E/launcher - Process exited with error code 1

0 个答案:

没有答案