【发布时间】:2021-07-23 08:21:19
【问题描述】:
我写了一个程序来比较网站中的价格和一个带有 selenium 和 java 的 csv 文件,在程序的最后我写了断言来确认两个数字,但它有一个问题:
预期价格为 57,15
实际价格为 57.15
实际价格应该是57,15,我不知道该怎么写,你能帮我吗?
@Test(priority = 1)
void checkBeschädigung() throws FileNotFoundException {
prepareTest();
List<CsvPrice> stuff = readFromCSV("resources/price/BikePrice.csv");
Select price = new Select(driver.findElement(By.id("coverageSum")));
price.selectByIndex(1);
driver.findElement(By.xpath("//*[@id=\"landingApp\"]/div[1]/div/div[2]/div/div/div/form/div[3]/div/div[2]/div[2]/div/label/input")).click();
try {
Thread.sleep(4000);
} catch (InterruptedException e) {
e.printStackTrace();
}
WebElement FirstPrice = driver.findElement(By.xpath("//*[@id='product-configurator-spinner']//parent::span"));
String finalprice = FirstPrice.getText().split(" ")[0];
System.out.println(finalprice);
for (int i = 0; i <= 329; i++) {
if (String.valueOf(stuff.get(i).getCoverageSum()).equals("250")
&& String.valueOf(stuff.get(i).getDurationStart()).equals("1") && stuff.get(i).getQualityName().equals("Diebstahl")
&& stuff.get(i).getDurationTimeUnit().equals("YEARS")) {
System.out.println(stuff.get(i).getPriceBasePrice());
Assert.assertEquals(finalprice, String.valueOf(stuff.get(i).getPriceBasePrice()));
break;
} else {
System.out.println("that is wrong");
}
}
【问题讨论】:
标签: java selenium automated-tests compare assert