Some fixes

This commit is contained in:
Guillem Hernandez Sola
2026-04-20 13:05:31 +02:00
parent a1f79f41c6
commit aa622511f4
11 changed files with 28 additions and 42 deletions

View File

@@ -1,13 +1,13 @@
package com.agile611.testng.webdriver; package com.agile611.testng.webdriver;
import static org.testng.Assert.assertTrue;
import org.testng.annotations.Test;
import com.agile611.testng.webdriver.pages.ResultsPage; import com.agile611.testng.webdriver.pages.ResultsPage;
import com.agile611.testng.webdriver.pages.SearchPage; import com.agile611.testng.webdriver.pages.SearchPage;
import org.testng.annotations.*;
import static org.testng.Assert.*; public class DuckDuckGoTest extends BaseTest {
@Test
public class DuckDuckGoTest extends BaseSaucelabsTest {
@Test //El propio test que hemos exportado de Katalon IDE
public void testUntitledTestCase() throws Exception { public void testUntitledTestCase() throws Exception {
SearchPage searchPage = new SearchPage(driver); SearchPage searchPage = new SearchPage(driver);
searchPage.searchKeyword("pizza hawaiana"); searchPage.searchKeyword("pizza hawaiana");

View File

@@ -1,17 +1,14 @@
package com.agile611.testng.webdriver; package com.agile611.testng.webdriver;
import java.time.Duration;
import org.openqa.selenium.By; import org.openqa.selenium.By;
import org.openqa.selenium.WebElement; import org.openqa.selenium.WebElement;
import org.openqa.selenium.interactions.Actions; import org.openqa.selenium.interactions.Actions;
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 org.testng.annotations.Test;
import java.time.Duration;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.testng.Assert.assertTrue; import static org.testng.Assert.assertTrue;
import org.testng.annotations.Test;
public class HoversTest extends BaseTest { public class HoversTest extends BaseTest {

View File

@@ -2,7 +2,7 @@ package com.agile611.testng.webdriver;
import org.testng.annotations.Test; import org.testng.annotations.Test;
public class InterrogationTest extends BaseSaucelabsTest { public class InterrogationTest extends BaseTest {
@Test //Opciones de Navegación @Test //Opciones de Navegación
public void testNavigation() throws Exception { public void testNavigation() throws Exception {
driver.get("https://www.duckduckgo.com/"); //Navegar hasta duckduckgo driver.get("https://www.duckduckgo.com/"); //Navegar hasta duckduckgo

View File

@@ -3,11 +3,8 @@ package com.agile611.testng.webdriver;
import org.openqa.selenium.By; import org.openqa.selenium.By;
import org.openqa.selenium.Keys; import org.openqa.selenium.Keys;
import org.openqa.selenium.interactions.Actions; import org.openqa.selenium.interactions.Actions;
import org.testng.annotations.Test;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.testng.Assert.assertTrue; import static org.testng.Assert.assertTrue;
import org.testng.annotations.Test;
public class KeyboardKeysTest extends BaseTest { public class KeyboardKeysTest extends BaseTest {
@Test @Test

View File

@@ -3,19 +3,19 @@ package com.agile611.testng.webdriver;
import org.openqa.selenium.By; import org.openqa.selenium.By;
import org.testng.annotations.Test; import org.testng.annotations.Test;
public class ManipulationTest extends BaseSaucelabsTest { public class ManipulationTest extends BaseTest {
@Test //Opciones de Navegación @Test //Opciones de Navegación
public void testNavigation() throws Exception { public void testNavigation() throws Exception {
driver.get("https://www.duckduckgo.com/"); //Navegar hasta duckduckgo driver.get("https://www.duckduckgo.com/"); //Navegar hasta duckduckgo
driver.findElement(By.id("search_form_input_homepage")).clear(); //Limpiar el text box driver.findElement(By.id("searchbox_input")).clear(); //Limpiar el text box
driver.findElement(By.id("search_form_input_homepage")).sendKeys("pizza hawaiana"); //Escribir en el text box driver.findElement(By.id("searchbox_input")).sendKeys("pizza hawaiana"); //Escribir en el text box
driver.findElement(By.id("search_form_homepage")).submit(); //Submit, darle al enter. driver.findElement(By.id("searchbox_input")).submit(); //Submit, darle al enter.
Thread.sleep(2000); //Espera forzada Thread.sleep(2000); //Espera forzada
driver.get("https://www.duckduckgo.com/"); //Navegar hasta duckduckgo driver.get("https://www.duckduckgo.com/"); //Navegar hasta duckduckgo
driver.findElement(By.id("search_form_input_homepage")).clear(); //Limpiar el text box driver.findElement(By.id("searchbox_input")).clear(); //Limpiar el text box
driver.findElement(By.id("search_form_input_homepage")).sendKeys("tortellini al pesto"); //Escribir en el text box driver.findElement(By.id("searchbox_input")).sendKeys("tortellini al pesto"); //Escribir en el text box
driver.findElement(By.id("search_button_homepage")).click(); //click a la lupa. driver.findElement(By.id("search_button_homepage")).click(); //click a la lupa. Va a petar porque el id del botón de búsqueda ha cambiado, pero es para mostrar la diferencia entre submit y click.
Thread.sleep(2000); //Espera forzada Thread.sleep(2000); //Espera forzada
} }
} }

View File

@@ -1,9 +1,8 @@
package com.agile611.testng.webdriver; package com.agile611.testng.webdriver;
import org.openqa.selenium.By;
import org.testng.annotations.Test; import org.testng.annotations.Test;
public class NavigationTest extends BaseSaucelabsTest { public class NavigationTest extends BaseTest {
@Test //Opciones de Navegación @Test //Opciones de Navegación
public void testNavigation() throws Exception { public void testNavigation() throws Exception {
driver.get("https://www.duckduckgo.com/"); //Navegar hasta duckduckgo driver.get("https://www.duckduckgo.com/"); //Navegar hasta duckduckgo

View File

@@ -1,5 +1,7 @@
package com.agile611.testng.webdriver; package com.agile611.testng.webdriver;
import java.io.File;
import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver; import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.firefox.FirefoxOptions; import org.openqa.selenium.firefox.FirefoxOptions;
@@ -7,8 +9,6 @@ import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod; import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test; import org.testng.annotations.Test;
import java.io.File;
public class StatusCodesTest { public class StatusCodesTest {
WebDriver driver; WebDriver driver;

View File

@@ -1,6 +1,5 @@
package com.agile611.testng.webdriver; package com.agile611.testng.webdriver;
import com.agile611.testng.webdriver.BaseTest;
import org.openqa.selenium.By; import org.openqa.selenium.By;
import org.openqa.selenium.WebElement; import org.openqa.selenium.WebElement;
import org.testng.annotations.Test; import org.testng.annotations.Test;

View File

@@ -1,15 +1,14 @@
package com.agile611.testng.webdriver; package com.agile611.testng.webdriver;
import java.io.File;
import java.time.Duration;
import org.openqa.selenium.By; import org.openqa.selenium.By;
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.WebDriverWait;
import org.testng.annotations.Test;
import java.io.File;
import java.time.Duration;
import static org.testng.AssertJUnit.assertTrue; import static org.testng.AssertJUnit.assertTrue;
import org.testng.annotations.Test;
public class UploadTest extends BaseTest { public class UploadTest extends BaseTest {

View File

@@ -9,7 +9,7 @@ public class ResultsPage {
private WebDriver driver; private WebDriver driver;
@FindBy(id = "links_wrapper") @FindBy(className = "react-results--main")
public WebElement resultsList; public WebElement resultsList;

View File

@@ -9,14 +9,9 @@ public class SearchPage {
private WebDriver driver; private WebDriver driver;
@FindBy(id = "search_form_input_homepage") @FindBy(id = "searchbox_input")
public WebElement searchBox; public WebElement searchBox;
@FindBy(id = "search_button_homepage")
public WebElement searchButton;
public SearchPage(WebDriver driver) { public SearchPage(WebDriver driver) {
PageFactory.initElements(driver, this); PageFactory.initElements(driver, this);
driver.get("https://duckduckgo.com/"); driver.get("https://duckduckgo.com/");
@@ -25,6 +20,6 @@ public class SearchPage {
public void searchKeyword(String keyword) { public void searchKeyword(String keyword) {
searchBox.clear(); searchBox.clear();
searchBox.sendKeys(keyword); searchBox.sendKeys(keyword);
searchButton.click(); searchBox.submit();
} }
} }