由于未定义的值,我在Protractor中出现随机故障。在conf文件中,我有以下内容:
homeData: {
numericString: '123456789',
balanceRandomNumbers: parseInt(Math.random()*100000)
},
在spec文件中,我有以下内容:
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);
};
...
现在,当我运行此规范时,我会随机收到错误消息,指出 splitedRandomNumbers 未定义。我做错了什么?