Q:

Is there a way to send keys to "Save Image As..." dialog in Selenium webdriver?

Trying to extract an image, successfully triggered "Save Image as..." dialog, but couldn't send any keys, is there a way to solve this problem?
driver = webdriver.Firefox()
actions = webdriver.ActionChains(driver)
actions.move_to_element(img).context_click(img).send_keys('v').perform()

time.sleep(2)

# and this line does not work
actions.send_keys('image.jpg').perform()

Only one step away from making everything works, what should I do?

A:

This is a kind of popup you cannot control with selenium.
In this case you need to ask the browser to save the file automatically by tweaking it's preferences (aka desired capabilities):
profile = webdriver.FirefoxProfile()
profile.set_preference("browser.download.folderList", 2)
profile.set_preference("browser.download.manager.showWhenStarting", False)
profile.set_preference("browser.download.dir", "/path/to/file")
profile.set_preference("browser.helperApps.neverAsk.saveToDisk", "image/jpeg")

driver = webdriver.Firefox(firefox_profile=profile)

where browser.helperApps.neverAsk.saveToDisk setting value should have a mime-type (or a comma-separated list of mime-types) of the files that should be downloaded automatically.
See also:

Access to file download dialog in Firefox

