Using webDriverIO helper properly
See original GitHub issueWhat are you trying to achieve? To use webdriverio helper
What do you get instead? An error “Cannot read property ‘promise’ of undefined”.
webdriverIO test --
try to locate element
• I am on page "http://codecept.io/" (13.999 sec)
• I try locate (0.001 sec)
✖ FAILED in 16342ms
-- FAILURES:
1) webdriverIO test: try to locate element:
Cannot read property 'promise' of undefined
Scenario Steps:
- I.tryLocate() at Test.<anonymous> (livetv_test.js:5:7)
- I.amOnPage("http://codecept.io/") at Test.<anonymous> (livetv_test.js:4:7)
Run with --verbose flag to see NodeJS stacktrace
FAIL | 0 passed, 1 failed // 16s
Provide test source code if related some_test.js:
Feature('webdriverIO test');
Scenario("try to locate element", function * (I) {
I.amOnPage("http://codecept.io/");
I.tryLocate();
});
WebDriverIOHelper.js:
'use strict';
class WebDriverIOHelper extends Helper {
tryLocate() {
const element = this.helpers['WebDriverIO'].browser.element;
return element('h1');
}
}
module.exports = WebDriverIOHelper;
Details
- CodeceptJS version: v1.0.0
- NodeJS Version: v8.4.0
- Operating System: macOs Sierra v 10.12.6
- SeleniumWebDriver version: ‘3.4.0’
- Configuration file:
{
"output": "./output",
"helpers": {
"WebDriverIO": {
"url": "http://localhost:3000",
"windowSize": "maximize",
"browser": "chrome",
"restart": true,
"smartWait": 15000
},
"WebDriverIOHelper": {
"require": "./WebDriverIOHelper.js"
}
},
"include": {
"I": "./custom_steps.js"
},
"mocha": {
"reporterOptions": {
"mochaFile": "./output/result.xml"
}
},
"bootstrap": "./bootstrap.js",
"teardown": null,
"hooks": [],
"tests": "./*_test.js",
"timeout": 5000,
"multiple": {
"default": {
"grep": "signin",
"browsers": [
"chrome",
"safari"
]
}
},
"name": "tests"
}
Issue Analytics
- State:
- Created 6 years ago
- Comments:5 (1 by maintainers)
Top Results From Across the Web
Using webDriverIO helper properly · Issue #738 - GitHub
To use webdriverio helper What do you get instead? An error "Cannot read property 'promise' of undefined". webdriverIO test -- try to locate ......
Read more >Getting Started - WebdriverIO
Note: all WebdriverIO commands are asynchronous and need to be properly handled using async/await . Record tests. WebdriverIO provides tools to help you...
Read more >Optimize Test Framework - WebdriverIO Tutorial | #12 - YouTube
webdriverio #javascript #frameworkIn this video, we will look at some effective ways to optimize our tests:- we will create utility helper ...
Read more >Mobile Automation Testing using WebdriverIO - YouTube
testautomation #appium # webdriverio Get started with Mobile Automation Testing using WebdriverIO & Appium. In this video, we will cover ...
Read more >Find web elements using the best WEBDRIVERIO ... - YouTube
Webdriverio selectors: CSS, XPath, Link, ByText, By Index, and MORE.# webdriverio #typescript #javascript⏰Timestamps: 00:00 - Selector ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
You’re welcome. I just noticed that you have a small typo in the test scenario
aync
.Also the advantage of having the helper function return a promise instead of being an async function is that you can call it from the interactive shell and it behaves as expected.
Don’t forget to close the issue if everything works.
Awesome, thank you so much for your help! I adjusted the function to return the text in that element. I’ve updated the github repo with the changes.
and call it by using: