Selenium2Library-Safari未从下拉列表中选择

Selenium2Library-Safari未从下拉列表中选择,safari,robotframework,selenium2library,Safari,Robotframework,Selenium2library,我在一页上有两个下拉列表。当下拉列表2中的项目被选中时,我需要验证下拉列表1中的项目是否添加了“selected”类。下拉列表1中有3个以上的选项,但我想在文章中节省空间。第一块步骤获取列表中所有项目的值,并随机选择一个 第二部分使用在前几个步骤中随机选择的值来定位选项,请参见检查所选类是否为true 以下是HTML: <ol> <li class="select input required" id="message_recipient_input">

我在一页上有两个下拉列表。当下拉列表2中的项目被选中时,我需要验证下拉列表1中的项目是否添加了“selected”类。下拉列表1中有3个以上的选项,但我想在文章中节省空间。第一块步骤获取列表中所有项目的值,并随机选择一个

第二部分使用在前几个步骤中随机选择的值来定位选项,请参见检查所选类是否为true

以下是HTML:

<ol>
     <li class="select input required" id="message_recipient_input">
          <select id="message_recipient_id">
               <option value></option>
               <option value="1">Smith, Bob</option>
               <option value="2">Smith, Steve</option>
               <option value="3">Smith, Joe</option> 
          </select>
     </li>
</ol>

<ol>
     <li class="select input required" id="message_template_input">
          <select id="message_template_id">
               <option value></option>
               <option value="9">Message Template</option>
               <option value="10">Survey Template</option>
               <option value="11">Coupon Template</option> 
          </select>
     </li>
</ol> 

这在Mac OS X上的Chrome和Firefox中运行良好,但Safari没有选择列表中的任何项目。这些步骤就像是在选择它们一样通过,但在“应包含”步骤中失败,因为${selected_recipient}对于所选的类没有任何内容。

您用于Safari的webdriver和版本是什么?@A.Kootstra感谢您的回复。我正在运行Webdriver的3.4.1版。是否有单独的命令来查找Safari的Webdriver版本?在Mac OS Sierra 10.12.4上,我的Safari浏览器版本是10.1,通常使用--help参数或--version来完成。不确定SafariDriver是否确实支持这一点。
${RecipientCount}=      Get Matching Xpath Count        xpath=//*[@id="message_recipient_id"]/option
Log                     ${RecipientCount}
@{ValueList}=           Create List
: FOR       ${INDEX}    IN RANGE       1            ${RecipientCount}
\       ${recipient_value}=        Get Element Attribute    xpath=//*[@id="message_recipient_id"]/option[contains(text(), '@')] [${INDEX}]@value
\       Log                        ${recipient_value}
\       Append To List             ${ValueList}             ${recipient_value}
Log                     ${ValueList}
${recipient}=           Evaluate            random.choice(${ValueList})       random
Log                     ${recipient}
Sleep                   2s
Select From List        id=message_recipient_id       ${recipient}
Sleep                   2s

${message_template_dropdown}=   Select From List By Value       id=message_template_id          9
Sleep                           2s
${selected_recipient}=          Get Element Attribute           xpath=//option[@value=${recipient}] @selected
Log                             ${selected_recipient}
Should Contain                  ${selected_recipient}           true