Selenium webdriver SeleniumWebDriver中的动态文本

Selenium webdriver SeleniumWebDriver中的动态文本,selenium-webdriver,dynamic-text,Selenium Webdriver,Dynamic Text,我正在自动化一个web应用程序,在某一点上需要帮助 甚至当我登录到web应用程序时。它要求输入用户名(经理id),然后经理id在主页上不断闪烁。使用不同的登录凭据更改管理器id 所以我需要继续检查经理的身份证 <tr> <td> <center> <table width="100%" align="center"> <tbody> <tr/> <!--comments: To link all the scree

我正在自动化一个web应用程序,在某一点上需要帮助

甚至当我登录到web应用程序时。它要求输入用户名(经理id),然后经理id在主页上不断闪烁。使用不同的登录凭据更改管理器id

所以我需要继续检查经理的身份证

<tr>
<td>
<center>
<table width="100%" align="center">
<tbody>
<tr/>
<!--comments: To link all the screens-->
<tr>
<tr class="heading3" align="center">

<td style="color: green">Manger Id : mngr8499</td>

</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</body>


经理编号:mngr8499

据我所知,我将使用.getText()方法获取td中的4个字符,使用:

driver.findElement(By.cssSelector(".heading3 > td")).getText().substring(17);

如果您关注的是HTML的刷新,请考虑使用:

WebDriverWait wait = new WebDriverWait(driver, 10)
wait.until(ExpectedConditions.stalenessOf(By.cssSelector(".heading3 > td"));

当前一个值从DOM中退出时,您可以使用新的选择器来获取刷新后的值。

据我所知,在使用getText()之后您可以获得管理器Id:mngr8499,但您不希望每次管理器Id都包含文本且仅包含Id。我的实现是首先将文本复制到any String变量中,然后使用String.replaceAll()方法,我可以获得所需的文本

以下是相同的实施,如果我理解错误,请让我知道

WebElement mngrid = driver.findElement(By.xpath("//tr[@class='heading3']/td"));
String actual_text = mngrid.getText();
actual_text= actual_text.replace("Manger Id :"," ");
System.out.println(actual_text);

你在用什么语言?谢谢鲁佩什,你的理解是正确的,解决了我的问题。