无法识别Selenium中的元素

时间:2013-11-04 08:24:46

标签: html xpath selenium selenium-webdriver

我正在尝试验证文字。尝试了以下xpath但仍显示无法识别元素错误。

  1. //*[@id='bodyPartList_1']/li[1]/div
  2. //div[@id='question_1_5' and contains(@span,'Does the patient weigh over 350lbs?')]
  3. 元素的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 个答案:

答案 0 :(得分:0)

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

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

我假设缺少的结尾div在第3行。

相关问题