ActionChains double_click() method does not performs the double click using Selenium and Python(ActionChains DOUBLE_CLICK()方法不使用Selify和Python执行双击)
本文介绍了ActionChains DOUBLE_CLICK()方法不使用Selify和Python执行双击的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有以下网页
。
我正在尝试双击";BLOCKED_IPs";文本。
这是与其交互的代码:
blocked_ips = driver.find_elements_by_xpath('//td[contains(.,"Blocked_IPs")]')
print(len(blocked_ips), blocked_ips)
action = ActionChains(driver)
action.double_click(blocked_ips[0])
问题是,它似乎没有双击它。当我手动操作时,它起作用了。当我执行代码时,它不会。只有一次单词&BLOCKED_IPS";出现。这是终端中的输出:
1 [<selenium.webdriver.remote.webelement.WebElement (session="82b277a5f85cbb202f5cd57c0b800f3b", element="530b1a15-a190-401c-8495-921777f8fa84")>]
有人知道为什么它不工作吗?我怎样才能测试它?提前感谢!
推荐答案
您需要添加perform()
以使所有ActionChain如下所示:
action.double_click(blocked_ips[0]).perform()
理想情况下,您需要为element_to_be_clickable()
诱导WebDriverWait,并且可以使用以下Locator Strategy:
ActionChains(driver).double_click(WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//td[contains(.,"Blocked_IPs")]")))).perform()
注意:您必须添加以下导入:
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.action_chains import ActionChains
这篇关于ActionChains DOUBLE_CLICK()方法不使用Selify和Python执行双击的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
沃梦达教程
本文标题为:ActionChains DOUBLE_CLICK()方法不使用Selify和Python执行双击


基础教程推荐
猜你喜欢
- 将 YAML 文件转换为 python dict 2022-01-01
- 合并具有多索引的两个数据帧 2022-01-01
- 哪些 Python 包提供独立的事件系统? 2022-01-01
- 症状类型错误:无法确定关系的真值 2022-01-01
- 如何在 Python 中检测文件是否为二进制(非文本)文 2022-01-01
- 使用 Google App Engine (Python) 将文件上传到 Google Cloud Storage 2022-01-01
- 使 Python 脚本在 Windows 上运行而不指定“.py";延期 2022-01-01
- Python 的 List 是如何实现的? 2022-01-01
- 使用Python匹配Stata加权xtil命令的确定方法? 2022-01-01
- 如何在Python中绘制多元函数? 2022-01-01