xpath在没有任何内容的div元素中查找伪元素:: after [英] xpath to find pseudo-element ::after in side a div element with out any content
问题描述
我正在尝试编写xpath来查找是否已选中的复选框,正在使用css :: after元素更改此复选框.以下是我拥有的两个元素
I am trying to write xpath to find a checkbox selected or not, this checkbox is being changed using css ::after element. Below are two elements I have
//div[@class='FormBlock-formItem2' and .//text()='Scoped In']//div[@class='FormBlock-controlIndicator']
我需要找到未选择作用域外"和作用域内"的情况.我看到的唯一区别是复选框第二部分中的':: after'. 我尝试了xpath:"//div [@ class ='FormBlock-formItem2'和.//text()='作用域为']//div [@ class ='FormBlock-controlIndicator'] ",但这是在查找"Scoped In"元素,但我无法验证是否选中了该元素.挣扎了几天.请帮助.
I need to find that 'Scoped Out' is not selected and 'Scoped In' is selected. The only difference I see is '::after' in the second section of checkbox. I tried the xpath :" //div[@class='FormBlock-formItem2' and .//text()='Scoped In']//div[@class='FormBlock-controlIndicator'] " but this is finding the 'Scoped In' element but I am not able to verify if its checked or not. Struggling from couple of days. Kindly help.
推荐答案
如果返回正确的是/否,请检查下面的代码:
Check code below if return correct true/false:
driver.findElement(By.xpath("//label[./div[@class='FormBlock-itemText' and .='Scope In']]/input")).isSelected();
这篇关于xpath在没有任何内容的div元素中查找伪元素:: after的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!