Text Assertions
Learn how to assert text using Selenium and try it out yourself.
Assert label
text
Label tags are commonly used in web pages to wrap some text like:
<label id="receipt_number">NB123454</label>
It is very useful to assert such texts from time to time. We can do so by:
driver.findElement(By.id("label_1")).getText().then(function(the_elem_text) {assert.equal("First Label", the_elem_text);});
...