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