你能提供一个脚本,我可以获得值“3”并存储在一个字段中吗?验证销售数量,此数字每次都会更改。
这是Obj Rep
"Class Name:=WebElement",
"abs_x:=24",
"abs_y:=177",
"acc_name:=",
"class:=indicator",
"height:=67",
"html id:=",
"html tag:=DIV",
"innerhtml:=3",
"innertext:=3",
"outerhtml:=<div class=""indicator"" _ngcontent-c7="""">3</div>",
"outertext:=3",
"role:=",
"title:=",
"type:=",
"visible:=True",
"width:=54",
"x:=24",
"xpath:=//DIV\[@id=""number of sales""\]/DIV\[1\]/DIV\[1\]/DIV\[1\]/DIV\[1\]",
"y:=177"
首先,您必须从OR对象属性中删除innertext和innerhtml。然后使用GetROProperty
从应用程序中检索值。
Browser().Page().WebElement().GetROProperty("innertext")
顺便说一句,如果你提到问题中提到的所有属性作为部分或对象识别策略,你必须认真考虑更新它。我想你可以删除除class
或xpath
之外的所有内容,它们将唯一地标识该元素。
如果您不从OR对象标识属性中删除innertext和innerhtml,那么如果将来3
的数字发生变化,您的测试将会失败。如果您仍想维护所有属性,那么您只需检查元素上的.exists
以验证文本=3
,因为webelement本身具有innertext:3