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 in Selenium by ADS
• 280 points
445 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 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,110 points
4,954 views
0 votes
1 answer
0 votes
2 answers

How to get HTML Source of WebElement in Selenium WebDriver using Python?

You can read innerHTML attribute to get source of ...READ MORE

answered Jun 13, 2018 in Selenium by Samarpit
• 5,130 points
17,013 views
0 votes
1 answer

Installing Selenium Webdriver with Python package

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

answered May 8 in Selenium by Anvi
• 13,960 points
227 views
0 votes
1 answer

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,110 points
931 views
0 votes
1 answer
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,130 points
1,114 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
• 56,900 points
8,697 views
+9 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,270 points
69,992 views