RemoteTest

This commit is contained in:
Guillem Hernandez Sola
2026-06-17 11:22:20 +02:00
parent 023c761bcf
commit 3c196f5618

View File

@@ -2,21 +2,15 @@ package com.agile611.testng.webdriver;
import java.time.Duration; import java.time.Duration;
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement; import org.openqa.selenium.WebElement;
import org.openqa.selenium.remote.RemoteWebDriver; import org.openqa.selenium.remote.RemoteWebDriver;
import org.openqa.selenium.support.FindBy;
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.WebDriverWait;
import static org.testng.Assert.assertTrue; import static org.testng.Assert.assertTrue;
import org.testng.annotations.Test; import org.testng.annotations.Test;
public class DuckDuckGoRemoteTest extends BaseRemoteWebDriverTest { public class DuckDuckGoRemoteTest extends BaseRemoteWebDriverTest {
@FindBy(id = "searchbox_input")
public WebElement searchBox;
@FindBy(className = "react-results--main")
public WebElement resultsList;
public void waitPageToLoad(RemoteWebDriver driver, long secondsTimeout, WebElement webElement){ public void waitPageToLoad(RemoteWebDriver driver, long secondsTimeout, WebElement webElement){
WebDriverWait wait = new WebDriverWait(driver, Duration.ofSeconds(secondsTimeout)); WebDriverWait wait = new WebDriverWait(driver, Duration.ofSeconds(secondsTimeout));
wait.until(ExpectedConditions.elementToBeClickable(webElement)); wait.until(ExpectedConditions.elementToBeClickable(webElement));
@@ -25,10 +19,11 @@ public class DuckDuckGoRemoteTest extends BaseRemoteWebDriverTest {
@Test @Test
public void testUntitledTestCase() throws Exception { public void testUntitledTestCase() throws Exception {
driver.get("https://duckduckgo.com/"); driver.get("https://duckduckgo.com/");
waitPageToLoad(driver, 10, searchBox); Thread.sleep(10000);
WebElement searchBox = driver.findElement(By.id("searchbox_input"));
searchBox.sendKeys("pizza hawaiana"); searchBox.sendKeys("pizza hawaiana");
searchBox.submit(); searchBox.submit();
waitPageToLoad(driver, 10, resultsList); WebElement resultsList = driver.findElement(By.className("react-results--main"));
assertTrue(resultsList.isDisplayed()); assertTrue(resultsList.isDisplayed());
} }
} }