【问题标题】:Selecting radiobutton which is available after javascript execution选择javascript执行后可用的单选按钮
【发布时间】:2019-07-25 19:16:15
【问题描述】:

我的测试用例是预约。问题是,我必须选择的所需单选按钮(表单强制)可通过 javascript 函数getTimeSlots()

这是带有功能和输出的 webdeveloper 控制台

这里的 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)
------------------------------------------------------------------------------

如何使用robotframework来选择这个单选按钮?

【问题讨论】:

    标签: javascript automation robotframework


    【解决方案1】:

    嗯,出现此错误的原因有多种。一般来说,这意味着 DOM 的状态在交互之间发生了变化。由于 SeleniumLibrary 3.3Wait Until 开头的关键字不会因为此错误而失败。您可以尝试等到元素出现,然后单击它。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-02-27
      • 1970-01-01
      • 1970-01-01
      • 2019-06-06
      • 2023-03-29
      • 1970-01-01
      相关资源
      最近更新 更多