Sublocators using xpath locators not behaving the same as css locators
See original GitHub issueBug report
- Node Version:
8.15.1
- Protractor Version:
5.4.2
- Angular Version:
1.5
- Browser(s):
Chromium
- Operating System and Version
macOS Mojave 10.14.6
Example DOM:
<html>
<elementA>
</elementA>
<elementB>
<elementA>
</elementA>
</elementB>
</html>
Behavior observed:
// these ones return both instances of "elementA"
element(by.xpath('//elementB')).element(by.xpath('//elementA'));
element(by.xpath('//elementB')).all(by.xpath('//elementA'));
// these ones work as documented, only returning the "elementA" nested inside "elementB"
element(by.xpath('//elementB')).$('elementA');
element(by.xpath('//elementB')).$$('elementB');
Issue Analytics
- State:
- Created 4 years ago
- Comments:5
Top Results From Across the Web
Why does this xpath work but the css selection doesn't [locator ...
I'm working on switching from xpath to css for my selectors where possible. This worked in xpath: //ul[contains(@id,'district-switcher')].
Read more >XPath vs CSS Selector: The Difference and How to Choose
We'll discuss the syntax in greater depth shortly. Advantages of Using XPath. XPath allows you to navigate up the DOM when looking for...
Read more >CSS Selector vs XPath: Your Pocket Cheat Sheet - testRigor
Automation scripts can handle most locators using both XPath and CSS selectors. Best practices while writing locator expressions. Typically, CSS ...
Read more >Examples with xpath and Css (ID, Name, Text and Links)
It is very simple to locate elements if the HTML DOM has 'id' or 'name' and they are the safest locators to use....
Read more >Which locator do you use with Selenium: CSS or XPath?
Don't forget that not only performance is better with CSS locators, it's the compatibility too that matters. We are testing on a multi...
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
@costanza5813 can u try with .// foreg:
@praveendvd I don’t think CSS has a way to refer the current node like that