0

I would like to use ActionChains function of Selenium. Below is like my codes. But It does not work when it opens right click menu. The ARROW_DOWN and ENTER are implemented in main window not, right click menu. How can the ARROW_DOWN and ENTER code be implemented in right click menu.

Brower = webdriver.Chrome()

actionChain = ActionChains(Browser) actionChain.context_click(myselect[0]).send_keys(Keys.ARROW_DOWN).send_keys(Keys.ENTER).perform()

3
  • What is your goal? Are you trying to test a web application? Are you trying to automate some personal task? Or something else? Commented Mar 2, 2018 at 13:56
  • I try to automate my personal task. My goal is to download the link file. But the file is opened in the web not downloaded. Is there other way to download linked file? Commented Mar 6, 2018 at 1:41
  • To find an answer that address native context menus, see: stackoverflow.com/a/59361853/1747771 Commented Nov 11, 2020 at 1:55

2 Answers 2

1

Selenium cannot see or interact with native context menus.

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

2 Comments

what is the purpose of actions.context_click().perform() existing then? I have been searching for the solution to this an find it astounding such a solution does not exist or isn't documented for python
@Rhys, it appears that the context_click exists for context menus that offer app-specific functionality (e.g., right-clicking on a youtube video offers an app-specific context menu), but not for the browser's generic context menu. This has been a frustrating process for me to figure out this restriction.
0

I have implemented simliar functions, here is idea how to do it:

Step 1: perform right click to popup the menu

menuDiv = browser.find_element_by_xpath("//<selector>']")
actionChains.move_to_element(menuDiv).perform()
actionChains.context_click().perform()
time.sleep(3)   //better wait for a little while

Step 2: locate the menu item to click and perform click on it

targetMenuItem = browser.find_element_by_xpath("//<selector>")
actionChains.click(targetMenuItem)
actionChains.perform()

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.