Debomita Bhattacharjee

Debomita Bhattacharjee

590 Articles Published

Articles by Debomita Bhattacharjee

Page 53 of 59

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

Debomita Bhattacharjee
Debomita Bhattacharjee
Updated on 29-Jul-2020 8K+ Views

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 'name' attribute containing 'sel' text.Using the starts-with() method. This means the string starts with our given text.Syntax −driver.find_element_by_xpath("//input[starts-with (@name, 'Tut')]")It will search the input tag which contains the 'name' attribute starting with 'Tut' text.Using the ends-with() method. This means the string ends with our given text.Syntaxdriver.find_element_by_xpath("//input[ends-with (@name, 'nium')]")It will search ...

Read More

Name the different locators used in Selenium with python.

Debomita Bhattacharjee
Debomita Bhattacharjee
Updated on 29-Jul-2020 219 Views

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 −driver.find_element_by_name("name")Xpath - The element is identified with the attributes and tagname. There are two types of xpath – absolute and relative.Syntax −driver.find_element_by_xpath("//input[@type='type']")CSS - The element is identified with the help of css expression built with the help of attributes like id, class and tagName. NoSuchElementException raised if element with matching ...

Read More

How to write a text file in Selenium with python?

Debomita Bhattacharjee
Debomita Bhattacharjee
Updated on 29-Jul-2020 2K+ Views

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 reading methods to perform these operations.write() – It writes the string in one line in a text file.writelines() – It writes more than one string in a text file.ExampleCode Implementation with write().#open the file for write operation f = open('hello.txt' , 'w') #writes the new content f.write('Tutorialspoint') #close the file ...

Read More

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

Debomita Bhattacharjee
Debomita Bhattacharjee
Updated on 29-Jul-2020 11K+ Views

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 method will read one line in a file.A new line character is left at the string end and is ignored for the last line provided the file does not finish in a new line.This method reads up to the end of the line with readline() and returns a list.ExampleCode Implementation ...

Read More

How to read a text file in Selenium with python?

Debomita Bhattacharjee
Debomita Bhattacharjee
Updated on 29-Jul-2020 3K+ Views

We can read 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 and mention the path of the location of the text file as an argument. There are multiple reading methods to perform these operations.read() – It reads the entire content of the file.read(n) – It reads n characters of the text file.readline() – It reads character line by line at a time. If we need to read the first two lines, the readline() method is to be used twice.readlines() – it reads ...

Read More

How to close a browser session in Selenium with python?

Debomita Bhattacharjee
Debomita Bhattacharjee
Updated on 29-Jul-2020 1K+ Views

We can close a browser session in Selenium by the following ways −Using the close() method.Using the quit() method.Both these methods close the browser, but close() the browser in focus and quit() ends the driver session.ExampleCode Implementation with close().from selenium import webdriver #browser exposes an executable file #Through Selenium test we will invoke the executable file which will then #invoke actual browser driver = webdriver.Chrome(executable_path="C:\chromedriver.exe") # to maximize the browser window driver.maximize_window() #get method to launch the URL driver.get("https://www.tutorialspoint.com/index.htm") #to refresh the browser driver.refresh() #to close the browser driver.close()Code Implementation with quit().from selenium import webdriver #browser exposes an executable file ...

Read More

How to invoke the IE browser in Selenium with python?

Debomita Bhattacharjee
Debomita Bhattacharjee
Updated on 29-Jul-2020 1K+ Views

We can invoke any browsers with the help of the webdriver package. From this package we get access to numerous classes. Next we have to import the selenium.webdriver package. Then we shall be exposed to all the browsers belonging to that package.For invoking the internet explorer browser, we have to select the Ie class. Then create the driver object of that class. This is the most important and mandatory step for browser invocation.Every internet explorer browser gives an executable file. Through Selenium we need to invoke this executable file which is responsible for invoking the actual chrome browser.Next we need ...

Read More

How to invoke the Firefox browser in Selenium with python?

Debomita Bhattacharjee
Debomita Bhattacharjee
Updated on 29-Jul-2020 3K+ Views

We can invoke any browsers with the help of the webdriver package. From this package we get access to numerous classes. Next we have to import the selenium.webdriver package. Then we shall be exposed to all the browsers belonging to that package.For invoking the Firefox browser, we have to select the Firefox class. Then create the driver object of that class. This is the most important and mandatory step for browser invocation.Every firefox browser gives an executable file. Through Selenium we need to invoke this executable file which is responsible for invoking the actual chrome browser.Next we need to download ...

Read More

How to invoke the Chrome browser in Selenium with python?

Debomita Bhattacharjee
Debomita Bhattacharjee
Updated on 29-Jul-2020 14K+ Views

We can invoke any browsers with the help of the webdriver package. From this package we get access to numerous classes. Next we have to import the selenium.webdriver package. Then we shall be exposed to all the browsers belonging to that package.For invoking chrome browser, we have to select the Chrome class. Then create the driver object of that class. This is the most important and mandatory step for browser invocation.Every chrome browser gives an executable file. Through Selenium we need to invoke this executable file which is responsible for invoking the actual chrome browser.Next we need to download the ...

Read More

How to identify multiple elements at the same time in Selenium with python?

Debomita Bhattacharjee
Debomita Bhattacharjee
Updated on 28-Jul-2020 880 Views

We can locate and identify multiple elements at the same time in Selenium. There are various strategies to locate the elements. The different ways of locating elements are listed below −find_elements_by_xpath – This method returns all the elements with matching xpath in the argument in form a list. It shall return an empty list if no element has the matching xpath.Syntaxdriver.find_elements_by_xpath("//input[name='text-search']")find_elements_by_link_text – This method returns all the elements with matching value of link text in the argument to form a list. It shall return an empty list if no element has the matching text.Syntaxdriver.find_elements_by_link_text("Tutorialspoint")find_elements_by_name – This method returns all the ...

Read More
Showing 521–530 of 590 articles
« Prev 1 51 52 53 54 55 59 Next »
Advertisements