6

so I have a variable named folder which contains a string that I randomly generate. I want to use xpath to find this folder by name, and I am not sure how to put this into action

driver.find_element_by_xpath('//div[text()="variable"]')

where variable contains the randomized text. With sql it would be like this (select * from table where value =(?)), [variable] ...or something similar

asked Jun 20, 2013 at 20:18

1 Answer 1

11

Try this:

driver.find_element_by_xpath('//div[text()="%s"]' % variable)
answered Jun 20, 2013 at 20:22
Sign up to request clarification or add additional context in comments.

1 Comment

Sure, it's python, simple is better than complex :)

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.