Posts

Showing posts with the label selenium

Selenium - locators

Image
Selenium Locators are used for identifying the web elements on the web page. T o access the HTML elements from a web page locators are used. In Selenium, we can use locators to perform actions on text boxes, checkboxes, links, radio buttons, list boxes, and other web elements. Locators help us in identifying the objects. This tutorial explains different types of locators, how, when, and ideal Strategies to use these locators. Example of web browser methods: Find Element by: There are two private methods that might be useful for locating page elements: find_element find_elements Example usage: from selenium.webdriver.common.by import By driver . find_element ( By . XPATH , '//button[text()="Some text"]' ) driver . find_elements ( By . XPATH , '//button' ) These are the attributes available for  By  class: ID = "id" XPATH = "xpath" LINK_TEXT = "link text" PARTIAL_LINK_TEXT = "partial link text" NAME ...

Selenium Webdriver Manager

Image
The simple way to connect the Webdriver is like that: 1 from selenium import webdriver 2 3 driver = webdriver.Chrome(<path_of_driver>) Const: We need to put all paths and their relative path. If the webdriver or the browser version change/update, we need to manually download him and replace it with the old one. A better way is to put the driver in venv folder, in that way the webdriver is available in all projects without writing the relative path. so... what is the easiest way to figure it out ? Meet webdriver manager, an alternative way to work with webdriver, It pulls the latest version from the central repository automatically. you just need to do two simple steps: Webdriver Manager The main idea of  webdriver_manager i s to simplify the management of binary drivers for different browsers. Instead of: Downloading binary chrome driver. Unzip it somewhere on your PC. Set path to this driver. Every time when there is a new version of the browser, we should repeat all tho...