C# Selenium Webdriver - Getting the text of a label
I am a novice with Selenium. If you provide an answer, try to keep the answer in simple terms.
I have been doing well with making some generic functions for the web controls (e.g., text box, combo box). I am stuck with trying to understand how to capture the text of a label. I cannot be sure where the label be located (i.e., in a table or outside of a table). Is there a generic way of getting the text? Otherwise, what are the factors I should be looking at to capture the text?
Thanks in a advance.
If you are able to identify the element, then use getText() method like below,
sData = myTestDriver.findElement(By.xpath("//label[@for='Email']")).getText();
Would XPath also be a solution if the label was just lingering between 2 html tags like this: <h3> You last logged on 1/1/2016 3:20pm </h3>
Tags for this Thread