I'm trying to use selenium webdriver to locate an element in html
size_element = driver.find_element(By.XPATH,"//span[text()= 'XL']")
The above works.
However, if I tried to represent "XL" with a string variable like below, it won't work.
size = "XL"
size_element = driver.find_element(By.XPATH,"//span[text()= f'{size}']")
similarly, the below don't work either:
size_element = driver.find_element(By.XPATH,"//span[text()= {}]".format(size)
size_element = driver.find_element(By.XPATH,"//span[text()= %s]"%size)
fis in the wrong place. It needs to be at the beginning of the outer string:f"//span..."