Question
Using Selenium in Java, how to getText() of a complicated element? consider following case: What is Max 's age? I am comparing it with
Using Selenium in Java, how to getText() of a complicated element?
consider following case:
"What is "
"Max"
"'s age?"
I am comparing it with the file that contains the same label "What is Max's age".
The developer have made it this way because the name "Max", changes depending on user's first name. Following is the xpath I have used to locate, "//h1[@class = "label-heading"], this works but is there a way I can call the label without using class name and h1. I have tried, "//*[text() = "What is Max's age"]. This does not work as the text in html is in 3 separate line but is there an alternative way I could get the label without using class name and h1?
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started