Author - StudySection Post Views - 113 views
Selenium testing python

Testing Of Links With Selenium Tool In Python

In this content, we will perform Selenium testing on links that are present on the web page. Some operations to be performed on the web page for testing the given links are:

  1. The first operation is to find out all links that are present on the web page.
  2. The second operation is to Capture the link.
  3. The third operation is to Click on the link.

from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common import keys

driver=webdriver.Chrome(executable_path="C:\\Users\\91798\\Desktop\\selinium\\chromedriver.exe")
driver.get("https://products.winsurtech.com/")
driver.maximize_window()
links=driver.find_elements(By.TAG_NAME,'a')
print(len(links))
for link in links:
print(link)

The above code will print the total number of links present on the web page https://products.winsurtech.com/ and will also print the test of those links. The output is shown below with web page:

winsurtech-product

selenium

If we will use ‘link.text’ instead of ‘link’ then it will print the provided text of links on the web page as shown.

To perform a click operation on the given link we will use this command:

aboutus=driver.find_element(By.LINK_TEXT,"About Us").click()

This command will capture the link text ‘About Us’ on the web page and will perform a click operation on it. We can also use partial link text by using the given command.
aboutus=driver.find_element(By.PARTIAL_LINK_TEXT,"About").click()

This command also performs the click operation on the About Us link on the web page.
This will show the two output tabs in the same window as shown in which the first tab is a parent and the second is the ’About Us’ page of the parent web page.
winsurtech-product

Study Section provides a big list of certification exams through its online platform. The French Certification Exam can help you to certify your skills to communicate in the French language. Whether you are new to the language or you are an expert in it, this French certification exam can test the ability of anybody’s command over the French language.

Leave a Reply

Your email address will not be published. Required fields are marked *

fiteesports.com rivierarw.com cratosroyalbet betwoon grandpashabet grandpashabet giriş deneme bonusu veren siteler casino siteleri