且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何使用硒验证textarea中滚动条的存在.

更新时间:2023-01-14 08:28:13

如果添加滚动条,则客户端的宽度或高度将减小.因此,一种方法是检查之前和之后的大小.

The client width or height will decrease if a scrollbar is added. So one way would be to check the size before and after.

这是一个示例(Java):

Here's an example (Java) :

Long height_before  = Long.parseLong(element.getAttribute("clientHeight"));
element.sendKeys("wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww")
Long height_after  = Long.parseLong(element.getAttribute("clientHeight"));

Assert.True((height_before - height_after) > 10);

或者:

Long clientHeight  = Long.parseLong(element.getAttribute("clientHeight"));
Long offsetHeight  = Long.parseLong(element.getAttribute("offsetHeight"));

Assert.True((offsetHeight - clientHeight) > 10);