how can i make a string work in quotes?

First of all you are not forrmating the string,

color = "White"
driver.find_element_by_xpath(f'//img[@alt = "{color}"]').click()

Use the above code for python3.x and up For Python versions 2.x, use:

color = "White"
driver.find_element_by_xpath('//img[@alt = "{}"]'.format(color)).click()

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top