Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/xpath/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用Xpath查找值_Xpath_Capybara - Fatal编程技术网

使用Xpath查找值

使用Xpath查找值,xpath,capybara,Xpath,Capybara,我需要使用Xpath获取所选单选按钮的值(82)。我不熟悉Xpath。如何使用Xpath获取文本 <label id="thankyou_label" class="itemName radio" for="thankyou_radio"> <input id="thankyou_radio" class="cardFilterItemSelection" type="radio" name="occasionGroup" value="Thank You" tagtype="

我需要使用Xpath获取所选单选按钮的值(82)。我不熟悉Xpath。如何使用Xpath获取文本

<label id="thankyou_label" class="itemName radio" for="thankyou_radio">
<input id="thankyou_radio" class="cardFilterItemSelection" type="radio" name="occasionGroup" value="Thank You" tagtype="Occasion" checked="checked">
<span class="occasion_display_name">Thank You </span>
<span class="itemCount">(82)</span>
</label>

非常感谢。
(82)

这里可以使用的xpath是:

//input[@class = 'cardFilterItemSelection' and @checked = 'checked']/following-sibling::span[@class = 'itemCount']/text()

这里可以使用的xpath是:

//input[@class = 'cardFilterItemSelection' and @checked = 'checked']/following-sibling::span[@class = 'itemCount']/text()

请尝试此操作。您可以在不使用xpath的情况下使用以下代码。干杯

   page.find('.itemCount').text

请尝试此操作。您可以在不使用xpath的情况下使用以下代码。干杯

   page.find('.itemCount').text