试图找到span元素内的特定文本,这些文本将用作成功测试的基础,但无法使其正常工作。有人可以帮忙吗? 我想再次在span范围内检索文本,作为证明我要查找的更新已完成的基础(在我之前的代码中,该更新文本已发布到记录中)
我的代码如下-
# Check for the update
check_work_info = driver.find_element(By.XPATH, "//*/span[contains(text(),'AUTOMATED TESTING INCIDENT CREATE 2018-10-18')]")
print(check_work_info)
引发的错误是-
selenium.common.exceptions.NoSuchElementException:消息:无法 定位元素:// * / span [contains(text(),'AUTOMATED TESTING INCIDENT 创建2018-10-18')]
源代码的HTML片段-
<div class="sn-card-component sn-card-component_summary sn-card-component_summary_spacing ng-scope" ng-repeat="journal in ::entry.entries.journal">
<div class="sn-widget sn-widget-textblock state-expanded" ng-class="{ 'state-expanded': journal.showMore || expandEntries }">
<span class="sn-widget-textblock-body sn-widget-textblock-body_formatted ng-binding" ng-bind-html="parseSpecial(journal.new_value)">AUTOMATED TESTING INCIDENT UPDATE 2018-10-18</span>
<!-- ngIf: ::journal.is_truncated -->
</div>
<!-- ngIf: ::journal.new_value.length > 200 -->
<!-- ngIf: ::journal.new_value.length > 200 -->
</div>
<div class="sn-widget sn-widget-textblock state-expanded" ng-class="{ 'state-expanded': journal.showMore || expandEntries }">
<span class="sn-widget-textblock-body sn-widget-textblock-body_formatted ng-binding" ng-bind-html="parseSpecial(journal.new_value)">AUTOMATED TESTING INCIDENT UPDATE 2018-10-18</span>
<!-- ngIf: ::journal.is_truncated --></div>
<span class="sn-widget-textblock-body sn-widget-textblock-body_formatted ng-binding" ng-bind-html="parseSpecial(journal.new_value)">AUTOMATED TESTING INCIDENT UPDATE 2018-10-18</span>
答案 0 :(得分:0)
// * / span [包含(text(),'AUTOMATED')]