自动化校验时,可能有些时候需要校验生成的值,如销售机会编号,每次生成时都是不一样的;所以我们需要提取出他们

 

assertTrue("SL17-001100".indexOf(driver.findElement(By.xpath("//*[@id='salesOpportunitiesListShow']/tr/td[1]/a")).getText())>=0);

 

假设后面的driver.findElement(By.xpath("//*[@id='salesOpportunitiesListShow']/tr/td[1]/a")).getText()为SL17-00110,则结果等于0

假设后面的driver.findElement(By.xpath("//*[@id='salesOpportunitiesListShow']/tr/td[1]/a")).getText()为110,则结果等于7=1

假设后面的driver.findElement(By.xpath("//*[@id='salesOpportunitiesListShow']/tr/td[1]/a")).getText()为SL17-0011000000,找不到值,则结果等于-1

假设后面的driver.findElement(By.xpath("//*[@id='salesOpportunitiesListShow']/tr/td[1]/a")).getText()为空,则结果等于0

 Contains类似 

  public void ValidateSubElementText(String SubText) throws Exception {

    String ActualText = getText();

    if(ActualText.contains(SubText)){

      assertEquals(subText, subText);

  }

}

"".indexOf()   "",replace(",","")的应用

"". replace(",",""); 

"2,667.00".replace(",","") = = 》2667.00

相关文章:

  • 2022-02-22
  • 2022-01-21
  • 2021-08-19
  • 2022-12-23
  • 2022-12-23
  • 2022-02-23
  • 2022-12-23
  • 2021-09-02
猜你喜欢
  • 2021-12-24
  • 2022-12-23
  • 2022-12-23
  • 2022-01-15
  • 2022-12-23
  • 2021-08-10
  • 2022-12-23
相关资源
相似解决方案