

Login_form = driver.find_element_by_xpath( TAKING SCREENSHOT WITH save_screenshot() FUNCTION Login_form = driver.find_element_by_xpath( "//form") Login_form = driver.find_element_by_xpath( "/html/body/form") XPath enables testers to navigate through the XML structure of any document, and this can be used on both HTML and XML documents. XPath is a technique in Selenium to navigate through the HTML structure of a page. Use send_keys () data to input required data into the field.Įlement = driver.find_element_by_name( "username")Įnd_keys( "this_is_my_username")Įlement = driver.find_element_by_name( "password")Įnd_keys( "this_is_my_password") Pass the name attribute in find_element_by_name () function. Search for name attribute in the inspect element page. Right click on the field and click inspect. Store the link in a variable using find_element_by_id (‘link’). Right click on the link to be opened and click on copy link address. sleep( 5) to add delay to open the URL.įinally click on the element with click () function.Įlement = driver.find_element_by_link_text( 'Solutions') Store the text of the link using find_element_by_link_text (). #For macOS #executable_path = '/usr/bin/chromedriver/chromedriver.exe’ #For Linux #executable_path = '/usr/local/bin/chromedriver/chromedriver.exe’ĬLICKING ON THE ELEMENTS USING find_element_by_link_text () FUNCTION. Use get () function and pass URL as the parameter.

# For Linux # executable_path = '/usr/ local/bin/chromedriver/chromedriver.exe’ # For macOS # executable_path = '/usr/bin/chromedriver/chromedriver.exe’ To maximize the window use maximize_window() function.ĭriver = webdriver.Chrome(executable_path = "C:\\chromedriver.exe")

NOTE: In this case we don’t need to specify the executable_path. Set the path: $ exportPATH = PATH:/usr/local/bin/driver_name. Move the webdriver to the bin folder using. Paste the path in the (executable_path = ‘path’).ĭownload the web-driver zip file from the above links.Įxtract the zip to the desired location (ex: /usr/bin/chromedriver)Ĭopy the path of executable to set as the (executable_path = ‘path’). Right click on executable of web-driver and copy the path.

Safari: Click Here.ĭownload the web-driver zip file from the above link according to the version of the browser.Įxtract the zip file to desired location. Download the required Web drivers: Chrome: Click here. Open Terminal/Command Prompt and type: ~ pip install seleniumĢ. Selenium can send the standard Python commands to different browsers such as Chrome, Firefox, IE on different operating systems to perform different tasks on the browser. Python APIs empower us to connect with a browser through Selenium Web driver. Selenium is an open-source, web-based automation tool.
