Robot Framework 无法找到 link 的正确地址
Robot Framework unable to find the right address for a link
我 运行 每天手动使用 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 变体的 None 仍然有效。我收到的消息是: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>
在单击 link 元素到“运行 全部”之前,需要一个额外的步骤来使用 Click Element //a[text()='Cell']
打开下拉菜单
我 运行 每天手动使用 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 变体的 None 仍然有效。我收到的消息是: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>
在单击 link 元素到“运行 全部”之前,需要一个额外的步骤来使用 Click Element //a[text()='Cell']
打开下拉菜单