Debomita Bhattacharjee has Published 872 Answers

What is xpath in Selenium with python?

Debomita Bhattacharjee

Debomita Bhattacharjee

Updated on 29-Jul-2020 07:40:05

Xpath is one the locators used in Selenium to identify elements uniquely on a web page. It traverses the DOM to reach the desired element having a particular attribute with/without tagname.The xpath can represented by the ways listed below −//tagname[@attribute='value']//*[@attribute='value']The xpath can be created by the following methods −OR & ... Read More

What are the differences between xpath and css in Selenium with python?

Debomita Bhattacharjee

Debomita Bhattacharjee

Updated on 29-Jul-2020 07:38:10

Both xpath and css are one the most frequently used locators in Selenium. Though there are other locators like id, name, classname, tagname, and link text and so on, xpath and css are used when there are no unique attributes available to identify the elements.There are some differences between xpath ... Read More

How to identify nth element using xpath in Selenium with python?

Debomita Bhattacharjee

Debomita Bhattacharjee

Updated on 29-Jul-2020 07:34:22

There are multiple ways of building a customized xpath. In case we need to identify nth element we can achieve this by the ways listed below.position() method in xpath.Suppose we have two edit boxes in a page with similar xpath and we want to identify the first element, then we ... Read More

Explain some of the ways of creating customized css in Selenium with python?

Debomita Bhattacharjee

Debomita Bhattacharjee

Updated on 29-Jul-2020 07:32:08

The css is one of the important locators in Selenium. A customized css can be developed with the help of attributes like id, classname and by the combination of tagname and html attributes.The ways of creating a css are listed below −Using a class name html attribute.This will select the ... Read More

How to use text() in xpath in Selenium with python?

Debomita Bhattacharjee

Debomita Bhattacharjee

Updated on 29-Jul-2020 07:29:54

We can create a customized xpath with the help of the visible text on the page. This is achieved with the help of text() method in xpath.The text() finds the object with the exact text match on the page.Syntaxdriver.find_element_by_xpath("//input[text()='Selenium']")It will search for elements with visible text 'Selenium' on the page.ExampleCode ... Read More

How to use regular expressions in xpath in Selenium with python?

Debomita Bhattacharjee

Debomita Bhattacharjee

Updated on 29-Jul-2020 07:27:39

We can identify elements by matching its attributes partially with the help of regular expressions. In xpath, there are multiple methods to achieve this. They are listed below −Using the contains() method. This means the string contains our given text.Syntax −driver.find_element_by_xpath("//input[contains(@name, 'sel')]")It will search the input tag which contains the ... Read More

How to use regular expressions in css in Selenium with python?

Debomita Bhattacharjee

Debomita Bhattacharjee

Updated on 29-Jul-2020 07:25:51

We can identify elements by matching its attributes partially with the help of regular expressions. In css, there are multiple methods to achieve this. They are listed below −Using the wild character *. This means the string contains our given text.Syntax−driver.find_element_by_css_selector("input[name*='sel']")It will search the input tag which contains the 'name' ... Read More

Name the different locators used in Selenium with python.

Debomita Bhattacharjee

Debomita Bhattacharjee

Updated on 29-Jul-2020 07:21:40

The different locators used in Selenium with python are listed below.Id - The element is identified with its id attribute. NoSuchElementException raised if element with matching id is not available.Syntax −driver.find_element_by_id("id")Name - The element is identified with its name attribute. NoSuchElementException raised if element with matching name is not available.Syntax ... Read More

How to write a text file in Selenium with python?

Debomita Bhattacharjee

Debomita Bhattacharjee

Updated on 29-Jul-2020 07:19:15

We can write a text file in Selenium with python by first creating a txt file and having a content on it.First of all, we need to open the file in write mode and mention the path of the location of the text file as an argument. There are multiple ... Read More

What are the differences between readline() and readlines() in Selenium with python?

Debomita Bhattacharjee

Debomita Bhattacharjee

Updated on 29-Jul-2020 07:15:42

The differences between readline() and readlines() methods are listed below.readlines()This method will read the entire content of the file at a time.This method reads all the file content and stores it in the list.This method reads up to the end of the line with readline () and returns a list.readline()This ... Read More

Advertisements