我有一个问题,因为我不知道如何检查或搜索一个文本(字符串)是否包含在一个列表的子元素中。
<div class="father_class">
<div class="child">
<div class="Elements">Profile</div>
</div>
<div class="child">
<div class="Elements">Settings</div>
</div>
</div>
我想在 "father_class "上搜索是否有任何 "子 "类有文本Profile(作为一个字符串输入).我已经尝试用下面的代码(Cucumber on Java for Selenium),但它不可能包含Profile作为一个字符串。
@FindBy (className="father_class")
private WebElementFacade Father
Father.containsElements(By.xpath("//div[@class='child']/div[contains(text(), 'Profile')]"));
但这里的问题是这个 "Profile "并没有输入我想要的字符串。
@FindBy (className="father_class")
private WebElementFacade Father
String var = "Profile"
Father.containsElements(By.xpath("//div[@class='child']/div[contains(text(), var)]"));
谢谢你,我有个问题