处理 span 标签中的动态文本更改

Handling dynamic text change in span tag

单击提交按钮后,我收到以下两条消息之一:

1) 说明找到的信息。请确认订单PO001007后再推送。

2) 订单号理货推送 - PO001008 成功

对于成功条件,我使用的是这个 xpath:

.//*[@id='wrap']/div[2]/div[2]/div/div[4]/span[text()='Tally push of order no - PO001008 successful']

但是里面的文字每次都在变化,所以如果我使用这个 xpath:

.//*[@id='wrap']/div[2]/div[2]/div/div[4]/span

即使失败的条件也会通过。有人知道如何处理 span 标签内的动态文本更改吗?

下面是我的 html 成功和失败条件代码:

<div class="alert alert-info alert-dismissable">
<button class="close" type="button" data-dismiss="alert" aria-hidden="true">×</button>
<span>Invalid states information found. Please verify the order PO001007 and then push.</span>
</div>
-----------------------------------------

<div class="alert alert-info alert-dismissable">
<button class="close" type="button" data-dismiss="alert" aria-hidden="true">×</button>
<span>Tally push of order no - PO001008 successful</span>
</div>

你必须使用这个 xpath

试试这个:

对于不成功的订单使用这个

 ///button[@class='close']/following::span[contains(text(),'Invalid')]

为了成功订购使用这个

//button[@class='close']/following::span[contains(text(),'order no')]