我的测试用例是预约。问题是,我必须选择的必需单选按钮(对表单是强制性的)可以通过JavaScript函数getTimeSlots()
在这里,WebDeveloper控制台向我显示了约会页面的单选按钮
在我的理解中,我转到约会页面,执行javascript并选择单选按钮并提交表格。但这是行不通的。
Book appointment
[Tags] appointment
Input Text id:foo here is bar
Input Text id:bar here is more bar
Click Element id:requested_date
# Get date out of the datepicker
${current_date_noon} = Get Current Date result_format=%Y-%m-%d 00:00:00
${date_in_7d} = Add Time To Date ${current_date_noon} 7 days
${unixtime} = get time epoch ${date_in_7d}
${data_format} = Set Variable ${unixtime}000
Click Element xpath=//td[@data-date="${data_format}"]
# FIXME Here I try to select the radiobutton
Execute Javascript window.getTimeSlots()
#Select Radio button requested_time 19:00 - 19:30
Click Element name:requested_time
Capture Page Screenshot Screenshot-termin-buchen-{index}.png
Submit Form
运行代码时,我在控制台中得到以下结果
------------------------------------------------------------------------------
Book appointment | FAIL |
StaleElementReferenceException: Message: stale element reference: element is not attached to the page document
(Session info: chrome=72.0.3626.109)
(Driver info: chromedriver=2.42.591071 (0b695ff80972cc1a65a5cd643186d2ae582cd4ac),platform=Linux 4.9.49-moby x86_64)
------------------------------------------------------------------------------
如何使用机械手框架选择此单选按钮?
答案 0 :(得分:0)
好吧,出现此错误有多种原因。通常,这意味着交互之间DOM的状态发生了变化。由于以SeleniumLibrary 3.3开头的关键字Wait Until
不会因此错误而失败。您可以尝试等到元素存在,然后单击它。