Added test

This commit is contained in:
Guillem Hernandez Sola
2026-04-23 13:22:56 +02:00
parent 818ea0622f
commit 98b34c5434
2 changed files with 16 additions and 3 deletions

View File

@@ -13,7 +13,7 @@
<version>3.1.2</version> <version>3.1.2</version>
<configuration> <configuration>
<suiteXmlFiles> <suiteXmlFiles>
<suiteXmlFile>src/main/resources/suite.xml</suiteXmlFile> <suiteXmlFile>src/test/resources/suite.xml</suiteXmlFile>
</suiteXmlFiles> </suiteXmlFiles>
</configuration> </configuration>
</plugin> </plugin>

View File

@@ -6,6 +6,7 @@ import java.time.Duration;
import org.openqa.selenium.chrome.ChromeOptions; import org.openqa.selenium.chrome.ChromeOptions;
import org.openqa.selenium.firefox.FirefoxOptions; import org.openqa.selenium.firefox.FirefoxOptions;
import org.openqa.selenium.remote.RemoteWebDriver; import org.openqa.selenium.remote.RemoteWebDriver;
import org.openqa.selenium.safari.SafariOptions;
import org.testng.annotations.AfterClass; import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass; import org.testng.annotations.BeforeClass;
@@ -14,13 +15,25 @@ public class BaseRemoteWebDriverTest {
@BeforeClass(alwaysRun = true) //Inicialización del navegador @BeforeClass(alwaysRun = true) //Inicialización del navegador
public void setUp() throws Exception { public void setUp() throws Exception {
String browser = System.getProperty("browser"); String browser = System.getProperty("browser");
// Extraemos la URL para mantener el código DRY (Don't Repeat Yourself)
URL gridUrl = new URL("http://0.0.0.0:4444/wd/hub");
if (browser != null && browser.equalsIgnoreCase("chrome")) { if (browser != null && browser.equalsIgnoreCase("chrome")) {
ChromeOptions options = new ChromeOptions(); ChromeOptions options = new ChromeOptions();
driver = new RemoteWebDriver(new URL("http://0.0.0.0:4444/wd/hub"), options); driver = new RemoteWebDriver(gridUrl, options);
} else if (browser != null && browser.equalsIgnoreCase("safari")) {
SafariOptions options = new SafariOptions();
// Aquí podrías añadir configuraciones específicas si lo necesitas
// options.setUseTechnologyPreview(true);
driver = new RemoteWebDriver(gridUrl, options);
} else { } else {
// Firefox se mantiene como el navegador por defecto (fallback)
FirefoxOptions options = new FirefoxOptions(); FirefoxOptions options = new FirefoxOptions();
driver = new RemoteWebDriver(new URL("http://0.0.0.0:4444/wd/hub"), options); driver = new RemoteWebDriver(gridUrl, options);
} }
driver.manage().timeouts().implicitlyWait(Duration.ofSeconds(30)); driver.manage().timeouts().implicitlyWait(Duration.ofSeconds(30));
} }