Selenium Webdriver - Click()方法因IE驱动程序而失败 [英] Selenium Webdriver - Click() method fails with IE driver

查看:1417
本文介绍了Selenium Webdriver - Click()方法因IE驱动程序而失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用IE驱动程序 IE11
对于某些元素点击方法只会选择一个元素,
它不会执行 Click()的操作。
使用 ChromeDriver FirefoxDriver 相同的脚本工作正常。

I'm using the IE driver with IE11, For some elements Click method will only select a element, it wont do the action of the Click(). With ChromeDriver and FirefoxDriver same script is working fine.

我已将驱动程序功能设置如下

I've set driver capabilities as below

DesiredCapabilities caps = DesiredCapabilities.internetExplorer();
caps.setCapability(InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS, true);
caps.setCapability(InternetExplorerDriver.IGNORE_ZOOM_SETTING, true);
caps.setCapability(InternetExplorerDriver.REQUIRE_WINDOW_FOCUS, false);
caps.setCapability(InternetExplorerDriver.ENABLE_PERSISTENT_HOVERING, false);
caps.setCapability(InternetExplorerDriver.NATIVE_EVENTS, false);

我在以下链接中找到了一些解决方案,但仍面临同样的问题。

I found some solutions on following links but still facing same issue.

Internet Explorer中的Selenium WebDriver点击问题

Selenium WebDriver,点击,链接闪烁,好像某些点击事件没有完全处理

Selenium 2.0b3 IE WebDriver,点击不激活

推荐答案

很难说为什么它无法点击 IE ,可能是它的设计问题。

It's hard to say why is it not clickable on IE, may be its designing issue.

如果你已经尝试了所有可能性,但没有任何成功尝试使用 JavascriptExecutor 作为替代溶胶如下: -

If you have tried all possibility, but nothing get success try using JavascriptExecutor as an alternate solution as below :-

((JavascriptExecutor)driver).executeScript("arguments[0].cli‌​ck()", yourElement);

注意: - JavaScript injection HTMLElement.click()不应在测试环境中使用。它违背了测试的目的。首先是因为它没有生成所有事件,如真正的点击(焦点,模糊,mousedown,鼠标...),其次是因为它不能保证真实用户可以与元素进行交互。但是要摆脱这个问题,你可以将它视为一种替代解决方案。

Note :- The JavaScript injection HTMLElement.click() shouldn't be used in a testing context. It defeats the purpose of the test. First because it doesn't generate all the events like a real click (focus, blur, mousedown, mouseup...) and second because it doesn't guarantee that a real user can interact with the element. But to get rid from this issues you can consider it as an alternate solution.

这篇关于Selenium Webdriver - Click()方法因IE驱动程序而失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆