I have a registration page.
In my test, I'm trying to register without a first name. Pressing the register button should display the a 'Required' notification label.
You can see the structure in the attached screenshot.
I tried to get the text from the id 'firstName'
by xpath, id, etc. It failed to locate this object.
My latest attempt:
String test = driver.findElement(By.id("'firstName'/descendant::td[@class='alert alert-danger']")).getText();`
What am I missing?
Try By.cssSelector("#firstName + registration-control-messages > div.alert")
The By
you are using is not correct.