Reputation: 133
I am trying to download a file using python headless chrome web driver. My code is running to slow.There is no output(downloaded) file. I am getting no error. Any help would be appreciated. here is my code:
# Getting All User Credintials
for x in range(2,st.max_row + 1):
Users.append([st.cell(x, 1).value,st.cell(x, 2).value, st.cell(x, 3).value])
# Looping through Users
for item in Users:
try:
chrome_options = Options()
chrome_options.add_argument("--headless")
prefs = {"download.default_directory": os.getcwd()}
chrome_options.add_experimental_option("prefs", prefs)
chrome = webdriver.Chrome(chrome_options=chrome_options)
chrome.get(Url)
chrome.find_element_by_id("formId:codEmpresa").send_keys(item[0]) # Enterinng login Credintials
chrome.find_element_by_id("formId:codUsuario").send_keys(item[1])
chrome.find_element_by_id("formId:senha").send_keys(item[2])
chrome.find_element_by_link_text("Entrar").click() # Clicking Login button
chrome.get("https://www3.honda.com.br/newihs/AbrirPag?Opcao=1998")
chrome.find_element_by_name("W0002vWDINI").send_keys(DateFrom) # Entering DateForm
chrome.find_element_by_name("W0002vWDFIM").send_keys(DateTo) # Entering DateTo
chrome.find_element_by_name("W0002BT_CONFIRMAR").click() # Clicking Confirm button
wait = WebDriverWait(chrome, 10)
element = wait.until(EC.element_to_be_clickable((By.NAME, 'W0002BT_INFORMAR2')))
chrome.find_element_by_name("W0002BT_INFORMAR2").click() # Clicking Download button
Upvotes: 5
Views: 8962
Reputation: 11
This should help (C#)
chromeoptions.AddArguments("--headless", "--window-size=1920,1200");
Upvotes: 1
Reputation: 4739
Disable the proxy and try, it should increase performance
chrome_options.add_argument('--no-proxy-server')
I found that it helped me.
Upvotes: 6
Reputation: 2533
In addition to iamsankalp89 answer:
chrome_options.add_argument('--no-proxy-server')
these additional options helped me to drastically increase the performance:
chrome_options.add_argument("--proxy-server='direct://'");
chrome_options.add_argument("--proxy-bypass-list=*");
(Source: from this issue on GitHub and this comment in particular)
Upvotes: 13