Python Selenium opens a new window on click instead of tab

被刻印的时光 ゝ 提交于 2019-12-13 03:42:59

问题


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.

来源:https://stackoverflow.com/questions/50611045/python-selenium-opens-a-new-window-on-click-instead-of-tab

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!