在使用黄瓜为webdriverio运行程序时获取以下错误
TypeError: LoginPage.userNameTextBox.setValue不是World的一个函数。(C:\Users\Desktop\Webdriver_cucumber\features\step-definitions\steps.js:21:31) at World.executeAsync (C:\Users\Desktop\Webdriver_cucumber\node_modules@wdio\utils\build\shim.js:136:25) at World.testFrameworkFnWrapper (C:\Users\Desktop\Webdriver_cucumber\node_modules@wdio\utils\build\test-framework\testFnWrapper.js:45:32)
login.feature文件
Feature: To test the login functionality in "The Internet Herokuapp"
Background:
Given the user is on login page
Scenario: The one where user logs in using valid credentials
When the user enters username as "tomsmith" and password as "SuperSecretPassword!"
And clicks on login button
Then the user must navigate to secure area page displaying a message "You logged into a secure area!"
Scenario Outline: The one where user logs in using invalid credentials
When the user enters username as "<username>" and password as "<password>"
And clicks on login button
Then the user must remain on login page displaying a message "<errorMessage>"
Examples:
| username | password | errorMessage |
| james | SuperSecretPassword! | Invalid username! |
| tomsmith | SuperPassword! | Invalid password! |steps.js
When('the user enters username as {string} and password as {string}', function (username,
password) {
LoginPage.userNameTextBox.setValue(username);
LoginPage.passwordTextBox.setValue(password);
});shim.js
async function executeAsync(fn, retries, args = []) {
this.wdioRetries = retries.attempts;
try {
return await fn.apply(this, args);
}
catch (e) {
if (retries.limit > retries.attempts) {
retries.attempts++;
return await executeAsync.call(this, fn, retries, args);
}
throw e;
}
}有人能帮忙吗?
发布于 2021-07-29 16:47:06
不确定你是否已经找到了解决办法,因为我看到这个问题已经有7天了。你有没有试着把wait放在LoginPage.userNameTextBox.setValue(username);之前。如果不查看页面定义或元素定义,就很难回答任何问题。但是在大多数情况下,发生这种情况是因为页面仍然在加载,但是代码已经被执行,并导致对元素调用一个函数,而该函数还不可用。也许尝试放置一个wait只是为了调试。
https://stackoverflow.com/questions/68479474
复制相似问题