简体   繁体   English

双击在Firefox中有效,但在chrome中无效(Python / Selenium)

[英]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.

相关问题 click()适用于Chrome但不适用于Firefox? - click() works in Chrome but not Firefox? Python + Selenium代码在Chrome中工作正常,但在Firefox中工作不正常 - Python+selenium code works fine in Chrome, but not in Firefox Python selenium选项卡功能在Firefox中运行良好,但在Chrome中运行不正常 - Python selenium tab feature works fine in Firefox but not in Chrome Selenium…Program可以在Firefox上正常运行,但不能在Chrome上运行 - Selenium…Program Works Fine for Firefox, but not Chrome 使用TOR获取代理的Python selenium适用于firefox,但不适用于chrome - Python selenium using TOR to get proxies works for firefox, but doesn't work for chrome Selenium-Python-相同的代码适用于firefox,但适用于chrome则慢10分钟 - Selenium - Python - same code works well with firefox but 10min slower with chrome 硒python不适用于phantomjs但可与Firefox一起使用 - selenium python not working with phantomjs but works with Firefox Python Selenium:提取Chrome和Firefox浏览器的PID - Python Selenium: Extracting the PID of Chrome and Firefox browser Python Selenium - 适用于 Chrome、Firefox 和 IE 的通用脚本 - Python Selenium - Common Script for Chrome, Firefox & IE Google Chrome / Firefox和Selenium的击键不适用于Python - keystrokes with Google Chrome/Firefox and Selenium not working in Python
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM