top of page
back.jpg

getText() method - Python Selenium Automation Testing

crystgandhi

What is the role of the `getText` method and how this method is utilized to fetch and display the text content from webelement

# Import necessary libraries
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.common.by import By

# Create a Service object for the Chrome browser
service_obj = Service()

# Initialize the Chrome WebDriver with the created Service
driver = webdriver.Chrome(service=service_obj)

# Open the specified website
driver.get("https://the-internet.herokuapp.com/")

# Maximize the browser window
driver.maximize_window()

# Set an implicit wait of 3 seconds to allow elements to be found
driver.implicitly_wait(3)

# Find and print the text of the first <h1> element on the page
h1_element_text = driver.find_element(By.TAG_NAME, "h1").text
print(h1_element_text)

# Close the browser window
driver.quit()

Recent Posts

See All

Test case for Valid Coupon Code

This test case checks whether a valid coupon code is successfully applied to a booking cart, the total is updated accordingly, and a...

Comments

Rated 0 out of 5 stars.
No ratings yet

Add a rating
  • Facebook
  • Twitter
  • LinkedIn

©2019 by MGNK Junction - Junction to uplift your life

bottom of page