I am trying to host my selenium script on Pythonanywhere.
However, I cannot see any .csv being downloaded through my code.
I have searched around for a while. such a headache!
Any help would be greatly appreciated!
from pyvirtualdisplay import Display
from selenium import webdriver
import time
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions
from selenium.webdriver.common.by import By
from os import getcwd
with Display():
profile = webdriver.FirefoxProfile()
profile.set_preference("browser.download.folderList", 2)
profile.set_preference("browser.download.manager.showWhenStarting", False)
profile.set_preference("browser.download.dir", getcwd())
profile.set_preference("browser.helperApps.neverAsk.saveToDisk", "text/csv")
browser = webdriver.Firefox(firefox_profile=profile)
try:
browser.get("https://track.cruxsystems.com/login")
browser.implicitly_wait(30)
WebDriverWait(browser, 50).until(
expected_conditions.element_to_be_clickable(
(By.XPATH, '//button[@uib-tooltip="Download"]')))
browser.find_elements_by_xpath("//button[@uib-tooltip='Download']")[0].click()
time.sleep(30)
finally:
browser.quit()
print('finished')
I have a screenshot after clicking the download button and it shows the pre-downloading loader and seems like it's about to download the file. However, nothing has been downloaded after.