Coder
Coder

Reputation: 1

(Python Selenium with Chrome) How to click in the right click menu list

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()

Upvotes: 0

Views: 1338

Answers (2)

LIU YUE
LIU YUE

Reputation: 2007

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()

Upvotes: 0

Ian Lesperance
Ian Lesperance

Reputation: 5139

Selenium cannot see or interact with native context menus.

Upvotes: 1

Related Questions