简体   繁体   English

如何获取显示来自后端值的输入框的文本

[英]How to get the text of a input box which is showing value from backend

I am using selenium webdriver. 我正在使用Selenium WebDriver。 My test case is Select a address on shipping page which inturn shows the details of the address in different fields below. 我的测试案例是在运送页面上选择一个地址,该地址依次在下面的不同字段中显示该地址的详细信息。 Now I want to check whatever the text is coming on those field is correct or not? 现在,我想检查在这些字段上输入的文字是否正确? Problem is niether it is coming as a text nor a value on that particular field. 问题在于它既不是文本,也不是特定领域的价值。 So get text or getattribute ("value") is not working. 因此,获取文本或getattribute(“值”)不起作用。 It is coming from javascript written on it and I am not able to inspect it. 它来自上面写的javascript,我无法检查。 Please help 请帮忙

Actually, I figured out. 实际上,我知道了。 The field was showing values fetched by javascript so I ran the same javascript using javascript executor. 该字段显示的是由javascript获取的值,因此我使用javascript执行程序运行了相同的javascript。

JavascriptExecutor js=(JavascriptExecutor)driver; 
String val = (String) js.executeScript("return $(\".id of field.val()");

then used val for my function. 然后用val作为我的功能。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM