微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

无法使用 Selenium 中的 Actions 类执行鼠标悬停

如何解决无法使用 Selenium 中的 Actions 类执行鼠标悬停

我正在尝试使用部分隐藏的 Actions 类打开应用面板。首先,我需要将鼠标悬停在鼠标上,然后单击它。

请查看屏幕截图以了解我在说什么类型的元素。

Apps panel before hooverApps panel after mouse hooverhtml code

执行此代码时出现以下错误

A)

public void getAppsPanel() {
        Actions act = new Actions(getDriver());
        WebElement appsPanelIcon = getDriver().findElement(By.xpath("//*[contains(text(),'Apps Panel')]"));
        act.movetoElement(appsPanelIcon).perform();
        appsPanelIcon.click();
    }

B)

public void getAppsPanel() {
    Actions act = new Actions(getDriver());
    WebElement appsPanelIcon = getDriver().findElement(By.xpath("//*[contains(text(),'Apps Panel')]"));
    act.movetoElement(appsPanelIcon,30,30).perform();
    appsPanelIcon.click();
}

2021 年 3 月 16 日下午 2:36:54 org.openqa.selenium.remote.ProtocolHandshake createSession 信息:检测到的方言:W3C

org.openqa.selenium.interactions.MoveTargetoutOfBoundsException: 移动目标越界 (会话信息:无头 chrome=89.0.4389.82) 构建信息:版本:'3.141.59',修订版:'e82be7d358',时间:'2018-11-14T08:17:03' 系统信息:主机:'',ip:'',os.name:'Mac OS X',os.arch:'x86_64 ',os.version: '10.11.6',java.version: '15.0.1' 驱动程序信息:org.openqa.selenium.chrome.ChromeDriver 功能 {acceptInsecureCerts: false,browserName: chrome,browserVersion: 89.0.4389.82,chrome: {chromedriverVersion: 89.0.4389.23 (61b08ee2c5002 ...,userDataDir: /var/folders/0v/zqm2pps/0v/zqm2pps),googn... debuggerAddress: localhost:51341},javascriptEnabled: true,networkConnectionEnabled: false,pageLoadStrategy: normal,platform: MAC,platformName: MAC,proxy: Proxy(),setwindowRect: true,strictFileInteractability: false,timeouts: {implicit: 0,pageLoad: 300000,脚本:30000},未处理的PromptBehavior:解雇和通知,webauthn:extension:largeBlob: true,webauthn:virtualAuthenticators: true} 会话 ID:987e9ee9266d17c0b3413260be25b50a

预先感谢您的帮助!

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。