Using element selectors in callback function fail
See original GitHub issueThis is what I have to make it work but if I try to use the @userName instead of #email css selector it will fail. Note im just using the callback function on the login page as an example.
login: function(userName, password) {
if (typeof username || password == "undefined")
{
userName = 'nouser@blah.com';
password = '1234lkjlkj'
}
this.getText('h2', function(result){
if(result.value == 'Sign in')
{
this.waitForElementVisible( '#email', 3000, 'Login Page Loaded')
.setValue( '#email', userName)
.setValue( '#password', password)
.waitForElementVisible('input[type=submit]', 3000, 'Submit Button Was Visible')
.click('input[type=submit]');
return this; // Return page object for chaining
}
} )
}
};
module.exports = {
url: 'http://whateveraddress.com',
commands: [loginCommands],
elements: {
userName: '#email',
password: '#password',
submitButton: 'input[type=submit]'
}
};```
Issue Analytics
- State:
- Created 7 years ago
- Comments:7 (4 by maintainers)
Top Results From Across the Web
Trying to bind a callback by passing in the function throws an ...
I just want to fire an event when an input changes value using jQuery 1.7.2 and Backbone.js.
Read more >Changed error handling: Test always fails when click returns ...
We have a custom command that attempts to click on a element, but sometimes the element is not clickable. In previous versions of...
Read more >Cypress should callback - Gleb Bahmutov
Cypress should callback. Use any assertion inside "should(cb)" function to have Cypress auto-retry its command with your assertion function.
Read more >Select Page Elements | Basic Guides - TestCafe
TestCafe outputs information about failed selectors to test run reports. When you try to use a selector that does not match any DOM...
Read more >click | API Reference - Nightwatch.js
If the element is not found, an error is thrown which will cause the test to fail. You can suppress element not found...
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 Free
Top 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

You can use
this, you just have to do so with the understanding that it won’t be your page object. You can, however, force it to be your page object by usingbind()Nvm I figured it out. Was having 0,0 as part of moveToElement. having it as undefined fixed the problem