jeudi 23 février 2017

params value undefined in Protracor

I having random failures in Protractor, because of undefined value. In conf file I have the following:

homeData: {
            numericString: '123456789',
            balanceRandomNumbers: parseInt(Math.random()*100000)
        },

In the spec file I have the following:

    var randomNumbers = browser.params.homeData.balanceRandomNumbers;
    var numberKeys = element(by.id("shiftStartingBalanceModal")).element(by.css(".virtualKeyboardContainer")).element(by.name("default"));

    describe(...
        it(...
            // split numbers and store into variable
            splitedRandomNumbers = randomNumbers.toString().split("");

            // print out splited variable value in console
            console.log("\nBalance value: " + splitedRandomNumbers);

            // waiting for onscreen keyboard "1" key to be visible
            browser.wait(EC.visibilityOf(numberKeys.element(by.buttonText("1"))),10000);

            // selecting balance value
            for (var i = 0; i < 5; i++) {
                numberKeys.element(by.buttonText(splitedRandomNumbers[i])).click();
                browser.sleep(100);
            };
...

Now when I run this spec, I randomly get error stating that the splitedRandomNumbers is undefined. What I'm doing wrong?




Aucun commentaire:

Enregistrer un commentaire