Some commands are not chainable with pageObjects.
See original GitHub issuesome functions like ‘getHTML’, ‘selectByIndex’ are not working with PageObject. [v4 with wdio]
File: pageobjects/registration.page.js
...
var registrationPage = Object.create(page, {
textBox_email: { get: function() { return browser.element('#email'); } },
dropDown_sex : { get: function() { return browser.element('select[name=sex]'); } }
...
file: tests/example.js
var RegistrationPage = require ('../pageobjects/client/registration.page');
...
RegistrationPage.textBox_email.setValue(suiteData.email); // works
browser.selectByIndex('select[name=sex]',1); // works
RegistrationPage.dropDown_sex.selectByIndex(1); // error: number or type of arguments don't agree with selectByIndex commandcode
RegistrationPage.dropDown_sex.selectByIndex
errors out with message
“number or type of arguments don’t agree with selectByIndex commandcode”
Issue Analytics
- State:
- Created 8 years ago
- Comments:7 (4 by maintainers)
Top Results From Across the Web
chaining commands breaks page api · Issue #884
Here's a sample page object that chains commands: const myCommands = { someCommand: function() { return this.navigate('/some-page') .
Read more >Cypress JS using multiple page objects in one method
How to do it with Custom Commands instead of pageObject. Chaining is a natural code pattern for Cypress commands, so using Custom Commands....
Read more >Stop using Page Objects and Start using App Actions
They use selectors to find elements, which is NOT checked by any linter ... Returns chain so you can attach more Cypress commands...
Read more >What is Page Object Pattern in Cypress? How to Implement ...
To achieve this, create a new folder with the name 'Page Objects' under cypress/support directory and then under that, create files which will ......
Read more >Abstract away! Page Objects vs Custom Commands in ...
So, if some structural change happens on the web page, it will just impact the page object and will not have any impact...
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
I have to fix that for couple of commands which do parameter checks
In your page object I would recommend to always use the
elements
commands to query elements. This way you don’t get these errors andgetText
returns[]
which is assertablethis might be a little hacky, but you could do this for your page object…
This will try the command, and if it finds the element return true, if it doesn’t find the element and returns any error, it’ll return false.