Safari polling Upload

This commit is contained in:
Guillem Hernandez Sola
2026-06-12 12:06:00 +02:00
parent 69e1e34370
commit 6ac43f79ed
2 changed files with 15 additions and 4 deletions

View File

@@ -14,7 +14,7 @@ public class HoversTest extends BaseTest {
@Test @Test
public void hoversTest() throws InterruptedException { public void hoversTest() throws InterruptedException {
driver.get("http://the-internet.herokuapp.com/hovers"); driver.get("https://the-internet.herokuapp.com/hovers");
Thread.sleep(3000); Thread.sleep(3000);
// Find and hover over desired element // Find and hover over desired element
WebElement avatar = driver.findElement(By.className("figure")); WebElement avatar = driver.findElement(By.className("figure"));

View File

@@ -2,11 +2,14 @@ package com.agile611.testng.webdriver;
import java.io.File; import java.io.File;
import java.time.Duration; import java.time.Duration;
import java.util.NoSuchElementException;
import org.openqa.selenium.By; import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement; import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.ui.ExpectedConditions; 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 static org.testng.AssertJUnit.assertTrue;
import org.testng.annotations.Test; import org.testng.annotations.Test;
@@ -14,6 +17,9 @@ public class UploadTest extends BaseTest {
@Test @Test
public void testApp() throws InterruptedException { public void testApp() throws InterruptedException {
// Controla el ritme per a Safari
Wait<WebDriver> wait = new FluentWait<WebDriver>(driver).withTimeout(Duration.ofSeconds(15)).pollingEvery(Duration.ofSeconds(1)).ignoring(NoSuchElementException.class);
driver.navigate().to("https://the-internet.herokuapp.com/upload"); driver.navigate().to("https://the-internet.herokuapp.com/upload");
WebElement fileUpload = driver.findElement(By.id("file-upload")); WebElement fileUpload = driver.findElement(By.id("file-upload"));
File file = new File("src" + File.separator + "test" File file = new File("src" + File.separator + "test"
@@ -21,9 +27,14 @@ public class UploadTest extends BaseTest {
fileUpload.sendKeys(file.getAbsolutePath()); fileUpload.sendKeys(file.getAbsolutePath());
WebElement buttonUpload = driver.findElement(By.id("file-submit")); WebElement buttonUpload = driver.findElement(By.id("file-submit"));
buttonUpload.click(); 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")); WebElement uploadedFiles = driver.findElement(By.id("uploaded-files"));
WebDriverWait wait = new WebDriverWait(driver, Duration.ofSeconds(20)); wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("uploaded-files")));
wait.until(ExpectedConditions.visibilityOf(uploadedFiles));
assertTrue(uploadedFiles.isDisplayed()); assertTrue(uploadedFiles.isDisplayed());
} }