According to the webdriver documentation, using the $
and $$ functions in WebdriverIO can provide shortcuts for moving deeper into the DOM tree without relying on complex xPath selectors.
Currently, I am working on writing a cucumber test for my Reactjs application with Flowjs, utilizing web driver and chai. The UI design includes various buttons which need to be tested for existence along with their text/values. You can view the design here.
This is the approach I have taken:
const links = $$('.button').filter(function(link) {
return link.isVisible();
});
const button1_value = links[0].getText();
const button2_value = links[1].getText();
expect(button1_value).to.equal('button1');
expect(button2_value).to.equal('button2');
However, I encountered an error when using $$
. You can see the error message here.
Is there an alternative method to retrieve a list of buttons for testing purposes? Should I import $
and $$
for use in JavaScript files?