I'm reading a list of customer names and using each to find an element.
Before reading the list, I make can confirm this works when I hard-code the name,
datarow = driver.find_element_by_xpath("//span[contains(text(),'ACME Anvil Company')]")
But when I read in the customer list and use it like this, I get a NoSuchElement exception. I know I'm getting the name into the customer variable because the print statement confirms it.
for customer in customerlist:
print("START OF DATA FOR CUSTOMER: " +customer)
datarow = driver.find_element_by_xpath("//span[contains(text(),'"+customer+"')]")
Do I have something wrong with the '" +customer+ "' part? I've tried it a bunch of different ways.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…