如何使用硒验证textarea中滚动条的存在. [英] How to verify presence of scrollbar in textarea using selenium.

查看:76
本文介绍了如何使用硒验证textarea中滚动条的存在.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在网页中有一个文本区域,最初没有滚动条. 但是,当我的字符数超出1000时,滚动条就会显示在文本区域中.

I have a text area in web page which has no scrollbar initially. But when i exceeds the character by 1000, scrollbar is displayed in the textarea.

当我单击或编辑同一文本区域时,我必须验证是否在文本区域中存在滚动条.

I have to verify the same whether scrollbar is present or not in the textarea when i click or edit the same textarea.

推荐答案

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

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);

这篇关于如何使用硒验证textarea中滚动条的存在.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆