What is the correct syntax for using a variable and following-sibling in Python Selenium? -


i'm using python , selenium webdriver.

i have following code works expected:

driver.find_element_by_xpath('//p[text()="text"]/../following-sibling::td/div/div/table/tbody/tr/td/a[@class ="class_name"]') 

i change above "text" variable, similar below:

driver.find_element_by_xpath('//p[text()="%s"] % variable_name/../following-sibling::td/div/div/table/tbody/tr/td/a[@class ="class_name"]') 

this doesn't work isn't valid xpath express. can correct coding please?

edit: also, if there way search text in follow-sibling useful. similar to:

 driver.find_element_by_xpath('//p[text()="%s"] % variable_name/../following-sibling:[div@text()= "text"]') 

when wrote '//p[text()="%s"] % variable_name/../following-sibling::td/div/div/table/tbody/tr/td/a[@class ="class_name"]', created string literally contains %s , % variable_name. % operator , variable(s) substituted go outside of string literal:

'//p[text()="%s"]/../following-sibling::td/div/div/table/tbody/tr/td/a[@class ="class_name"]' % variable_name 

Comments

Popular posts from this blog

PHP and MySQL WP -

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

go - golang pprof for c library code -