top of page

getText() method - Python Selenium Automation Testing

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 import Service
from 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

# Maximize the browser window

# Set an implicit wait of 3 seconds to allow elements to be found

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

# Close the browser window

17 views0 comments

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 success message is displayed. package com.seleniumExamples2024; pu

Keyboard shortcut keys for various operations

General Shortcuts: Ctrl + C: Copy Ctrl + X: Cut Ctrl + V: Paste Ctrl + Z: Undo Ctrl + Y: Redo Ctrl + A: Select All Ctrl + S: Save Ctrl + P: Print Ctrl + F: Find Windows Shortcuts: Windows Key: Open or


Noté 0 étoile sur 5.
Pas encore de note

Ajouter une note
bottom of page