selenium driver.find_element 报错 invalid argument: invalid locator

selenium.common.exceptions.InvalidArgumentException: Message: invalid argument: invalid locator

报错信息:invalid argument: invalid locator
提示的是 定位器 locator 的 参数 argument 是无效的,
为什么无效,是我代码写错了,

driver.find_element('//*[@id="staffid').send_keys(‘handsome’)

定位器 locator 少了最重要的参数 By.XPATH
正确的代码如下:

driver.find_element(By.XPATH,'//*[@id="staffid"]').send_keys(“handsome”)

所以说,自己写的代码,自己就很难发现错误,要仔细。
February the 15th 2023 Wednesday

猜你喜欢

转载自blog.csdn.net/m0_47505062/article/details/129041331