RemoteWebDriver
This commit is contained in:
@@ -32,6 +32,7 @@ public class BaseRemoteWebDriverTest {
|
|||||||
driver = new RemoteWebDriver(gridUrl, options);
|
driver = new RemoteWebDriver(gridUrl, options);
|
||||||
}
|
}
|
||||||
driver.manage().timeouts().implicitlyWait(Duration.ofSeconds(30));
|
driver.manage().timeouts().implicitlyWait(Duration.ofSeconds(30));
|
||||||
|
driver.manage().window().maximize();
|
||||||
}
|
}
|
||||||
|
|
||||||
@AfterClass(alwaysRun = true) //El cierre del navegador
|
@AfterClass(alwaysRun = true) //El cierre del navegador
|
||||||
|
|||||||
@@ -1,29 +0,0 @@
|
|||||||
package com.agile611.testng.webdriver;
|
|
||||||
|
|
||||||
import java.time.Duration;
|
|
||||||
|
|
||||||
import org.openqa.selenium.By;
|
|
||||||
import org.openqa.selenium.WebElement;
|
|
||||||
import org.openqa.selenium.remote.RemoteWebDriver;
|
|
||||||
import org.openqa.selenium.support.ui.ExpectedConditions;
|
|
||||||
import org.openqa.selenium.support.ui.WebDriverWait;
|
|
||||||
import static org.testng.Assert.assertTrue;
|
|
||||||
import org.testng.annotations.Test;
|
|
||||||
|
|
||||||
public class DuckDuckGoRemoteTest extends BaseRemoteWebDriverTest {
|
|
||||||
public void waitPageToLoad(RemoteWebDriver driver, long secondsTimeout, WebElement webElement){
|
|
||||||
WebDriverWait wait = new WebDriverWait(driver, Duration.ofSeconds(secondsTimeout));
|
|
||||||
wait.until(ExpectedConditions.elementToBeClickable(webElement));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testUntitledTestCase() throws Exception {
|
|
||||||
driver.get("https://duckduckgo.com/");
|
|
||||||
Thread.sleep(10000);
|
|
||||||
WebElement searchBox = driver.findElement(By.id("searchbox_input"));
|
|
||||||
searchBox.sendKeys("pizza hawaiana");
|
|
||||||
searchBox.submit();
|
|
||||||
WebElement resultsList = driver.findElement(By.className("react-results--main"));
|
|
||||||
assertTrue(resultsList.isDisplayed());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,47 @@
|
|||||||
|
package com.agile611.testng.webdriver;
|
||||||
|
|
||||||
|
import java.time.Duration;
|
||||||
|
|
||||||
|
import org.openqa.selenium.By;
|
||||||
|
import org.openqa.selenium.WebElement;
|
||||||
|
import org.openqa.selenium.remote.RemoteWebDriver;
|
||||||
|
import org.openqa.selenium.support.ui.ExpectedConditions;
|
||||||
|
import org.openqa.selenium.support.ui.WebDriverWait;
|
||||||
|
import org.testng.Assert;
|
||||||
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
|
public class YahooRemoteTest extends BaseRemoteWebDriverTest {
|
||||||
|
public void waitPageToLoad(RemoteWebDriver driver, long secondsTimeout, WebElement webElement){
|
||||||
|
WebDriverWait wait = new WebDriverWait(driver, Duration.ofSeconds(secondsTimeout));
|
||||||
|
wait.until(ExpectedConditions.elementToBeClickable(webElement));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testUntitledTestCase() throws Exception {
|
||||||
|
driver.get("https://www.yahoo.com/");
|
||||||
|
String originalWindow = driver.getWindowHandle();
|
||||||
|
WebElement acceptar = driver.findElement(By.xpath("//button[@value='agree']"));
|
||||||
|
acceptar.click();
|
||||||
|
WebElement searchBox = driver.findElement(By.xpath("//*[@type='search']"));
|
||||||
|
searchBox.click();
|
||||||
|
searchBox.clear();
|
||||||
|
searchBox.sendKeys("pizza hawaiana");
|
||||||
|
searchBox.submit();
|
||||||
|
|
||||||
|
WebDriverWait wait = new WebDriverWait(driver, Duration.ofSeconds(20));
|
||||||
|
wait.until(ExpectedConditions.numberOfWindowsToBe(2));
|
||||||
|
|
||||||
|
String newWindow = "";
|
||||||
|
for (String handle : driver.getWindowHandles()) {
|
||||||
|
System.out.println(handle);
|
||||||
|
if (!handle.equals(originalWindow)) {
|
||||||
|
newWindow = handle;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
driver.switchTo().window(newWindow);
|
||||||
|
WebElement searchResults = driver.findElement(By.id("results"));
|
||||||
|
Assert.assertTrue(searchResults.isDisplayed());
|
||||||
|
Thread.sleep(5000);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user