Reputation: 43
I want to download files into a desired location in chrome using python selenium.however,i am not getting any idea.our framework uses mozwebqa. how do i change the properties to download files to my desired location.
Just a sample code
@pytest.fixture()
def preparation (self, request, mozwebqa):
openyaml = open("desired txt file")
testdata = yaml.load(openyaml)
openyaml.close()
self.sample = testdata['abc']
def test_sampletest(self, mozwebqa, preparation):
homepage = basePage(mozwebqa).homepage()
homepage.login()
please help, where to set the preference for downloading files to my desired location.
Upvotes: 2
Views: 4550
Reputation: 17553
Use below code :-
chromeOptions = webdriver.ChromeOptions()
prefs = {"download.default_directory" : "/some/path"}
chromeOptions.add_experimental_option("prefs",prefs)
chromedriver = "path/to/chromedriver.exe"
driver = webdriver.Chrome(executable_path=chromedriver, chrome_options=chromeOptions)
Source: https://sites.google.com/a/chromium.org/chromedriver/capabilities
Upvotes: 3