Foros del Web » Programación para mayores de 30 ;) » Java »

[SOLUCIONADO] Selenium webdriver cargar parámetros desde xml.

Estas en el tema de Selenium webdriver cargar parámetros desde xml. en el foro de Java en Foros del Web. Hola, soy nuevo en esto y agradezco ayuda. Tengo que cargar parametros desde un xml a unos test, en el código que mostraré me sucede ...
  #1 (permalink)  
Antiguo 01/10/2017, 06:35
 
Fecha de Ingreso: septiembre-2012
Ubicación: montevideo
Mensajes: 131
Antigüedad: 11 años, 6 meses
Puntos: 0
Selenium webdriver cargar parámetros desde xml.

Hola, soy nuevo en esto y agradezco ayuda.
Tengo que cargar parametros desde un xml a unos test, en el código que mostraré me sucede que o cargo los parametros o ejecuto el test, no puedo asignar los parametros al test.

Código Java:
Ver original
  1. public static void main(String[] args) {
  2.  
  3.     Properties prop = new Properties();
  4.     InputStream input = null;
  5.  
  6.     try {
  7.         input = new FileInputStream("C:\\Users\\jeggg\\Desktop\\2017\\mavenproject2\\src\\test\\java\\com\\mycompany\\mavenproject2\\newproperties.properties");
  8.  
  9.         // load a properties file
  10.         prop.load(input);
  11.  
  12.         // get the property value and print it out
  13.         System.out.println(prop.getProperty("nomb"));
  14.         System.out.println(prop.getProperty("passw"));
  15.                
  16.     } catch (IOException ex) {
  17.         ex.printStackTrace();
  18.     } finally {
  19.         if (input != null) {
  20.             try {
  21.                 input.close();
  22.             } catch (IOException e) {
  23.             //  e.printStackTrace();
  24.             }
  25.         }
  26.     }
  27.  
  28. }
  29.  
  30.                        
  31.     public void Firefox(){
  32.     System.setProperty("webdriver.gecko.driver", "C://geckodriver.exe");
  33.     driver = new FirefoxDriver();
  34.     baseUrl = "http://egroupware.cursos.ces.com.uy/";
  35.     //driver.manage().timeouts().implicitlyWait(3, TimeUnit.SECONDS);
  36.   }
  37.  
  38.    
  39. @Before  //seleccione navegador
  40. public void navegador() throws Exception {
  41.  
  42. Firefox();
  43. //Chrome();
  44. //IE();
  45. }
  46.  
  47.   private boolean isElementPresent(By by) {
  48.     try {
  49.       driver.findElement(by);
  50.       return true;
  51.     } catch (NoSuchElementException e) {
  52.       return false;
  53.     }
  54.   }
  55.  
  56.     public void Logout() throws Exception {
  57.  
  58.     driver.findElement(By.cssSelector("img[alt=\"Logout\"]")).click();
  59.     assertTrue(isElementPresent(By.className("divLoginboxHeader")));
  60.   }  
  61.      
  62.   @Test
  63.  
  64.   public void testLogin() throws Exception {
  65.     driver.get(baseUrl + "/login.php");
  66.     assertEquals("eGroupWare [Login]", driver.getTitle());
  67.     driver.findElement(By.name("login")).clear();
  68.     driver.findElement(By.name("login")).sendKeys("nomb");
  69.     driver.findElement(By.name("passwd")).clear();
  70.     driver.findElement(By.name("passwd")).sendKeys("passw");
  71.   /*  try {
  72.       assertTrue(isElementPresent(By.id("divAppboxHeader")));
  73.     } catch (Error e) {
  74.       verificationErrors.append(e.toString());
  75.     }   */
  76.     //Logout();
  77.   }
  78.    }

Etiquetas: Ninguno
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 11:55.