机器人框架没有通过xpath正确找到元素
机器人框架没有通过xpath标识元素。机器人框架没有通过xpath正确找到元素
以下是
<div id="sticky-actions-sticky-wrapper" class="sticky-wrapper" style="height: 100px;"><section class="content-header" id="sticky-actions" style=""> <h1>Curriculum</h1>
<div class="breadcrumb save-message hidden">
<label class="text-success">
<i class="flaticon flaticon-circle-check"></i>
Saved <span>a few seconds ago</span>
</label>
</div>
<div class="row p-t-15">
<div class="col-xs-12">
<button type="button" class="btn btn-primary add-task-btn" disabled="">Create New Task</button>
<div class="btn-group m-r-15">
<button type="button" class="btn btn-primary dropdown-toggle add-statement-btn" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" style="">
Create <span class="caret"></span>
</button>
<ul class="dropdown-menu">
<li><a tabindex="0" class="add-curriculum-btn">Curriculum</a></li>
<li><a tabindex="0" class="add-learning-area-btn hidden">Learning Area</a></li>
<li><a tabindex="0" class="add-topic-btn hidden">Topic</a></li>
<li><a tabindex="0" class="add-outcome-btn hidden">Outcome</a></li>
</ul>
</div>
<button type="button" class="btn btn-circle btn-xs blue link-statements-btn" disabled="" data-toggle="tooltip" data-placement="top" title="" data-original-title="Link selected statements">
<i class="fa fa-link"></i>
</button>
</div>
</div>
</section></div>
的Xpath我曾经发现代码 “创建” 按钮:
的XPath = // * [@ ID = “粘行动粘性,包装” ]/div [2]/div/div/button
xpath = // * [@ id =“sticky-actions”]/div [2]/div/div/button [.// text()= '创建']
机器人框架步骤:
click element xpath=//*[@id="sticky-actions-sticky-wrapper"]/div[2]/div/div/button
错误: -
ValueError异常:元素定位器“的xpath = // * [@ ID = “粘性动作粘性-包装”] /格[2 ]/div/div/button'与任何元素都不匹配。
回答:
根据您的XML,第一个div
中有一个section
元素,它没有包含在XPath中。
//*[@id="sticky-actions-sticky-wrapper"]/section/div[2]/div/div/button
或
//*[@id="sticky-actions"]/div[2]/section/div/div/button[.//text() = 'Create']
以上是 机器人框架没有通过xpath正确找到元素 的全部内容, 来源链接: utcz.com/qa/262951.html