question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Getting unexpected result when using element.all(by.xpath()) to read table data

See original GitHub issue

My application contains two mat-tables on it. I would like to read the table data from my second table

await this.secondTableElement.all(by.xpath(//tr[${rowIndex}]/td[${columnIndex}]));

but this statement actually provides me the data from the first table and not from the secondtableElement. I believe when you execute all() method under a parent element, protractor is supposed to search under this element and not from the very beginning of the HTML document.

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:6

github_iconTop GitHub Comments

1reaction
Fuun347commented, Jun 5, 2020

Xpath is not recommended at all for any use by the protractor team. This is a section from the protractor style guide image which you can locate here https://www.protractortest.org/#/style-guide. Generally I’ve had issues with xpath before so I absolutely never use it. I’m not sure if this here is a bug or just xpath’s broken behavior, but if you can go by without using it, then do go that route.

1reaction
Fuun347commented, Jun 5, 2020

Then there is no reason why this should be selecting the wrong table. Have you tried using by.css rather than by.xpath?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Element should have been "select" but was "a" while trying to ...
UnexpectedTagNameException : Element should have been "select" but was "a" while trying to get the texts of dropdown menu using Selenium and Java....
Read more >
XML Path Language (XPath) Version 1.0 - W3C
Abstract. XPath is a language for addressing parts of an XML document, designed to be used by both XSLT and XPointer.
Read more >
Top 10 Selenium Exceptions and How To Handle These ...
Handling Exceptions in Selenium WebDriver - In this tutorial we will learn about types of exceptions and how to handle top 10 most...
Read more >
Chapter 4. XPath Functions and Numeric Operators - O'Reilly
The XPath 1.0 Recommendation specifies a number of functions and numeric operations that can be used to refine the results returned by an...
Read more >
Web scraping using Python: requests and lxml - GitHub Pages
Traversing HTML and extracting data from it with lxml ... We can use XPath or CSS selectors to select what elements on a...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found