Safari polling Upload
This commit is contained in:
@@ -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"));
|
||||||
|
|||||||
@@ -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());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user