For example, in this line of code I need the "x + 10 = 10". Does anyone know how to do it?
<span class="task" onclick="loadExercise(201)" id="task201">x+10=10</span>
For example, in this line of code I need the "x + 10 = 10". Does anyone know how to do it?
<span class="task" onclick="loadExercise(201)" id="task201">x+10=10</span>
If you are using python for example you can use .text:
name = driver.find_element_by_id("task201").text
print (name)
x+10=10
I think that's how it works:
var elemento = browser.FindElement(By.Id("task201")).Text;
or
var elemento = browser.FindElement(By.Id("task201")).GetAttribute("innerText");
You first need to identify if the element is dynamic or it is part of a list and every time it appears it may be in a different location, the most common and safe way to capture text is like this:
texto String;
texto = driver.findElemnt(By.xpath(//span [text()='x+10=10'])).text; //desta forma ele vai localizar o texto mesmo que ele mude de posição na pagina