首页 > 解决方案 > How to use send_keys in selenium webdriver in python?

问题描述

i want to move the canvas element using mouse right click and mouse move. how can i do with it actiondriver and send_keys in selenium. could someone help me with this. thanks.

i have tried something like

ActionChains(driver).move_to_element(canvas_element).send_keys(
Keys.chord(Keys.CONTROL, Keys.ADD)).build().perform();

this is to zoomin the canvas element. similarly how can i perform right click and mouse move.

标签: pythonselenium

解决方案


您可以context_clickselenium.webdriver.common.action_chains中使用右键单击。

from selenium import webdriver
from selenium.webdriver import ActionChains

driver = webdriver.Chrome()
actionChains = ActionChains(driver)

actionChains.context_click(your_link).perform()

使用 Selenium Webdriver,您可以使用move_by_offset(xoffset, yoffset)函数移动鼠标

参考 - https://selenium-python.readthedocs.org/api.html?highlight=mouse#selenium.webdriver.common.action_chains.ActionChains.move_by_offset


推荐阅读