51Testing软件测试论坛

 找回密码
 (注-册)加入51Testing

QQ登录

只需一步,快速开始

微信登录,快人一步

查看: 2478|回复: 2
打印 上一主题 下一主题

Python+Selenium鼠标悬停报错,求大神指点一下

[复制链接]

该用户从未签到

跳转到指定楼层
1#
发表于 2018-9-15 23:51:01 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
代码如下:
from selenium import webdriver
from selenium.webdriver.common.action_chains import ActionChains
driver=webdriver.Ie()
driver.implicitly_wait(10)
driver.get("http://www.baidu.com")
link=driver.find_element_by_link_text("设置")
#鼠标悬停在百度“设置”上
ActionChains(driver).move_to_element(link).perform()
driver.find_element_by_link_text("搜索设置").clear()
driver.find_element_by_class_name("prefpanelgo").clear()

目的是想鼠标悬浮百度首页“设置”处
运行之后并没有悬停在设置处
报错如下:
Traceback (most recent call last):
  File "D:/python/test.py", line 7, in <module>
    ActionChains(driver).move_to_element(link).perform()
  File "D:\Tool\python370\Python\Python37\lib\site-packages\selenium\webdriver\common\action_chains.py", line 80, in perform
    self.w3c_actions.perform()
  File "D:\Tool\python370\Python\Python37\lib\site-packages\selenium\webdriver\common\actions\action_builder.py", line 76, in perform
    self.driver.execute(Command.W3C_ACTIONS, enc)
  File "D:\Tool\python370\Python\Python37\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 320, in execute
    self.error_handler.check_response(response)
  File "D:\Tool\python370\Python\Python37\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 242, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.MoveTargetOutOfBoundsException: Message: The requested mouse movement to (1781, 16) would be outside the bounds of the current view port (left: 0, right: 1536, top: 79, bottom: 824)
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏
回复

使用道具 举报

  • TA的每日心情
    开心
    15 小时前
  • 签到天数: 1903 天

    连续签到: 1 天

    [LV.Master]测试大本营

    2#
    发表于 2018-9-17 09:09:20 | 只看该作者
    中间加个时间等待试下
    回复 支持 反对

    使用道具 举报

  • TA的每日心情
    无聊
    2018-12-21 17:28
  • 签到天数: 20 天

    连续签到: 1 天

    [LV.4]测试营长

    3#
    发表于 2018-9-17 14:31:33 | 只看该作者
    可以参考下博客:https://www.cnblogs.com/android-it/p/9371944.html,跟你写的差不多,你的报错猜测:是不是因为没有最大化你的ie导致定位找不到?个人猜测
    回复 支持 反对

    使用道具 举报

    本版积分规则

    关闭

    站长推荐上一条 /1 下一条

    小黑屋|手机版|Archiver|51Testing软件测试网 ( 沪ICP备05003035号 关于我们

    GMT+8, 2024-4-30 23:00 , Processed in 0.070918 second(s), 22 queries .

    Powered by Discuz! X3.2

    © 2001-2024 Comsenz Inc.

    快速回复 返回顶部 返回列表