From 399ecaff28b0709e16eeda9eac9a9810b0f7b358 Mon Sep 17 00:00:00 2001 From: Guillem Hernandez Sola Date: Tue, 21 Apr 2026 12:35:46 +0200 Subject: [PATCH] Added Manipuation hover duckduckgo --- .../testng/webdriver/ManipulationTest.java | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/test/java/com/agile611/testng/webdriver/ManipulationTest.java b/src/test/java/com/agile611/testng/webdriver/ManipulationTest.java index e5fa0d6..ac52415 100644 --- a/src/test/java/com/agile611/testng/webdriver/ManipulationTest.java +++ b/src/test/java/com/agile611/testng/webdriver/ManipulationTest.java @@ -1,6 +1,9 @@ package com.agile611.testng.webdriver; import org.openqa.selenium.By; +import org.openqa.selenium.WebElement; +import org.openqa.selenium.interactions.Actions; +import static org.testng.Assert.assertTrue; import org.testng.annotations.Test; public class ManipulationTest extends BaseTest { @@ -11,12 +14,20 @@ public class ManipulationTest extends BaseTest { driver.findElement(By.id("searchbox_input")).sendKeys("pizza hawaiana"); //Escribir en el text box driver.findElement(By.id("searchbox_input")).submit(); //Submit, darle al enter. Thread.sleep(2000); //Espera forzada + WebElement resultsList = driver.findElement(By.className("react-results--main")); //Comprobar que el resultado se muestra + assertTrue(resultsList.isDisplayed()); + driver.get("https://www.duckduckgo.com/"); //Navegar hasta duckduckgo driver.findElement(By.id("searchbox_input")).clear(); //Limpiar 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. Va a petar porque el id del botón de búsqueda ha cambiado, pero es para mostrar la diferencia entre submit y click. + driver.findElement(By.id("searchbox_input")).sendKeys("tortellini al pesto"); Thread.sleep(2000); //Espera forzada + Actions builder = new Actions(driver); + WebElement searchButton = driver.findElement(By.xpath(".//button[@data-mode=\'search\']")); //Click en el text box, no hace nada pero es para mostrar la diferencia entre submit y click. + builder.moveToElement(searchButton).click().build().perform(); //Click en el botón de búsqueda, esto es diferente a submit, ya que submit solo funciona con formularios, mientras que click funciona con cualquier elemento. + Thread.sleep(2000); //Espera forzada + resultsList = driver.findElement(By.className("react-results--main")); //Comprobar que el resultado se muestra + assertTrue(resultsList.isDisplayed()); } }