2013-11-04 133 views
1

我正在尝试验证文本。尝试了以下xpath,但它仍然显示无法识别元素错误。无法识别Se中的元素

  1. //*[@id='bodyPartList_1']/li[1]/div
  2. //div[@id='question_1_5' and contains(@span,'Does the patient weigh over 350lbs?')]

的元素HTML源:

<div id="question_1_5" class="qaContainer"> 
    <input type="hidden" name="questionIds[]" value="5"/> 
    <div class="left" style="width: 680px;"> 
    <span class="num">1.</span> 
    <span class="ans" style="width: 650px;">              
           Does the patient weigh over 350lbs?</span> 
</div> 
+1

你能粘贴代码和堆栈跟踪? – Amith

+4

请显示与您的XPath相匹配的HTML代码(其中'bodyPartList_1'和'li'?),还会显示您的堆栈跟踪和完整的异常消息。顺便说一句,你的第二个XPath是不正确的。 –

+0

文字'病人体重超过350磅吗?'是的孩子。同样在你的HTML源代码中,''div class =“left”style =“width:680px;”>'没有关闭。请发布正确的HTML。 –

回答

0

第1部分是缺少相关的HTML。 在第二部分中,contains函数有两个参数,它们都必须是字符串。

//div[@id='question_1_5' and contains(span[2]/text(),'Does the patient weigh over 350lbs?')] 

我假设缺少结束的div是在第3行

+0

不,它不工作。它显示错误:FAIL对象未找到无法找到元素 – user2943890

+0

你有没有添加结束div? – resigned

相关问题