0

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.

5
  • What code have you tried? You are much more likely to get an answer if you provide your attempts (no matter how bad), and the desired outcome of your code. Commented Sep 26, 2019 at 3:50
  • updated my question. thanks Commented Sep 26, 2019 at 3:57
  • 1
    Can you provide the website and element that you are trying this on? Your code as is looks fine, but I can't say for sure without looking at the page. Commented Sep 26, 2019 at 5:12
  • my code in the question works for zooming in the canvas_element. how can i do right click and drag on canvas element using the selenium in python. thanks. Commented Sep 26, 2019 at 6:13
  • Possible duplicate of selenium webdriver sendkeys() using python and firefox Commented Sep 26, 2019 at 10:04

1 Answer 1

0

You can use context_click in selenium.webdriver.common.action_chains for right click.

from selenium import webdriver
from selenium.webdriver import ActionChains

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

actionChains.context_click(your_link).perform()

With Selenium Webdriver, you can move mouse using move_by_offset(xoffset, yoffset) function

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.