【发布时间】:2020-03-23 11:13:42
【问题描述】:
我正在尝试以编程方式从从远程数据填充的 select2 下拉列表中选择一个项目。
这里有几个基于 select2 的演示页面的测试用例:
*** Settings ***
Library Selenium2Library
*** Variables ***
${URL} https://select2.github.io/examples.html
${BROWSER} Chrome
*** Test Cases ***
Test select2 input with click
Open browser ${URL} ${BROWSER}
Wait Until Page Contains Loading remote data
Click Element xpath=/html/body/div/div/div[1]/section[3]/p[4]/span
Input Text xpath=/html/body/span/span/span[1]/input robotframework
Wait Until Page Contains Generic test automation
Click Element xpath=//*[@id="select2-aiw0-results"]/li
Test select2 input with select from
Open browser ${URL} ${BROWSER}
Wait Until Page Contains Loading remote data
Click Element xpath=/html/body/div/div/div[1]/section[3]/p[4]/span
Input Text xpath=/html/body/span/span/span[1]/input robotframework
Wait Until Page Contains Generic test automation
Select From List By Index xpath=/html/body/span 0
本意是从“Loading remote data”部分打开select2输入,输入“robotframework”,最后选择robotframework项。这是我无法弄清楚如何正确执行的最新操作。这是我从 Robot Framework 得到的输出:
$ robot select2.robot
==============================================================================
Select2
==============================================================================
Test select2 input with click | FAIL |
ValueError: Element locator 'xpath=//*[@id="select2-aiw0-results"]/li' did not match any elements.
------------------------------------------------------------------------------
Test select2 input with select from | FAIL |
ValueError: Element locator 'xpath=/html/body/span' did not match any elements.
------------------------------------------------------------------------------
Select2 | FAIL |
2 critical tests, 0 passed, 2 failed
2 tests total, 0 passed, 2 failed
==============================================================================
Output: /home/al/essai/robotframework/output.xml
Log: /home/al/essai/robotframework/log.html
Report: /home/al/essai/robotframework/report.html
我使用 Chrome 和 Firefox 得到相同的结果。
【问题讨论】: