Python Selenium opens a new window on click instea

2019-08-24 21:39发布

问题:

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.