So I believe I am able to grab the element via CSS Selector or Xpath and even by TagName but I am unable to grab the text that is associated with it.
Here is what the HTML looks like:
<label for="AnswerText">This is the question text? </label>
In my code I have this:
static IWebDriver driver = new ChromeDriver(".");
static IWebElement securityQuestion = driver.FindElement(By.TagName("label"));
Console.WriteLine("question is ", securityQuestion.Text)
What I want to be able to do is grab this text from the label "This is the question text?". Im doing this because the text changes and depending on the answer the Input will be different so I have to incorporate logic in order to grab that text and set it equal to a variable to match against.
I have tried .Text GetAttribute("value") but that wont work because labels do not have any value as well as different selectors.
static IWebDriver driver = new ChromeDriver(".");
static IWebElement securityQuestion = driver.FindElement(By.TagName("label"));
Console.WriteLine("question is ", securityQuestion.Text)