English 中文(简体)
在选定无线电台旁边的冲绳,在瓦里使用Xpath
原标题:Obtaining stray text adjacent to selected radio button using xpath in watir
  • 时间:2011-11-21 17:36:01
  •  标签:
  • xpath
  • watir

我在无线电台塔顿集团的无线电台旁边有一些直线文字。 我试图用xpath和watir来获取,但我没有幸运。 此处为某些超文本样本

<html> 
<head></head> 
<body> 
 <input type="radio" name="options" value="No">No <br />
 <input type="radio" name="options" value="Yes">Yes <br />
 <input type="radio" name="options" value="Maybe">Maybe <br />
</body> 
</html> 

我可以通过Xpath获得选定的无线电塔顿。

selectedRadio = browser.radio(:xpath,"//input[@checked and @name= options ]")

我如何获得发言权 是的, 是否选择相应的无线电台? 我也试图利用Watir获得,但文字方法不会在Watir:RadioButton物体上工作,因为这些文本是一纸空文。

Thanks in advance.

最佳回答

提供的这种超文本不通XML,因此,我认为,这一表述将取决于放弃如何使投入落空。 如果委员会认为案文是<条码>输入/编码>要素中的一种儿童,就如:

<input type="radio" name="options" checked="checked" value="No">No </input><br />
<input type="radio" name="options" value="Yes">Yes </input><br />
<input type="radio" name="options" value="Maybe">Maybe </input><br />

Then use this expression:

//input[@checked and @name= options ]/text()

而另一方面,如果它自动关闭< 输入/编码>,并将该文本视为一个兄弟,就如:

<input type="radio" name="options" checked="checked" value="No"/>No <br />
<input type="radio" name="options" value="Yes"/>Yes <br />
<input type="radio" name="options" value="Maybe"/>Maybe <br />

Then use the following expression:

//input[@checked and @name= options ]/following-sibling::text()[1]

My guess is that this second one is the correct one, since you already said that .text did not work.

问题回答




相关问题
VTD XML inner XPath Expressions

I have a xml file for example like this <root> <test> <bla>test1</bla> </test> <test> <bla>test2</bla> </test> <test> </test&...

C# XML adding/copying

With the following XML I am trying to copy and add to another XML but I haven t used the C# XML document objects before. So here is the XML <config> <configXML> <Connections&...

Filter SQL queries on the XML column using XPath/XQuery

I m having a table with one XML column. I d like to filter out the rows where a specific attribute in the XML match a string, essentially doing a WHERE or HAVING. The table looks something like this ...

Python XPath Result displaying only []

Hey I have just started to use Python recently and I want to use it with a bit of xPath, the thing is when I print the result of the query I only get [] and I don t know why =S import libxml2, ...

热门标签