SeleniumAutomation TestingTesting Tools

The Complete Selenium WebDriver with Java Course

192 Lectures 20 hours

Mastering XPath and CSS Selector for Selenium

47 Lectures 3 hours

We can download files to a specified location with Selenium in Python. This is done by the help of the ChromeOptions class. We shall set the preferences of the browser and pass the download.default_directory parameter.

We need to mention the path of the download directory with that parameter. This preference is sent to the ChromeOptions object with the add_experimental_option method.

Finally, this browser information is shared with the driver object.

Syntax

op = webdriver.ChromeOptions()
driver = webdriver.Chrome(chrome_options=op)

Example

Code Implementation.

from selenium import webdriver
from selenium.webdriver.common.by import By
#object of ChromeOptions
op = webdriver.ChromeOptions()
m.click()