xpath从浏览器里console可以定位到元素,在pycharm IDE里搪行代码时,提示unknown error: a.tagName.toUpperCase is not a function

xpath从浏览器里console可以定位到元素,在pycharm IDE里搪行代码时,提示unknown error: a.tagName.toUpperCase is not a function

self.d.find_element_by_xpath("//i[@class='anticon anticon-plus']/parent::button").click()
sleep(1)
print(self.d.find_elements_by_xpath('//input[@id="tagName"]'))
self.d.find_elements_by_xpath('//input[@id="tagName"]')[1].send_keys("test")

img

感谢支持,试了下还是一样的报错,这个页面加载很快的。

看起来不像是定位的问题,定位最多报未找到元素

这个改了试下

self.d.find_elements_by_xpath('//input[@id="tagName"][1]').send_keys("test")

selenium 很少用xpath定位,因为页面加载可能会有延迟,程序如果没有阻塞就到了xpath那块,页面结构可能会跟你xpath想获取的不同。
一般selenium 用by id 啊 by classname 啊 比较稳定
可以加下判断
WebDriverWait这个函数