Developmentcookbook
  • Introduction
  • Herramientas de Desarrollo
  • PlantUML en NetBeans
  • JPA
    • AUTOINCREMENTABLE SECUENCE
    • Autoincrementable mediante Tabla
    • Agregar DataSource /JNDI
    • Sincronizando EntityManager /con base datos
  • NoSQL
    • Couchdb
      • Instalacion_couchdb
    • MongoDB
      • Optimizar mongodb
      • mongodb 4.0
      • MongoDB vs RDBM
      • Instalar mongodb
  • Apache Tomcat10
    • Tomcat con Jakarta EE
    • UberJar
  • SQL Server
    • SQL Server Con NetBeans
    • SQL Server Command Line
    • Sql Migrar desde hoja de calculos
    • Cambiar contraseƱa de usuario sa
    • Azure Data Studio
  • Kazam
  • Ubuntu
    • Desintalar un paquete
    • Activar la virtualizacion en Ubuntu
    • Crear acceso directo
    • Deshabilitar el splash screen en el grub ubuntu
    • Optimizar Google Chrome
    • ZRAM EN UBUNTU
    • Formatear usb con varias particiones
    • Crear usb Live persistente de ubuntu
    • Controlar mouse con raton
  • I-Android
    • 1.1- InstalarAndroid Studio
    • 1.2-Crear proyecto
    • 1.4-Configurar dispositivo Android
      • III. Emulador Android Studio
        • 3.1-Instalar el Emulador de Android Studio
        • 3.2-Crear AVD ( emulador Android Studio)
        • 3.3 Instalar KVM
        • 3.4 Virtualizacion para el Emulador de Android Studio
          • 3.5 Activar Virtualizacion en Ubuntu
            • 3.5.1 Instalar acelerador kvm
          • 3.6 Configure el emulador de Android
      • Otras opciones no Fundamentales
        • 1.3-Mejorar rendimiento de Android Studio
          • 1.3.1 Permisos
        • 1.1.1 Cambiar Colores
        • 1.1.1 Optimizar Android
  • II.Emulador Genymotion
    • 2.0 Instalar Emulador Genymotion
    • 2.1 Error con redes y VirtualBox
    • 2.2 Configurar ADB
    • 2.1 Crear Dispositivos
    • 2.4 Corregir el error al ejecutar ABD
    • 2.5 Integrar Emulador Genymotion con Android Studio
  • Apple IOS
  • IV.Flutter
    • 4.0 Links
    • 4.1 Instalar Flutter
    • 4.2 Configurar Editor
    • 4.3 Primera Aplicacion en Flutter
    • 4.4 Ejecutar con Genymotion
    • 4.5 Genymotion Devices con Android Studio
    • 4.6 Agregar dependencias
    • 4.7 Path
    • 4.8 Crear un build para Android e Ios desde consola
  • V. Visual Studio Code
    • Java Support
    • Microprofile Visual Studio
    • Soporte Git
    • 5.1 Instalar
    • 5.2 Configurar Flutter
    • 5.3 Proyecto Flutter en Visual Studio Code
    • 5.4 Ejecutar Proyecto con Genymotion
    • 5.5 Launch Emulator
      • 5.6 Git
  • VI. DiseƱar aplicaciones Flutter con pencil
  • VII. Flutter WebView
    • main.dart
    • WebViewInFlutter.dart
  • VIII. Fluter con RestFull API
    • 8.0 Enlaces
    • 8.1 Proyecto ejemplo
  • IX. Flutter Push Notificationes
    • 9.0 Enlances
    • Untitled
  • X. Flutter Test
    • 10.0 Enlaces
  • XI. Flutter Mockito
    • 11.0 Enlaces
  • XII. CodeMagic CI/CD Continuos Development
    • 12.0 gitlab
    • 12.1 Build Fase
    • 12.2 Testing Fails
    • 12.3 TestMagic
    • 12.4 Generar para IOS
    • 12.5 Firmar para IOS
  • XIII. Cambiar Icono Lanzador
  • XIV. Firmar APP
  • XV. Reducir el tamaƱo
  • Dart
    • Instalacion_dart
  • Flutter con MongoDB
  • Heroku
  • Vaadin
  • NodeJS
    • Instalar_nodejs
    • Angular IDE
    • NetBeans Angular
    • Instalar PrimeNG
    • Instalar AngularCI
    • Instalar FontAwesome
  • VueJS
  • Jenkins
    • Requerimientos
    • Configurar el Sistema
    • Login
    • Dashboard
    • Plugins
    • Global Tool Configuration
    • Crear proyecto maven
    • Configurar el archivo pom.xml
    • Inicializar mercurial
    • Ejecutar mercurial server
    • Crear Tarea Jenkins
      • General
      • Configurar origen del codigo fuente
      • Disparadores de ejecuciones
      • Entorno de ejecución
      • Pasos previos
      • Proyecto
      • Pasos posteriores/Cobertura
      • Propiedades del proyecto
      • Acciones para Ejecutar despuĆ©s
    • PMD
    • Ver la integración continua
      • Modulos
      • Bajar el artefacto de cada corrida
      • Tendencia
    • Editemos el Test
    • Test de Cobertura
    • Plugins Jenkins para NetBeans
  • MVC con JEE8
    • Introduccion mvc
    • Mvc learn
    • mvc con facelets
    • mvc con jnoqsl
  • Microservicios
    • Introduccion a microservicios
    • Crear un microservcios
    • Cliente del Microservicio
  • NetBeans Platform
  • Markdown
    • texto expandible
  • Android
    • Git
  • Selenium Testing
  • Zoom en Ubuntu 20.04
Powered by GitBook
On this page

Was this helpful?

Selenium Testing

PreviousGitNextZoom en Ubuntu 20.04

Last updated 4 years ago

Was this helpful?

instalar

instalar google chrome

sudo apt-get install google-chrome-stable

proyecto

Mi proyecto

Instalar

Chrome Driver

Pasos:

Descargarlo

sudo mv chromedriver /usr/bin/chromedriver

sudo chown root:root /usr/bin/chromedriver

sudo chmod +x /usr/bin/chromedriver

dependencias

  <!--
                Test Containers
        -->
        <dependency>
            <groupId>org.testcontainers</groupId>
            <artifactId>testcontainers</artifactId>
            <version>${testcontainers.version}</version>
        </dependency>
        
        <dependency>
            <groupId>org.testcontainers</groupId>
            <artifactId>selenium</artifactId>
            <version>${testcontainers.version}</version>
        </dependency>
        <dependency>
            <groupId>org.seleniumhq.selenium</groupId>
            <artifactId>selenium-remote-driver</artifactId>         
            <version>${selenium-remote-driver.version}</version>
        </dependency>
        <dependency>
            <groupId>org.seleniumhq.selenium</groupId>
            <artifactId>selenium-chrome-driver</artifactId>
            <version>${selenium-remote-driver.version}</version>
        </dependency>
        <dependency>
            <groupId>org.seleniumhq.selenium</groupId>
            <artifactId>selenium-support</artifactId>
            <version>3.141.59</version>
        </dependency>
        
           <dependency>
    <groupId>org.slf4j</groupId>
    <artifactId>slf4j-jdk14</artifactId>
    <version>1.7.29</version>
</dependency>
        
        
        
        
         <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.22.2</version>
            </plugin>

Codigo

package com.bpb.book;

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
import static org.junit.Assert.assertEquals;
import org.junit.Rule;
import org.junit.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeOptions;
import org.openqa.selenium.remote.RemoteWebDriver;
import org.openqa.selenium.support.FindBy;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
import org.testcontainers.containers.BrowserWebDriverContainer;

public class AppControllerTest {

    String url = "http://192.168.0.5:8080/krazosguide";
    @FindBy(id = "greeting")
    private WebElement greeting;

    @Rule
    public BrowserWebDriverContainer chrome
            = new BrowserWebDriverContainer()
                    .withCapabilities(new ChromeOptions());

    @Test
    public void viewTest() {
        RemoteWebDriver driver = chrome.getWebDriver();

        driver.get(url + "/mvc/app/view");

//        WebDriverWait wait = new WebDriverWait(driver, 10);// 1 minute 
//        wait.until(ExpectedConditions.visibilityOfElementLocated(By.name("country")));

        WebElement element = driver.findElement(By.name("country"));

        String country = element.getAttribute("value");
        assertEquals("Panama", country);
        driver.close();
    }

    @Test
    public void cdiTest() {
        RemoteWebDriver driver = chrome.getWebDriver();
        driver.get(url + "/mvc/app/cdi");
        WebElement element = driver.findElement(By.id("message"));
        String message = element.getAttribute("innerHTML");
        assertEquals("Welcome from CDI", message);
        

        driver.close();
    }

    @Test
    public void viewable() {
        RemoteWebDriver driver = chrome.getWebDriver();
        driver.get(url + "/mvc/app/viewable");
        WebElement element = driver.findElement(By.id("message"));
        String message = element.getAttribute("innerHTML");
        assertEquals("Welcome from viewable", message);
        driver.close();
    }

//    @Test
//    public void simplePlainSeleniumTest() {
//        RemoteWebDriver driver = chrome.getWebDriver();
//
//        driver.get("https://wikipedia.org");
//        WebElement searchInput = driver.findElementByName("search");
//
//        searchInput.sendKeys("Rick Astley");
//        searchInput.submit();
//
//        WebElement otherPage = driver.findElementByLinkText("Rickrolling");
//        otherPage.click();
//
//        boolean expectedTextFound = driver.findElementsByCssSelector("p")
//                .stream()
//                .anyMatch(element -> element.getText().contains("meme"));
//
//        assertTrue("The word 'meme' is found on a page about rickrolling", expectedTextFound);
//    }
//    @Test
//    public void helloJsp() {
//        RemoteWebDriver driver = chrome.getWebDriver();
//
//        driver.get("http://localhost:8080/krazosguide/mvc/app/view");
//        WebElement searchInput = driver.findElementByName("search");
//
//        searchInput.sendKeys("Avbravo");
//        searchInput.submit();
//
//        WebElement otherPage = driver.findElementByLinkText("Rickrolling");
//        otherPage.click();
//
//        boolean expectedTextFound = driver.findElementsByCssSelector("p")
//                .stream()
//                .anyMatch(element -> element.getText().contains("meme"));
//
//        assertTrue("The word 'meme' is found on a page about rickrolling", expectedTextFound);
//    }
//    @Test
//    public void book1() {
//        RemoteWebDriver driver = chrome.getWebDriver();
//        driver.get("http://book.theautomatedtester.co.uk/chapter4");
//        WebElement element = driver.findElement(By.id("selectLoad"));
//        String value = element.getAttribute("value");
//        assertEquals("Click to load the select below", value);
//        driver.close();
//    }
//    @Test
//    public void google() {
//        RemoteWebDriver driver = chrome.getWebDriver();
//        try{
//            driver.get("https://google.com/ncr");
//            driver.findElement(By.name("q")).sendKeys("cheese" + Keys.ENTER);
//            WebElement firstResult = wait.until(presenceOfElementLocated(By.cssSelector("h3>div")));
//            System.out.println(firstResult.getAttribute("textContent"));
//        } finally {
//            driver.quit();
//        }
//    }
//    @Test
//    public void XPath() {
//        RemoteWebDriver driver = chrome.getWebDriver();
//
//        driver.get("http://http://192.168.0.5:8080/krazosguide/index.html");
////         WebElement element = driver.findElement(By.id("h12"));
////         WebElement element = driver.findElement(By.id("country"));
//        //    WebElement element = driver.findElement(By.id("search"));
//
////     wait.until(ExpectedConditions.visibilityOfAllElementsLocatedBy(By.xpath("/html/body/input")));
////   WebElement element = driver.findElementByName("search");
//
//
//        WebDriverWait wait = new WebDriverWait(driver, 10);// 1 minute 
//        wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("///html/body/input")));
////        wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//*[@id=\"name\"]")));
//        
//       //  WebElement element =driver.findElement(By.xpath("//input[@value='paypal']"));  
////         WebElement element =driver.findElement(By.name("input"));  
//         WebElement element =driver.findElement(By.xpath("///html/body/input"));  
////  driver.findElement(By.name("search")).sendKeys("selenium");
//        
//
//        String country = element.getAttribute("value");
//        assertEquals("Panama", country);
//        driver.close();
//    }
//    @Test
//    public void indexhtml() {
//        RemoteWebDriver driver = chrome.getWebDriver();
////driver.switchTo().frame("UWPIFrame");
//        //driver.get("http://localhost:8080/krazosguide/mvc/app/view");
//        driver.get("http://192.168.0.5:8080/krazosguide/index.html");
////         WebElement element = driver.findElement(By.id("h12"));
////         WebElement element = driver.findElement(By.id("country"));
//        //    WebElement element = driver.findElement(By.id("search"));
//
////     wait.until(ExpectedConditions.visibilityOfAllElementsLocatedBy(By.xpath("/html/body/input")));
////   WebElement element = driver.findElementByName("search");
//
//
//        WebDriverWait wait = new WebDriverWait(driver, 10);// 1 minute 
//        wait.until(ExpectedConditions.visibilityOfElementLocated(By.name("search")));
////  driver.findElement(By.name("search")).sendKeys("selenium");
//        WebElement element = driver.findElement(By.name("search"));
//
//        String country = element.getAttribute("value");
//        assertEquals("Panama", country);
//        driver.close();
//    }
//    @Test
//    public void view() {
//        RemoteWebDriver driver = chrome.getWebDriver();
//
//        driver.get("http://192.168.0.5:8080/krazosguide/mvc/app/view");
//
//
//        WebDriverWait wait = new WebDriverWait(driver, 10);// 1 minute 
//        wait.until(ExpectedConditions.visibilityOfElementLocated(By.name("country")));
////  driver.findElement(By.name("search")).sendKeys("selenium");
//        WebElement element = driver.findElement(By.name("country"));
//
//        String country = element.getAttribute("value");
//        assertEquals("Panama", country);
//        driver.close();
//    }
//    @Test
//    public void google() {
//        RemoteWebDriver driver = chrome.getWebDriver();
//
//        WebDriverWait wait = new WebDriverWait(driver, 10);
//        try {
//            driver.get("https://google.com/ncr");
//            driver.findElement(By.name("q")).sendKeys("cheese" + Keys.ENTER);
//            WebElement firstResult = wait.until(presenceOfElementLocated(By.cssSelector("h3>div")));
//            System.out.println(firstResult.getAttribute("textContent"));
//            assertEquals(firstResult.getAttribute("textContent"), "[Show more]");
//        } finally {
//            driver.quit();
//        }
//    }
//   @Test
//    public void book() {
//        RemoteWebDriver driver = chrome.getWebDriver();
//
//        driver.get("http://localhost:8080/krazosguide/mvc/app/view");
//        WebElement element = driver.findElement(By.id("login"));
//    String value = element.getAttribute("value");
//    assertEquals("Login", value);
//    }
//    @Test
//    public void viewxpaht() {
//        RemoteWebDriver driver = chrome.getWebDriver(); 
//
//        driver.get("http://192.168.0.5:8080/krazosguide/index.html");
//
//        
//// 
//       String heading = driver.findElement(By.xpath("/html/body/h2"))
//           .getText();
//       assertEquals("Welcome from view", heading);
//    }
}

You can find the latest ChromeDriver on its . Now execute below commands to configure ChromeDriver on your system.

https://tecadmin.net/setup-selenium-chromedriver-on-ubuntu/
official download page
How to Setup Selenium with ChromeDriver on Ubuntu 20.04 & 18.04TecAdmin
Logo
Getting Started With Selenium In JavaSauce Labs
GitHub - avbravo/seleniumtest: seleniumtestGitHub
Logo
Logo