Selenium - No Download Permission

Asked

Viewed 40 times

-1

I created a script in Python using Selenium to access a site and download some files, however, the browser blocks the download and informs the following message: "Could not download - No permissions". Note: I don’t have an Adm account on the computer I run, but the lock only happens when I use Selenium. If I open the browser manually the downloads are done normally.

Is there an adjustment option in the code to handle this download lock (for example, some option in "Options")? Below is a part of the code as an example, but the permission error happens on any page/site.


def baixa_relacao():
    options = EdgeOptions()
    options.use_chromium = True
    driver = Edge(options=options)
    actionChains = ActionChains(driver)

    driver.get('confidencial')

    driver.find_element_by_xpath('//*[@id="gsft_nav"]/div/magellan-favorites-list/ul/li[1]/div/div[1]/a/div[2]/span').click()


    driver.switch_to.frame('gsft_main')
    driver.find_element_by_link_text('Enviar Segurado...').click()

    botao = driver.find_element_by_xpath('//*[@id="hdr_sc_req_item"]/th[5]/span/a')
    actionChains.context_click(botao).perform()

    driver.find_element_by_xpath('//*[@id="context_list_headersc_req_item"]/div[13]').click()

    driver.find_element_by_xpath('//*[@id="d1ad2f010a0a0b3e005c8b7fbd7c4e28_sc_req_item"]/div[2]').click()

    driver.find_element_by_id('download_button').click()

  • You already asked that question here cannot answer without knowing which page that code is intended for.

  • Regardless of the page, it blocks the download. That is, if the script joins google and tries to download something, it will give the same permission problem. I’ve tried it on several pages. The above code was just one of the example pages.

  • But as so page independent, the xpath is very specific it can only be applied to the tree whose was designed.

  • The code I put above is just a part of the script that accesses a particular website and downloads a file. The script accesses other pages on the internet also to download other files. Regardless of the site or browser I use I can’t download any file and I get the message "No permissions". I’ve even tried to change the folder where downloads are saved, but also without success.

1 answer

-3

Use a User-Agent, for example:

header = {'User-Agent': "Coloque seu User-Agent aqui"}

Then enter in the parameter in the driver get., thus:

driver.get('confidencial', headers=header)

Note: to get your User-Agent just search some site by the term "My User-Agent".

Browser other questions tagged

You are not signed in. Login or sign up in order to post.