Reputation: 97
I'm having trouble in finding the text value inside the table, here's the sample screenshot of the table.
When i try to get the firepath, it shows a dynamic id:
.//*[@id='UID18-33316107000078976-1444640760832Display']/tbody/tr[1]/td[6]
I need to get the exact Value inside the table example "3004". I tried using this xpath contains but still no luck.
driver.findElement(By.xpath(//td[contains(.,'3004')]));
is there a way to extract the value inside this tables? Heres the element of tables.
Note: Tried using FirePath for the highlighted element output is:
.//*[@id='tdDataDiv']
It's the same id for all selected rows. It doesn't seem to work also.
UPDATE: @alecxe
This is the error shown when i try using the .getText() on the xpath. So the problem is im having a null pointer when im getting the value of the element. the xpath you can be found, but i cannot get the text from the xpath.
Thanks for all those who will look into this. Please do notify me if more info needed thanks!
Upvotes: 1
Views: 4519
Reputation: 473833
Assuming you know the EMP_COMPANY
label beforehand:
driver.findElement(By.xpath("//td[contains(div, 'EMP_COMPANY')]/following-sibling::td/div[@id = 'tdDataDiv']")).getText();
Upvotes: 1