How to automate menu box / pop up of right click in python selenium.

+3 votes

Hello,

I want to automate / click the menus available after right click. But right click pop up is not supported by Chro Path / F12.

Any suggestions how to do it with Python-Selenium.

Thanks In Advance.

ADS...

Aug 9, 2019 in Selenium by ADS
• 280 points
3,686 views

1 answer to this question.

+3 votes

You can use keys to do this. Here's the code snippet:

img = driver.find_element_by_xpath('//img')
actionChains = ActionChains(driver)
actionChains.move_to_element(img).context_click().send_keys(Keys.ARROW_DOWN).send_keys(Keys.ARROW_DOWN).send_keys(Keys.ENTER).perform()
answered Aug 9, 2019 by Shubham
Hey Shubham,

Thanks but it is not what I am looking for and working.

If I click on blank area of any web page (e.g. google) then I could view above native context menus. and if I want to choose 'Reload', 'Save as' and others then there is no any Xpath or other locators then how to click these options using python selenium that is what I want.

Thanks !
Yes, you don't have xpath for the context menu. The workaround is to right-click and then use arrow keys to go to that particular option.
Ya, but if I want to choose the option 'Cast' or 'Print' then how and where to pass this value ?

When I use above code it clicks but it scrolls web page and not showing selection of options from the context menu.
Which browser you are using to perform the automation?

Related Questions In Selenium

0 votes
1 answer

How to handle Pop-up in Selenium WebDriver using Java

Actually, its pretty simple. Use this code ...READ MORE

answered Apr 5, 2018 in Selenium by nsv999
• 5,520 points
7,577 views
0 votes
1 answer
0 votes
2 answers
0 votes
1 answer

Installing Selenium Webdriver with Python package

Hey Hemant, for installing Selenium Webdriver with ...READ MORE

answered May 8, 2019 in Selenium by Anvi
• 14,110 points
3,490 views
0 votes
2 answers

Finding WebDriver element with Class Name in java

The better way to handle this element ...READ MORE

answered Apr 10, 2018 in Selenium by nsv999
• 5,520 points
3,777 views
0 votes
2 answers

Problem while using InternetExplorerDriver in Selenium WebDriver

enable trusted connection  in internet explorer by ...READ MORE

answered Aug 31 in Selenium by Sri
• 2,970 points
4,761 views
0 votes
1 answer

Geo-location microphone camera pop up

To Allow or Block the notification, access using Selenium and you have to ...READ MORE

answered May 11, 2018 in Selenium by Samarpit
• 5,890 points
2,739 views
0 votes
2 answers

Unable to Click on an Element in Selenium (Python) even after finding it.

Here, I give you working script which ...READ MORE

answered Sep 19, 2018 in Selenium by Priyaj
• 57,700 points
16,686 views
+10 votes
15 answers

How to automate gmail login process using selenium webdriver in java?

Check the below code: Here is the working ...READ MORE

answered Apr 24, 2018 in Selenium by Vardy
• 2,360 points
121,801 views