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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!