Skip to content

Commit

Permalink
Fix breaking changes selenium 4.1.3 WebDriverWait duration
Browse files Browse the repository at this point in the history
  • Loading branch information
javiertuya committed Mar 29, 2022
1 parent d96ed8a commit 89d008a
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
4 changes: 3 additions & 1 deletion src/it/java/giis/demo/descuento/it/TestDescuentoSelema.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import org.junit.runner.RunWith;
import static org.junit.Assert.assertEquals;

import java.time.Duration;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.web.server.LocalServerPort;
Expand Down Expand Up @@ -98,7 +100,7 @@ public void testDescuentoScenario() {
}
private void doStep(boolean initialStep, String edad, String expected) {
WebElement txtEdad;
txtEdad = (new WebDriverWait(sm.driver(), 5))
txtEdad = (new WebDriverWait(sm.driver(), Duration.ofSeconds(5)))
.until(ExpectedConditions.presenceOfElementLocated(By.id("txtEdad")));

if (initialStep) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import org.junit.runner.RunWith;
import static org.junit.Assert.assertEquals;

import java.time.Duration;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.web.server.LocalServerPort;
Expand Down Expand Up @@ -143,7 +145,7 @@ private void doStep(boolean initialStep, String edad, String expected) {
//causando una excepcion.
//Esto es tipico cuando se usa/incluye javascript, y tambien depende del navegador y la velocidad del equipo.
//Este elemento se obtendra utilizando una espera explicita
txtEdad = (new WebDriverWait(driver, 5))
txtEdad = (new WebDriverWait(driver, Duration.ofSeconds(5)))
.until(ExpectedConditions.presenceOfElementLocated(By.id("txtEdad")));
//Existen tambien formas de establecer un tiempo implicito para el driver.
//Ver: https://www.seleniumhq.org/docs/04_webdriver_advanced.jsp#explicit-and-implicit-waits
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package giis.demo.descuento.it.jbehave;
import static org.junit.Assert.assertEquals;

import java.time.Duration;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -80,7 +81,7 @@ public void setEdad() {
}
private void doSetEdad(String edad) {
WebElement txtEdad;
txtEdad = (new WebDriverWait(driver, 5)).until(ExpectedConditions.presenceOfElementLocated(By.id("txtEdad")));
txtEdad = (new WebDriverWait(driver, Duration.ofSeconds(5))).until(ExpectedConditions.presenceOfElementLocated(By.id("txtEdad")));
txtEdad.clear(); //si no se limpia antes, sendKeys concatenara con el texto existente
txtEdad.sendKeys(edad);
driver.findElement(By.id("btnEdad")).click();
Expand Down

0 comments on commit 89d008a

Please sign in to comment.