zoukankan      html  css  js  c++  java
  • "".indexOf() "",replace(",","")的应用

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

    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);

      }

    }

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

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

  • 相关阅读:
    【洛谷4251】 [SCOI2015]小凸玩矩阵(二分答案,二分图匹配)
    JXOI2019游记
    luogu4884 多少个1?
    数论难点选讲
    计树问题小结
    codeforces选做1.0
    POI2015选做
    后缀自动机小结
    bzoj4008 [HNOI2015]亚瑟王
    bzoj1500 [NOI2005]维修数列
  • 原文地址:https://www.cnblogs.com/nieliangcai/p/7326420.html
Copyright © 2011-2022 走看看