【问题标题】:Robot Framework unable to find the right address for a linkRobot Framework 无法找到正确的链接地址
【发布时间】:2021-11-26 14:39:20
【问题描述】:

我每天都在手动运行 Corona Jupyter 笔记本,并希望使用 Robot Framework 将其自动化。

代码如下:

Library           RPA.Browser.Selenium

# ...

${result1}=    Open Using Run Dialog    C:/Python/runJupyter.bat    C:\\WINDOWS\\system32\\cmd.exe
Open Browser    http://localhost:8888/?token=c08...    chrome    alias=chrome
Maximize Browser Window
Click Element    //span[contains(text(), 'Corona')]
Sleep    1s
Click Element    //span[contains(text(),"corona.ipynb")]
Sleep    3s
${handle}=    Switch Window    NEW # took me a while to find this
${title}=    Get Title
Log    ${title} # check if the right Tab is active
Pause Execution
# //*[contains(@id,"run_all_cells")] # error
# //a[contains(text(), 'Run All')] # also error
# //a[text()='Run All'] # also error
Click Element    //*[contains(@id,"run_all_cells")] # error
Pause Execution

最后我想Run All笔记本的行数。即使我使用 chrome 检查了 html 代码,xpath 变体都不起作用。我得到的消息是:Message: element not interactable

Run All 的正确 xpath 是什么?

编辑:感兴趣的部分如下所示:

 <li class="dropdown"><a href="#" class="dropdown-toggle" data-toggle="dropdown">Cell</a>
                    <ul id="cell_menu" class="dropdown-menu">
                        <li id="run_cell" title="Run this cell, and move cursor to the next one">
                            <a href="#">Run Cells</a></li>
                        <li id="run_cell_select_below" title="Run this cell, select below">
                            <a href="#">Run Cells and Select Below</a></li>
                        <li id="run_cell_insert_below" title="Run this cell, insert below">
                            <a href="#">Run Cells and Insert Below</a></li>
                        <li id="run_all_cells" title="Run all cells in the notebook">
                            <a href="#">Run All</a></li>
                        <li id="run_all_cells_above" title="Run all cells above (but not including) this cell">
                            <a href="#">Run All Above</a></li>
                        <li id="run_all_cells_below" title="Run this cell and all cells below it">
                            <a href="#">Run All Below</a></li>
                        <li class="divider"></li>

【问题讨论】:

  • 嗯,也许这只是我的配置,但我没有在主页上看到运行所有选项的选项 - 我必须进入单元菜单才能找到它 - 你确定你没有错过吗单击此菜单项的步骤?例如单击元素 //*[@id="celllink"],然后单击元素 //*[@id="run_all_cells"]/a
  • 嗯,不,它不起作用:找不到带有定位器'//*[@id="cellink"]'的元素。在第一个“停止执行”中,我可以手动单击“全部运行”而不关注第一个单元格,因为该命令会执行所有单元格 ;-)
  • 啊,好吧 - 你能显示页面中的一些 html 吗?
  • 我编辑了原始帖子并添加了感兴趣的html部分。
  • 那在下拉菜单里,你打开自动化里面的下拉菜单了吗?我认为它会是 //*[@id="celll_menu"] 或上面的下拉切换之一

标签: selenium jupyter-notebook robotframework


【解决方案1】:

在单击链接元素以“全部运行”之前,还需要一个额外的步骤才能使用Click Element //a[text()='Cell'] 打开下拉菜单

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-12-01
    • 2021-03-21
    • 2018-06-30
    • 1970-01-01
    • 2020-02-18
    • 1970-01-01
    • 1970-01-01
    • 2022-11-01
    相关资源
    最近更新 更多