selenium driver.find_element 报错 invalid argument: invalid locator

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

The error message: invalid argument: invalid locator
indicates that the parameter argument of the locator is invalid.
Why is it invalid? My code is wrong.

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

The locator is missing the most important parameter. The By.XPATH
correct code is as follows:

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

Therefore, it is difficult to find errors in the code you write yourself, so be careful.
February the 15th 2023 Wednesday

Guess you like

Origin blog.csdn.net/m0_47505062/article/details/129041331