0

I am trying to right click on a link, and then click "Save link as" and then have the program type some name and save the link. However, whenever I open a context menu on a link, I am only able to choose the first or second option in the menu. More specifically, I can click on "Open link in new tab" and "Open link in new window", but not anything below that. Here is my code:

from selenium import webdriver

from selenium.webdriver.common.keys import Keys
from selenium.webdriver import ActionChains

import time

driver = webdriver.Chrome()
driver.get("https://www.wikipedia.org")

elem = driver.find_element_by_link_text('Download for iOS on the App Store')

actionChains= ActionChains(driver);
time.sleep(3)
actionChains.context_click(elem).send_keys(Keys.SHIFT, Keys.ARROW_DOWN,'H').send_keys(Keys.ARROW_DOWN).send_keys(Keys.ARROW_DOWN).send_keys(Keys.ARROW_DOWN).send_keys(Keys.ENTER).perform()
Patrick Artner
  • 50,409
  • 9
  • 43
  • 69
  • looks like you cant: https://stackoverflow.com/questions/37835867/using-selenium-in-python-to-save-a-webpage-on-firefox – Doug Clark Jan 02 '19 at 19:41
  • why do you `time.sleep` ? – Amr Ayman Jan 02 '19 at 19:51
  • The time sleep thing is a remnant from before, it does nothing so you can just ignore that –  Jan 02 '19 at 20:01
  • @DougClark Very well, but I'd still like to know just how to go down in the context menu beyond the first two options –  Jan 02 '19 at 20:07
  • from the linked post: "What you are trying to achieve is impossible to do with Selenium. The dialog that opens is not something Selenium can interact with." But here is another post i found that could help you: https://stackoverflow.com/questions/45789188/how-to-navigate-context-menus-selenium-python – Doug Clark Jan 02 '19 at 20:32
  • But if it's impossible to navigate, then how was I able to navigate to choose a new window instead of a new tab? –  Jan 02 '19 at 22:10

0 Answers0