Reputation: 1
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
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