【问题标题】:Selenium IDE DropDownSelenium IDE 下拉菜单
【发布时间】:2017-05-17 05:35:40
【问题描述】:

谁能帮帮我。我正在尝试使用 selenium IDE 从下拉列表中选择一个选项,但不能。下面是 HTML。我尝试在目标中使用带有 xpath 的“选择”命令,但无法从选项中进行选择

               <select id="age" class="default chzn-done"onfocus="javascript:setOmnitureFallout('birthdate');"name="ctl00$ContentPlaceHolder1$age" style="display: block; visibility: hidden;" tabindex="21">
                 <option value="0">0 - 11 months</option>
                 <option value="1">1 year</option>
                 <option value="2">2 years</option>
                 <option value="3">3 years</option>
                 </select>
                    <div id="age_chzn" class="chzn-container chzn-container-single chzn-container-active" style="width: 200px;" tabindex="21">
                     <a class="chzn-single" tabindex="-1">
                      <span style="background-color: transparent;">2 years</span>
                      <div>
                          <b/>
                         </div>
                          </a>
           <div class="chzn-drop" style="left: -9000px; width: 198px; top: 41px;">
          <div class="chzn-search" style="">
           <ul class="chzn-results">
           <li id="age_chzn_o_0" class="active-result" style="">Select one</li>
           <li id="age_chzn_o_1" class="active-result" style="">0 - 11 months</li>
               <li id="age_chzn_o_2" class="active-result" style="">1 year</li>
        <li id="age_chzn_o_3" class="active-result result-selected" style="">2 years</li> 
        <li id="age_chzn_o_4" class="active-result" style="">3 years</li>
</ul>

【问题讨论】:

  • 以下不是 HTML :D 请附上 HTML。我相信你忘了这样做
  • 根据要求,请提供您尝试过的 HTML 和 selenese。另外,请参阅此处E:stackoverflow.com/questions/6314330/…

标签: selenium-ide


【解决方案1】:

这就是我如何使用“select”命令一般

Using select command

对于选择元素定位器,我通常使用 xpath,对于选项定位器,我将使用可以指定为正则表达式的标签。例如:

label=regexp:^This_Matches_the_Option_I_want_to_Select$

希望这会有所帮助。

如果您发布您正在处理的页面的html代码片段和您已经编写的代码,我们可以给您更具体的答案。

如果您有任何问题,请告诉我。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-03-26
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多