I am trying to use python and selenium to automate some tasks in firefox. When I download a file, that pop up comes up asking if you want to open or save, and a check box fo
Error: fp.set_preference("browser.download.dir",getcwd()) NameError: name 'getcwd' is not defined
getcwd() is not defined. So I assume you want the getcwd from the os module:
add: import os , and then invoke with os.getcwd().
or you could just add the import for this function:
from os import getcwd
your example with the proper imports included:
import os
from selenium import webdriver
profile = webdriver.FirefoxProfile()
profile.set_preference('browser.download.folderList', 2)
profile.set_preference('browser.download.manager.showWhenStarting', False)
profile.set_preference('browser.download.dir', os.getcwd())
profile.set_preference('browser.helperApps.neverAsk.saveToDisk', 'text/csv/xls')
driver = webdriver.Firefox(profile)