我需要知道以下html代码的Xpath :这里我想要的是检测4x6文本,首先返回到输入,选择单选按钮
<div class="span-5 prepend-01 prepend-top last format">
<h5 style="color:#41393b;font-weight:bold">Select your Size</h5>
<div class="size-info">
<input type="radio" value="http://www.staging.photojaanic.com/productdesign/5/10104" checked="checked" name="selection"/>
4x6
<span class="right">Rs.3.45*</span>
<br/>我写了下面的xpath//div[contains(text(),'4x6')],但它没有选择文本,它只选择了完整的input,有人能建议我如何实现它吗?
发布于 2015-08-11 20:03:53
“如何使用xpath从子节点切换回父节点?”
使用parent::* (或使用相同的快捷方式:..)或ancestor::*,这取决于您所说的parent的实际含义。但我看不出这个标题与你问题正文中的描述有什么关系。另一件事是,//div[contains(text(),'4x6')]只检查当前div中的第一个文本节点。要检查所有文本节点,请改用以下内容://div[text()[contains(.,'4x6')]]
“这里我想要的是检测4x6文本,首先返回到输入,选择单选按钮”
仍然很难理解您说这句话到底是什么意思,但是如果您想选择文本"4x6"之前的input元素,那么您可以尝试如下所示:
//text()[contains(.,'4x6')]/preceding-sibling::input[1]https://stackoverflow.com/questions/31941095
复制相似问题