According to the “Location elements” section of the manual, By.XPATH
seems to be a string, and the correct usage would be this:
self.driver.find_element(By.XPATH, '//*[@id="datepicker"]')
That also makes sense from the error message, since you are calling By.XPATH
. And the current source also confirms this.
Unfortunately, the Selenium API is not really consistent across different platforms. The syntax you are using, calling By.xpath()
is used by Java, and in C#, you also have to call By.Xpath()
. So it’s just naturally that you get confused when you see other examples where it’s being called and in Python, you suddenly need to pass it. So you shouldn’t blindly trust examples you find on the internet (like this one) but always check for which language they are. And check the documentation and/or the source in doubt.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…