read from framework driven data selenium-webdriver webdriver apache-poi

selenium webdriver - from - Obtener datos de Excel



selenium java read excel (0)

Necesito probar un sitio afiliado, el escenario es, hacer clic en el enlace, abrir ventana nueva, obtener clave de ese nuevo código fuente abierto y comparar con clave real con clave esperada,

Lo había hecho, pero el problema es que hay demasiados enlaces para capturar, así que sugerí poner todo el enlace xpath, valor esperado, valor real recibido del origen de la página en un archivo de Excel y usar Apache POI para ejecutar mis casos de prueba.

Aquí está mi código en el que estoy trabajando:

public void test() throws Exception { String home_logo_url="158321"; String enough_talk_promo="1057406"; System.out.println("Check for home_logo_url"); driver.get(baseUrl); String SiteWindow = driver.getWindowHandle(); // get the current window handle driver.findElement(By.xpath("//*[@id=''logo'']/a")).click(); for (String PromoWindow : driver.getWindowHandles()) { driver.switchTo().window(PromoWindow); // switch focus of WebDriver to the next found window handle (that''s your newly opened window) } String script = "return rlSerial;"; String value = (String) ((JavascriptExecutor)driver).executeScript(script); Assert.assertEquals(value,home_logo_url); driver.close(); driver.switchTo().window(SiteWindow); System.out.println("Pass"); System.out.println("Check for enough_talk_promo"); driver.get(baseUrl + "/category/tournaments/"); driver.findElement(By.xpath("//*[@id=''content'']/div/div[4]/aside/div/div/p[1]/a")).click(); for (String PromoWindow : driver.getWindowHandles()) { driver.switchTo().window(PromoWindow); // switch focus of WebDriver to the next found window handle (that''s your newly opened window) } String sr_enough_talk_promo = (String) ((JavascriptExecutor)driver).executeScript(script); Assert.assertEquals(sr_enough_talk_promo,enough_talk_promo); driver.close(); driver.switchTo().window(SiteWindow); System.out.println("Pass"); }

Al no obtener cómo proceder, un código de muestra es muy apreciado. Gracias.

Mi hoja de origen de Excel es: