Selenium is an open source tool which is used for automating the tests carried out on web browsers.
(web application are tested using any web browser). It allows you to write scripts in a variety of programming languages to automate interactions with web pages.
Why selenium IDE?
Test Scripts(language) --- Java, Ruby,Python,PHP,C#
OS Platform -- Windows, mac, Linux
Browsers -- Chrome, Mozilla, Internet Explorer, Opera, Microsoft Edge, safari
selenium Locators
There is a divers range of web elements like textbox, id, radio button etc, and identifying these elements is a tricky approach. Selenium uses locators to interact with the web elements on the webpage. There are 8 locators in Selenium WebDrivers.
Types of Locators
ID
Name
Classname
LinkText
Partial Link Text
CSS selector
XPath
TagName
ID -- The ID, stored in the id attribute of an HTML DOM element, is unique for every element in the page by design. Thus, an ID can uniquely identify an element. It is the fastest way to locate the webElement on the page. To use this feature, one needs to call the .find_element_by_id() method of the webDriver class.
Name -- Locating elements by name are very similar to locating by ID, except that we use the "name" prefix instead. The .find_element_by_name() method only returns the first element with the matching class.
Classname -- The another strategy of locating element on a page is to search by the class name.The class name is stored in the class attribute of an HTML tag. The .find_element_by_class_name() method only returns the first element with the matching class. It raises a NoSuchElementException if no element exists with the given class name.
LinkText -- This type of locator applies only to hyperlink text. We access the link by prefixing our target with "link=" and then followed by the hyperlink text. One can either use the .find_element_by_link_text() method to search for the exact link’s text.
Partial Link Text -- In some situation, we may need to find links by a portion of the text in a link text element. At that time we use partial link text to locate elements. The partial link text .find_element_by_partial_link_text() method to search for a partial text.
CSS selector -- CSS (Cascading Style Sheets) Selectors in Selenium are used to identify and locate web elements based on their id, class, name, attributes and other attributes. CSS is a preferred locator strategy as it is simpler to write and faster as compared to XPath. By.cssSelector(String cssSelector) method is used to locate the elements in Selenium WebDriver. This method accepts a CSS Selector String as an argument which defines the selection method for the web elements.
XPath -- XPath is designed to allow the navigation of XML documents with the purpose of selecting individual elements, attributes, or some other parts of an XML document for specific processing.We will use the .find_element_by_xpath() method to locate an appropriate element in the document.
TagName -- A tag name is a part of a DOM structure where every element on a page is been defined via tag like input tag, button tag or anchor tag etc. Each tag has multiple attributes like ID, name, value class etc. As far as other locators in Selenium are concerned, we used these attributes values of the tag to locate elements. We can locate elements by their HTML tag name using the .find_element_by_tag_name() method.
Comments