Reputation: 827
I have a page in a Lightening SalesForce application that I need to click. I have tried copying it's xpath, but webdriver IO cannot find this element nor interact with it.
Here is it's HTML:
<span class=" listViewPickerOption" data-aura-rendered-by="1124:0">All Accounts</span>
I have tried this in my webdriverIO code:
.click('//*[@id="800:0_listviewpicker_0"]/span[3]')
(//*[@id="800:0_listviewpicker_0"]/span[3]
is the xpath of the element.
when I run the test, it does not click on this element.
What is the correct way to click on this element?
Upvotes: 0
Views: 1390
Reputation: 827
Solution
this is what ended up working 100% of the time:
.click('//span[text()="All Accounts"]')
It clicks on this element every time without fail.
Upvotes: 0
Reputation: 400
Sometimes, HTML elements are nested under a <frame>
or an <iframe>
element.
The Webdriver does not automatically read inside these frames, so you'll have to switch to the frame for the webdriver to be able to read the internal HTML.
driver.switchTo().frame("whatever the frame name is");
Upvotes: 1
Reputation: 53
What I would do is something like this: //*[@class="listViewPickerOption"]
If I'm understanding the question correctly, that should do it. You can test out xpath in the developer tools of chrome when you do a search on the DOM.
Upvotes: 1