如何从输入标签获取文本? [英] How to get text from input tag?

查看:78
本文介绍了如何从输入标签获取文本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在某些情况下,我必须从input标记获取文本,例如-

I've a case where I've to get the text from input tag which is something like -

<input id="AB_WIN_1" class="text real" type="text" ds="0" style="top:0px; left:167px; width:140px; height:21px;"/>

该输入标签中的文本是某些文本,例如Hello

And the text in that input tag is some text say Hello

但是当我使用getText时,它什么也不返回.

But when I use getText, it returns nothing.

反正我可以从input标记中获取文字吗?

Is there anyway I can get text from input tag?

推荐答案

您可以使用以下任意一种方式:

you can use any of the below:

1. element.getAttribute("value")
2. element.getAttribute("innerHTML")
3. element.getAttribute("innerText")
4. element.getText()
5. ((JavascriptExecutor)driver)execute.script("return arguments[0].value",element)

让我知道这是否无济于事.

Let me know if this does not helps.

这篇关于如何从输入标签获取文本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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