this is my first question. I am automating a page where I must choose two prices, when choosing the first price the page goes down the scroll and that's where the test fails, I get the error, I've already tried with explicit waits and thread.sleep but it does not work. any ideas?
this is the error: net.thucydides.core.webdriver.exceptions.ElementShouldBeVisibleException: Expected condition failed: waiting for [[RemoteWebDriver: chrome on XP (e64b73bc32012e0506c1b2816cbc2ac2)] -> xpath: //div[@id='divAvailabilityOut']//span[@data-bind='html: Price']] to be displayed (tried for 50 second(s) with 100 milliseconds interval)
and this is my code:
public void escogerPreioMasCaro() throws InterruptedException {
List<WebElementFacade> listPreciosCaros = findAll(
"//div[@class='availabilityIn box']//span[@data-bind='html: Price']");
String[] strVectorCaros = new String[listPreciosCaros.size()];
int i = 0;
for (WebElementFacade listado : listPreciosCaros) {
System.out.println("Lista Precios Caros" + listado.getText());
strVectorCaros[i] = listado.getText().replaceAll("COP", " ").trim();
i++;
}
System.out.println(Arrays.toString(strVectorCaros).trim());
double[] vec1 = new double[strVectorCaros.length];
for (int g = 0; g < strVectorCaros.length; g++) {
try {
vec1[g] = Double.parseDouble(strVectorCaros[g]);
} catch (NumberFormatException ex) {
System.err.println("Ilegal input");
}
}
// System.out.println(Arrays.toString(vec1));
double precioMayor = vec1[0];
for (int x = 0; x < vec1.length; x++) {
// System.out.println(nombres[i] + " " + sueldos[i]);
if (vec1[x] > precioMayor) { //
precioMayor = vec1[x];
}
}
System.out.println("PrecioCaro" + precioMayor);
String precioMayorString = String.valueOf(precioMayor);
System.out.println("string " + precioMayorString);
for (WebElementFacade listado2 : listPreciosCaros) {
if (listado2.getText().contains(precioMayorString)) {
System.out.println(precioMayorString);
listado2.click();
}
}
Thread.sleep(2000);
}
What I am doing is to go through the series of prices and separate them to choose only the number, then pass them to double type vector to be able to compare their prices and choose the most expensive one
this is the page of the automation, the error presents it after choosing the destination and dates of travel
https://www.vivaair.com/co/flight/reserva
Thanks!
Aucun commentaire:
Enregistrer un commentaire