如何使用Selenium ChromeDriver执行右键单击? [英] How to perform right click using Selenium ChromeDriver?
本文介绍了如何使用Selenium ChromeDriver执行右键单击?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我一直在寻找这个,但是找不到Python的答案.
I have been searching for this a lot, but could not find an answer for Python.
是否可以模拟右键单击或通过selenium/chromedriver打开上下文菜单?
Is it possible to simulate right click, or open up the context menu via selenium/chromedriver?
我见过Java和其他一些语言的选项,但从未在Python中看到过. 我该怎么做才能模拟右键单击链接或图片?
I have seen options for Java, and some other languages, but never in Python. What would I have to do to simulate a right click on a link, or a picture?
推荐答案
It's called context_click
in selenium.webdriver.common.action_chains. Note that Selenium can't do anything about browser level context menu, so I assume your link will pop up HTML context menu.
from selenium import webdriver
from selenium.webdriver import ActionChains
driver = webdriver.Chrome()
actionChains = ActionChains(driver)
actionChains.context_click(your_link).perform()
这篇关于如何使用Selenium ChromeDriver执行右键单击?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文