1

I am trying to download some files with python selenium after authentication, but when selenium clicks the file link it opens a new window and therefore it is asking for authentication again. Can I force selenium to download file without opening new window or in new tab using same auth?

elementList = driver.find_elements_by_class_name("file-link")
for el in elementList:
    el.click()

Update 1:

elementList = driver.find_elements_by_class_name("file-link")
for el in elementList:
    driver.execute_script("arguments[0].setAttribute('target', 'self')", el)
    el.click()

But still getting multiple windows.

Manvi
  • 1,136
  • 2
  • 18
  • 41
  • Have you tried the suggestions from [this post?](https://stackoverflow.com/questions/34378449/selenium-open-link-in-same-tab) – Mihai Chelaru May 30 '18 at 18:52
  • Yes I setAttribute target to self. But its not working. – Manvi May 30 '18 at 20:41
  • Another workaround is, call directly URL which download a resource from the server. You can get URL directly from DOM element. Example: https://mysite/section/dummy/file.txt with python (http://docs.python-requests.org/en/master/) – Zhivko.Kostadinov May 31 '18 at 06:27

0 Answers0