html - Selenium: Test if text is fully visible -
is there way check selenium if text visible? let's have text
lorum ipsum dolor sit amet
and due bad css reads
lorem ips
on page, rest under wrongly placed div. there way assert full text visible?
here's simple example using jsfiddle created , java/selenium.
the html
<p id="1">lorum ipsum dolor sit amet</p> <p id="2">lorum ipsum <div style="display:none">dolor sit amet</div></p>
the code
string expectedstring = "lorum ipsum dolor sit amet"; webdriver driver = new firefoxdriver(); driver.get("https://jsfiddle.net/jeffc/t7scm8tg/1/"); driver.switchto().frame("result"); string actual1 = driver.findelement(by.id("1")).gettext().trim(); string actual2 = driver.findelement(by.id("2")).gettext().trim(); system.out.println("actual1: " + actual1); system.out.println("actual2: " + actual2); system.out.println("pass: " + expectedstring.equals(actual1)); system.out.println("pass: " + expectedstring.equals(actual2));
the output
actual1: lorum ipsum dolor sit amet actual2: lorum ipsum pass: true pass: false
selenium won't return text isn't visible user need compare expected string. if aren't equal, text hidden.
Comments
Post a Comment