Can't find element by xpath with title as a variable

Sahil Dhiman

selenium can't locate the element, Time Out Exception. name="karam"

This works.

WebDriverWait(browser,10).until(
    EC.presence_of_element_located((By.XPATH,'//*[@title="karam"]'))
)

This won't work.

WebDriverWait(browser,10).until(
    EC.presence_of_element_located((By.XPATH,'//*[@title=str(name)]'))
)

nor this.

WebDriverWait(browser,10).until(
    EC.presence_of_element_located((By.XPATH,'//*[@title="{}".format(name)))
)
Rakesh

Try:

name="karam"
WebDriverWait(browser,10).until(EC.presence_of_element_located((By.XPATH,'//*[@title="{0}"]'.format(name)))

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related