我想通过xpath找到按钮元素,当我在chrome中键入它时发现该按钮元素,但该脚本给了我无属性id错误。我尝试切换到iframe和框架,我用webdriver.wait等待按钮元素显示,并没有这些工作。我还想循环点击第一个按钮,如果它显示“Follow”,然后移动到下一个按钮,如果它显示“Follow”。脚本在Chrome上运行,我试图在instagram上执行此操作Html hereXpath存在于chrome中,但不存在于我的脚本中。没有这样的元素:无法找到元素:
popup = browser.find_element_by_xpath('//button[@class="_qv64e _gexxb _4tgw8 _njrw0"]')
ActionChains(browser)\
.move_to_element(popup).click()\
.perform()
File "/Users/trevaroneill/PycharmProjects/Insta/instafollow.py", line 91, in <module> popup = browser.find_element_by_xpath('//button[@class="_qv64e _gexxb _4tgw8 _njrw0"]')
selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"xpath","selector":"//button[@class="_qv64e _gexxb _4tgw8 _njrw0"]"}
请分享网址 – iamsankalp89
你看到的错误是正常的,因为名单没有名为id – iamsankalp89
你可以给一些HTML属性码?脚本也运行在chrome上呢? – yong