Write Selenium Test to test text wrapping?
I am trying 开发者_开发问答to write the selenium test using selenium 2.0 for the attached scenario.
HTML code is as follows
<div width="100px" style = "background-color:blue">
This%is%Normal%Text%on%page%without%dynamic%view%and%not%width%set.
</div>
I need to verify whether text is wrapping or not. Text should wrap in the 2nd scenario
Any help would be appreciated.
Thanks, Sahil
I'm afraid it goes too deep to browser's internals so it is not possible with Selenium. Maybe you can check the height ow wrapping element (div) if it exceeds height of line, but it looks fragile to me.
May be should try the url encode/uncode to see if that particular text is encoded or not?
You can check if the text is overflowed.
public boolean isElementOverflowed(CoreLocator element) {
return (boolean) coreDriver.executeScript("return arguments[0].scrollWidth > arguments[0].clientWidth",
element.getWebElement());
}
and call it in your code.
精彩评论