[英]Double click works in Firefox but not chrome (Python/Selenium)
I have an element that requires a double_click().perform()
action. 我有一个需要double_click().perform()
操作的元素。 It works great in Firefox, but doesn't in Chrome. 它在Firefox中效果很好,但在Chrome中不起作用。 A single click displays a menu, but a double click takes you to a directory. 单击可显示菜单,但双击可将您带到目录。 Here is my python/selenium step: 这是我的python / selenium步骤:
(webdriver.ActionChains(self.browser)).double_click(self.browser.find_element_by_id('nav-link-shopall')).perform()
The error message returns that the text I'm wanting to verify exists does not exist. 错误消息返回,我要验证的文本不存在。 Which is true if the double_click().perform()
doesn't do its job. 如果double_click().perform()
没有完成其工作,则为true。
I'm using Python 2.7.8 and Selenium 2.45.0. 我正在使用Python 2.7.8和Selenium 2.45.0。
I'm using Amazon.com as an example because the behavior is the same as the proprietary code I am testing. 我以Amazon.com为例,因为其行为与我正在测试的专有代码相同。 So here is the HTML code I'm attempting to click: 因此,这是我尝试单击的HTML代码:
<div class="nav-left">
<div id="nav-shop">
<a href="/gp/site-directory/ref=nav_shopall_btn" class="nav-a nav-a-2" data-nav-tabindex="15" id="nav-link-shopall" tabindex="1">
<span class="nav-line-1">Shop by</span>
<span class="nav-line-2">"Department"
<span class="nav-icon nav-arrow" style="visibility:visible;"></span>
</span>
</a>
</div>
</div>
Try this: 尝试这个:
variable = self.browser.find_element_by_id('nav-link-shopall')
actions = ActionChains(driver)
actions.move_to_element(variable)
actions.double_click(variable)
actions.perform()
You should use move to element. 您应该使用move to元素。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.