How do I find_element_by_xpath in Python?

413 views
Skip to first unread message

Stephen M. Olds

unread,
Feb 12, 2012, 10:37:02 PM2/12/12
to seleniu...@googlegroups.com

I am searching for the part of the webpage that goes:

<TR class='title'><TD colspan=3 bgcolor=#C0C0C0>Order number 6097279</TD></TR>

I want to pull out the number - which changes every time from the text (i.e.: 'Order number 6097279' gives me the string '6097279')

I have tried the following and get an 'unable to locate element' error:

find_element_by_xpath("//tr[@class='title']");

Why isn't this working?

What is the best xpath code to pull this out?

Alexander Kruglov

unread,
Feb 13, 2012, 3:07:03 AM2/13/12
to Selenium Users
Maybe you should try like this - find_element_by_xpath("//tr[@class=
\'title\']") ?

Try to locate this element using some extension like Firepath in
Firefox.

On 13 фев, 07:37, "Stephen M. Olds" <smo...@orcasoul.com> wrote:
> I am searching for the part of the webpage that goes:<TRclass='title'><TDcolspan=3bgcolor=#C0C0C0>Order number 6097279</TD></TR>

Stephen M. Olds

unread,
Feb 13, 2012, 7:31:29 AM2/13/12
to seleniu...@googlegroups.com, Alexander Kruglov
Nope, that didn't work either.

OK, I downloaded and installed firepath - and it found that the
'<TRclass='title'>' is actually '<TRclass='title even'>'...even though
the page source shows it as just 'title'...

Very interesting tool, thanks!

Hopefully that solve this problem - and the tool should help on other
similar problems...

Reply all
Reply to author
Forward
0 new messages