From 6ac43f79edd134b2cd7aa0dfa99e948d85c7f5ed Mon Sep 17 00:00:00 2001 From: Guillem Hernandez Sola Date: Fri, 12 Jun 2026 12:06:00 +0200 Subject: [PATCH] Safari polling Upload --- .../agile611/testng/webdriver/HoversTest.java | 2 +- .../agile611/testng/webdriver/UploadTest.java | 17 ++++++++++++++--- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/src/test/java/com/agile611/testng/webdriver/HoversTest.java b/src/test/java/com/agile611/testng/webdriver/HoversTest.java index 5e86769..b34168f 100644 --- a/src/test/java/com/agile611/testng/webdriver/HoversTest.java +++ b/src/test/java/com/agile611/testng/webdriver/HoversTest.java @@ -14,7 +14,7 @@ public class HoversTest extends BaseTest { @Test public void hoversTest() throws InterruptedException { - driver.get("http://the-internet.herokuapp.com/hovers"); + driver.get("https://the-internet.herokuapp.com/hovers"); Thread.sleep(3000); // Find and hover over desired element WebElement avatar = driver.findElement(By.className("figure")); diff --git a/src/test/java/com/agile611/testng/webdriver/UploadTest.java b/src/test/java/com/agile611/testng/webdriver/UploadTest.java index f6af128..bb7a389 100644 --- a/src/test/java/com/agile611/testng/webdriver/UploadTest.java +++ b/src/test/java/com/agile611/testng/webdriver/UploadTest.java @@ -2,11 +2,14 @@ package com.agile611.testng.webdriver; import java.io.File; import java.time.Duration; +import java.util.NoSuchElementException; import org.openqa.selenium.By; +import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.support.ui.ExpectedConditions; -import org.openqa.selenium.support.ui.WebDriverWait; +import org.openqa.selenium.support.ui.FluentWait; +import org.openqa.selenium.support.ui.Wait; import static org.testng.AssertJUnit.assertTrue; import org.testng.annotations.Test; @@ -14,6 +17,9 @@ public class UploadTest extends BaseTest { @Test public void testApp() throws InterruptedException { + // Controla el ritme per a Safari + Wait wait = new FluentWait(driver).withTimeout(Duration.ofSeconds(15)).pollingEvery(Duration.ofSeconds(1)).ignoring(NoSuchElementException.class); + driver.navigate().to("https://the-internet.herokuapp.com/upload"); WebElement fileUpload = driver.findElement(By.id("file-upload")); File file = new File("src" + File.separator + "test" @@ -21,9 +27,14 @@ public class UploadTest extends BaseTest { fileUpload.sendKeys(file.getAbsolutePath()); WebElement buttonUpload = driver.findElement(By.id("file-submit")); buttonUpload.click(); + + // Espera explĂ­cita para Safari + if (System.getProperty("browser").equalsIgnoreCase("safari")) { + Thread.sleep(2000); // Espera para Safari + } + WebElement uploadedFiles = driver.findElement(By.id("uploaded-files")); - WebDriverWait wait = new WebDriverWait(driver, Duration.ofSeconds(20)); - wait.until(ExpectedConditions.visibilityOf(uploadedFiles)); + wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("uploaded-files"))); assertTrue(uploadedFiles.isDisplayed()); }