Hiro 714
asked on
Python selenium xpath question
How do I get a whole row data with xpath?
I'm getting only header
I'm getting only header
Xpath
Title
/html/body/div[2]/div[3]/div[2]/div/form/table/thead/tr/th[2]/a
Data
/html/body/div[2]/div[3]/div[2]/div/form/table/tbody/tr[1]/td[2]/a
CodeTicket_Titles = driver.find_element_by_xpath('//tbody/tr/td[2]/a')
for Ticket_Title in Ticket_Titles:
print(Ticket_Title.text)
Error---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-182-6e3e609a1ea1> in <module>
2 Ticket_Titles = driver.find_element_by_xpath('//tbody/tr/td[2]/a')
3
----> 4 for Ticket_Title in Ticket_Titles:
5 print(Ticket_Title.text)
TypeError: 'FirefoxWebElement' object is not iterable
another sampleTicket_Titles = driver.find_element_by_xpath('//tbody/tr/td[2]/a')
Ticket_Titles.text
Output:'Export max results to Excel (may timeout)'
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
also get this error
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
aaaa
ASKER
Thank you! that was it
Glad to hear that.You can refer this article to use more variety way to locating the elements.
https://selenium-python.readthedocs.io/locating-elements.html
https://selenium-python.readthedocs.io/locating-elements.html
ASKER
How could I remove this data?
ASKER
Open in new window
Open in new window
Open in new window