量角器数据提供者。测试运行时不断跳过第一数据

时间:2018-11-05 10:15:01

标签: javascript testing jasmine protractor automated-tests

数据的第一位不断被跳过。我不知道为什么

I explain in more detail in this video

问题:

1我做错了什么?

  1. 我该如何解决?

IT案例规范名称:PageObjectLocator2.js

describe('protractor page Object  training',function(){
    var obj= require("./PageObjectDemo.js");
    var using= require ('jasmine-data-provider');
    var d= require("./data1.js");


    beforeEach(function() {
        obj.geturl();//the url on your test page is a method

      });

    //data = this the actual data items 
    //description =  This are names you given each set of data

    using(d.DataDriver, function (data, description){
    //test scenarios can only be carried out in this area. Place your IT block here!!!

        it('Perform Simple Calculation ',function(){
            // write your code here!!!

                obj.firstnumber.sendKeys(data.firstinput);//page of object properties
                obj.secondnumber.sendKeys(data.secondinput);//page object properties

                obj.gobutton.click();

                //Jasmine Attribute Syntax toBe. Jasmine takes care of the promise 'resolve'internally

                expect(obj.result.getText()).toBe(data.result);     
                //this confirm printout in console.

           obj.result.getText().then(function(text){
                console.log(text) 
             }) //end of console log message           


            })//end of it block


    });//end of data testing block 



    afterEach(function () {
       console.log("If you can see this, test is completed. Well Done!!");
    });

2。数据规范名称:Data1.js

这是数据提供者部分。看起来还可以,我没有任何错误消息。因此,我遇到这个问题毫无意义。

  module.exports=
    {

    DataDriver:
    {

        FirstData: 
        {
            firstinput:"3",
            secondinput:"5",
            result: "8"
        },

        SecondData:
        {
            firstinput:"3",
            secondinput:"6",
            result: "9"
        },

        ThirdData:
        {
            firstinput:"5",
            secondinput:"5",
            result: "10"
        }

           }
                }

3。从终端打印出来

最后,在本地项目级别运行npm run protractor后,来自控制台的消息。如您所见,第一个数据提供程序项由于某种原因被跳过了。

> LocatorTraining@ protractor /Users/jacquelinegeorge/Documents/JSworkspace/LocatorTraining
> protractor configurations.js


[21:04:46] I/launcher - Running 1 instances of WebDriver
[21:04:46] I/hosted - Using the selenium server at http://localhost:4444/wd/hub
Started
If you can see this, test is completed. Well Done!!
F9
If you can see this, test is completed. Well Done!!
.10
If you can see this, test is completed. Well Done!!
.


Failures:
1) protractor page Object  training Perform Simple Calculation 
  Message:
    WebDriverError: unknown error: failed to change window state to maximized, current state is normal
      (Session info: chrome=70.0.3538.77)
      (Driver info: chromedriver=2.43.600229 (3fae4d0cda5334b4f533bede5a4787f7b832d052),platform=Mac OS X 10.13.6 x86_64)
  Stack:
    WebDriverError: unknown error: failed to change window state to maximized, current state is normal
      (Session info: chrome=70.0.3538.77)
      (Driver info: chromedriver=2.43.600229 (3fae4d0cda5334b4f533bede5a4787f7b832d052),platform=Mac OS X 10.13.6 x86_64)
        at Object.checkLegacyResponse (/Users/jacquelinegeorge/Documents/JSworkspace/LocatorTraining/node_modules/selenium-webdriver/lib/error.js:546:15)
        at parseHttpResponse (/Users/jacquelinegeorge/Documents/JSworkspace/LocatorTraining/node_modules/selenium-webdriver/lib/http.js:509:13)
        at doSend.then.response (/Users/jacquelinegeorge/Documents/JSworkspace/LocatorTraining/node_modules/selenium-webdriver/lib/http.js:441:30)
        at process._tickCallback (internal/process/next_tick.js:103:7)
    From: Task: WebDriver.manage().window().maximize()
        at thenableWebDriverProxy.schedule (/Users/jacquelinegeorge/Documents/JSworkspace/LocatorTraining/node_modules/selenium-webdriver/lib/webdriver.js:807:17)
        at Window.maximize (/Users/jacquelinegeorge/Documents/JSworkspace/LocatorTraining/node_modules/selenium-webdriver/lib/webdriver.js:1686:25)
        at onPrepare (/Users/jacquelinegeorge/Documents/JSworkspace/LocatorTraining/configurations.js:10:37)
        at q_1.Promise (/Users/jacquelinegeorge/Documents/JSworkspace/LocatorTraining/node_modules/protractor/built/util.js:46:49)
        at Function.promise (/Users/jacquelinegeorge/Documents/JSworkspace/LocatorTraining/node_modules/q/q.js:682:9)
        at Object.runFilenameOrFn_ (/Users/jacquelinegeorge/Documents/JSworkspace/LocatorTraining/node_modules/protractor/built/util.js:38:16)
        at plugins_.onPrepare.then (/Users/jacquelinegeorge/Documents/JSworkspace/LocatorTraining/node_modules/protractor/built/runner.js:98:27)
        at _fulfilled (/Users/jacquelinegeorge/Documents/JSworkspace/LocatorTraining/node_modules/q/q.js:834:54)
        at self.promiseDispatch.done (/Users/jacquelinegeorge/Documents/JSworkspace/LocatorTraining/node_modules/q/q.js:863:30)
        at Promise.promise.promiseDispatch (/Users/jacquelinegeorge/Documents/JSworkspace/LocatorTraining/node_modules/q/q.js:796:13)
  Message:
    Failed: Error while waiting for Protractor to sync with the page: "both angularJS testability and angular testability are undefined.  This could be either because this is a non-angular page or because your test involves client-side navigation, which can interfere with Protractor's bootstrapping.  See http://git.io/v4gXM for details"
  Stack:
    Error: Error while waiting for Protractor to sync with the page: "both angularJS testability and angular testability are undefined.  This could be either because this is a non-angular page or because your test involves client-side navigation, which can interfere with Protractor's bootstrapping.  See http://git.io/v4gXM for details"
        at runWaitForAngularScript.then (/Users/jacquelinegeorge/Documents/JSworkspace/LocatorTraining/node_modules/protractor/built/browser.js:463:23)
        at ManagedPromise.invokeCallback_ (/Users/jacquelinegeorge/Documents/JSworkspace/LocatorTraining/node_modules/selenium-webdriver/lib/promise.js:1376:14)
        at TaskQueue.execute_ (/Users/jacquelinegeorge/Documents/JSworkspace/LocatorTraining/node_modules/selenium-webdriver/lib/promise.js:3084:14)
        at TaskQueue.executeNext_ (/Users/jacquelinegeorge/Documents/JSworkspace/LocatorTraining/node_modules/selenium-webdriver/lib/promise.js:3067:27)
        at asyncRun (/Users/jacquelinegeorge/Documents/JSworkspace/LocatorTraining/node_modules/selenium-webdriver/lib/promise.js:2927:27)
        at /Users/jacquelinegeorge/Documents/JSworkspace/LocatorTraining/node_modules/selenium-webdriver/lib/promise.js:668:7
        at process._tickCallback (internal/process/next_tick.js:103:7)Error
        at ElementArrayFinder.applyAction_ (/Users/jacquelinegeorge/Documents/JSworkspace/LocatorTraining/node_modules/protractor/built/element.js:459:27)
        at ElementArrayFinder.(anonymous function) [as sendKeys] (/Users/jacquelinegeorge/Documents/JSworkspace/LocatorTraining/node_modules/protractor/built/element.js:91:29)
        at ElementFinder.(anonymous function) [as sendKeys] (/Users/jacquelinegeorge/Documents/JSworkspace/LocatorTraining/node_modules/protractor/built/element.js:831:22)
        at UserContext.<anonymous> (/Users/jacquelinegeorge/Documents/JSworkspace/LocatorTraining/PageObjectLocator2.js:21:21)
        at /Users/jacquelinegeorge/Documents/JSworkspace/LocatorTraining/node_modules/jasminewd2/index.js:112:25
        at new ManagedPromise (/Users/jacquelinegeorge/Documents/JSworkspace/LocatorTraining/node_modules/selenium-webdriver/lib/promise.js:1077:7)
        at ControlFlow.promise (/Users/jacquelinegeorge/Documents/JSworkspace/LocatorTraining/node_modules/selenium-webdriver/lib/promise.js:2505:12)
        at schedulerExecute (/Users/jacquelinegeorge/Documents/JSworkspace/LocatorTraining/node_modules/jasminewd2/index.js:95:18)
        at TaskQueue.execute_ (/Users/jacquelinegeorge/Documents/JSworkspace/LocatorTraining/node_modules/selenium-webdriver/lib/promise.js:3084:14)
        at TaskQueue.executeNext_ (/Users/jacquelinegeorge/Documents/JSworkspace/LocatorTraining/node_modules/selenium-webdriver/lib/promise.js:3067:27)
    From: Task: Run it("Perform Simple Calculation ") in control flow
        at UserContext.<anonymous> (/Users/jacquelinegeorge/Documents/JSworkspace/LocatorTraining/node_modules/jasminewd2/index.js:94:19)
        at emitOne (events.js:96:13)
        at process.emit (events.js:188:7)
    From asynchronous test: 
    Error
        at /Users/jacquelinegeorge/Documents/JSworkspace/LocatorTraining/PageObjectLocator2.js:18:3
        at /Users/jacquelinegeorge/Documents/JSworkspace/LocatorTraining/node_modules/jasmine-data-provider/src/index.js:37:22
        at Array.forEach (native)
        at /Users/jacquelinegeorge/Documents/JSworkspace/LocatorTraining/node_modules/jasmine-data-provider/src/index.js:30:24
        at Suite.<anonymous> (/Users/jacquelinegeorge/Documents/JSworkspace/LocatorTraining/PageObjectLocator2.js:15:2)
        at Object.<anonymous> (/Users/jacquelinegeorge/Documents/JSworkspace/LocatorTraining/PageObjectLocator2.js:1:63)


3 specs, 1 failure
Finished in 6.394 seconds


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


npm ERR! Darwin 17.7.0
npm ERR! argv "/Users/jacquelinegeorge/.nvm/versions/node/v7.2.0/bin/node" "/Users/jacquelinegeorge/.nvm/versions/node/v7.2.0/bin/npm" "run" "protractor"
npm ERR! node v7.2.0
npm ERR! npm  v3.10.9
npm ERR! code ELIFECYCLE
npm ERR! LocatorTraining@ protractor: `protractor configurations.js`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the LocatorTraining@ protractor script 'protractor configurations.js'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the LocatorTraining package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     protractor configurations.js
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs LocatorTraining
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls LocatorTraining
npm ERR! There is likely additional logging output above.


npm ERR! Please include the following file with any support request:
npm ERR!     /Users/jacquelinegeorge/Documents/JSworkspace/LocatorTraining/npm-debug.log
Jacquelines-MacBook-Air:Locator

1 个答案:

答案 0 :(得分:0)

好吧

我找到了此问题的根本原因。它似乎与谷歌浏览器有关的问题,而不是我的实际测试。如果我在FF上运行此测试,效果很好。就我而言,有关测试的问题已解决-因为我的测试没有问题。

我将打开一个问题,涉及我的Chrome的实际问题以及为什么它无法正常运行测试。