Python Forum

Full Version: How to handle tables splitted across multiple web pages
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi
I am trying to print value from a table using the following code

row = browser.find_element_by_xpath("//table[@cols='8']/tbody/tr[last()]/td[2]/div").text
print(row)

But the table is splitted across multiple web pages and pagination is being used to access various parts of table. So the above code is returning the text in last row of table on first web page, not the actual last row of table.. How to access actual last row of table
Xpath is different for every part of every page, so it varies completely from page to page.
You need specific Xpath for page in question.
Please let us know URL, and what part of page you are targeting.

Also, learn how to use element inspector which is available on Firefox and chrome.
basically hover over area of page that you want Xpath for, right click, select inspect element,
move cursor until exact target is highlighted, Then right click on highlighted html code in inspector, select copy ==> Xpath
Thanks for your reply. It is working now after I used sleep() function.. The structure of table is same on all pages. Except that it needs to wait for a few seconds before the last page is loaded.