MoveTargetOutOfBoundsException:使用Python时出错

我正在尝试爬网一个具有菜单的网站,该菜单会在胡佛上打开一个子菜单,因此使用actionChains我可以进行悬停和单击,但是在某些子菜单中可以使用它

这是我得到的错误:

selenium.common.exceptions.MovetargetOutOfBoundsException: Message: (990,-89638) is out of bounds of viewport width (2560) and height (1315)

我使用的代码是这样:

for v in second_menu: #second menu is a list of strings with HTML class names
        initial_menu_item = browser.find_element_by_link_text(first_menu) 
        actionChains(browser).move_to_element(initial_menu_item).perform()
        time.sleep(3)
        secondary_menu_item = browser.find_element_by_class_name(v)
        actionChains(browser).move_to_element(secondary_menu_item).click().perform()

我了解到,根据错误,元素不在视口中,但事实是我得到的高度负值很大,我觉得很奇怪,实际上该元素确实在视口中。

lhbbb123 回答:MoveTargetOutOfBoundsException:使用Python时出错

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/3139435.html

大家都在问