How to save an image by selecting "save image as ..." in the context menu using Selenium Webdriver (Python)

I am trying to use selenium webdriver to save a specific image in a directory. I wanted to do this by simulating a right click on the img element and selecting "save image as ...". With the following code, I can open the context menu, but I cannot select the correct option.

browser = WebDriver(executable_path=CHROMEDRIVER_PATH)
browser.get(URL)
img = browser.find_element_by_tag_name('img')
ActionChains(browser).context_click(img).perform()

I also tried:

ActionChains(browser).context_click(img).send_keys(Keys.ARROW_DOWN).send_keys(Keys.ENTER).perform()                 

and using the shortcut ('v' seems to select "save image as ...")

ActionChains(browser).context_click(img).send_keys('v').perform()

URL-, , . , , , - ( " ..." ). , .

?

+5
3

, , , .

driver.save_screenshot('screenshot.png')
+3

kreativitea, , , CAPTCHA , , . CAPTCHA . , .

0

I had a similar problem and now I got a shortcut to save the image using save as ---

Step-1-right click on an image you wish to save
Step-2- press v. 
Step-3-Enter to the directory window to save 

Since I am a java programmer, so I could not insert the code accordingly (the question was asked for python).

0
source

All Articles