tutorial español selenium-webdriver automated-tests appium

selenium webdriver - español - No se puede crear una nueva sesión remota mientras se prueba una aplicación de Android con Appium



appium selenium (3)

Olvidaste la capacidad más importante, que es el camino a la .apk:

capabilities.setCapability("app", "appPath");

Además, recomendaría cambiar de RemoteWebDriver a controlador de Android, ya que tendrá más funcionalidades:

driver = new AndroidDriver(....)

ps: puedes actualizar tu java-client a 4.1.2 y testng a 6.9.10

Estoy intentando ejecutar un ejemplo de scripts de prueba codificados con java en Eclipse con Appium. Ejecuto Appium por npm (estoy usando Appium 1.6.3, no soy nuevo en Appium lo ejecuto antes en Mac y en Windows sin ningún problema, pero esta vez en Ubuntu parece un poco diferente mientras que no está en el appium aplicación pero con consola)

appium --address 127.0.0.1

Estoy usando

  • java-client-4.1.2.jar
  • selenio-java-3.0.1.jar
  • selenium-server-standalone-3.0.1.jar
  • testng-6.9.10.jar

Y mi clase de Java es:

import io.appium.java_client.android.AndroidDriver; import io.appium.java_client.android.AndroidElement; import java.io.File; import java.net.MalformedURLException; import java.net.URL; import java.util.concurrent.TimeUnit; import org.testng.annotations.AfterClass; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.remote.DesiredCapabilities; import org.openqa.selenium.remote.RemoteWebDriver; public class FirstTest { AndroidDriver<AndroidElement> driver; File path = new File("/home/emna/Téléchargements/AutomationFiles/app-release.apk"); @BeforeClass public void setUp() throws MalformedURLException { System.out.println("app Dir.--->" + path); DesiredCapabilities capabilities = new DesiredCapabilities(); capabilities.setCapability("deviceName", "SM-G360H"); capabilities.setCapability("version", "4.4.4"); capabilities.setCapability("platformName", "Android"); capabilities.setCapability("platformVersion", "platform"); capabilities.setCapability("udid", "***************"); capabilities.setCapability("app", path.getAbsolutePath()); capabilities.setCapability("appPackage", "com.bulldozer.gaa"); capabilities.setCapability("appActivity", "com.bulldozer.gaa.activities.MainActivity"); driver = new AndroidDriver<AndroidElement>(new URL("http://127.0.0.1:4723/wd/hub"), capabilities); driver.manage().timeouts().implicitlyWait(15, TimeUnit.SECONDS); } @Test public void Test1() throws InterruptedException { // driver.wait(10000); System.out.println("GAA"); driver.findElement(By.id("acceptCheckbox")).click(); driver.findElement(By.id("continueBtn")).click(); } @AfterClass public void tearDown() { driver.quit(); } }

Pero el problema es que:

[TestNG] Running: /tmp/testng-eclipse--2049046107/testng-customsuite.xml app Dir.--->/home/emna/Téléchargements/AutomationFiles/app-release.apk Jan 24, 2017 1:14:44 PM org.openqa.selenium.remote.ProtocolHandshake createSession INFO: Attempting bi-dialect session, assuming Postel''s Law holds true on the remote end Jan 24, 2017 1:14:59 PM org.openqa.selenium.remote.ProtocolHandshake createSession INFO: Falling back to original OSS JSON Wire Protocol. Jan 24, 2017 1:15:10 PM org.openqa.selenium.remote.ProtocolHandshake createSession INFO: Falling back to straight W3C remote end connection FAILED CONFIGURATION: @BeforeClass setUp org.openqa.selenium.SessionNotCreatedException: Unable to create new remote session. desired capabilities = Capabilities [{app=/home/emna/Téléchargements/AutomationFiles/app-release.apk, appPackage=com.bulldozer.gaa, appActivity=com.bulldozer.gaa.activities.MainActivity, platformVersion=platform, platformName=Android, udid=*************, deviceName=SM-G360H, version=4.4.4}], required capabilities = Capabilities [{}] Build info: version: ''3.0.1'', revision: ''1969d75'', time: ''2016-10-18 09:48:19 -0700'' System info: host: ''tarek-Vostro-3902'', ip: ''127.0.1.1'', os.name: ''Linux'', os.arch: ''amd64'', os.version: ''4.4.0-59-generic'', java.version: ''1.8.0_91'' Driver info: driver.version: AndroidDriver at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:91) at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:141) at io.appium.java_client.remote.AppiumCommandExecutor.execute(AppiumCommandExecutor.java:69) at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:601) at io.appium.java_client.DefaultGenericMobileDriver.execute(DefaultGenericMobileDriver.java:40) at io.appium.java_client.AppiumDriver.execute(AppiumDriver.java:1)

Aquí el archivo de registro de Appium:

[debug] [ADB] Running ''/home/emna/Android/Sdk/platform-tools/adb'' with args: ["-P",5037,"-s","***************","shell","am","force-stop","io.appium.unlock"] [debug] [Logcat] Stopping logcat capture [debug] [AndroidDriver] Not cleaning generated files. Add `clearSystemFiles` capability if wanted. [MJSONWP] Encountered internal error running command: Error: Error occured while starting App. Original error: Permission to start activity denied. at Object.wrappedLogger.errorAndThrow (lib/logger.js:60:13) at ADB.callee$0$0$ (../../../lib/tools/apk-utils.js:80:9) at tryCatch (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:67:40) at GeneratorFunctionPrototype.invoke [as _invoke] (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:315:22) at GeneratorFunctionPrototype.prototype.(anonymous function) [as next] (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:100:21) at GeneratorFunctionPrototype.invoke (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:136:37) at process._tickCallback (internal/process/next_tick.js:103:7) [HTTP] <-- POST /wd/hub/session 500 11015 ms - 223 [HTTP] --> POST /wd/hub/session {"capabilities":{"desiredCapabilities":{"app":"/home/emna/Téléchargements/AutomationFiles/app-release.apk","appPackage":"com.bulldozer.gaa","appActivity":"com.bulldozer.gaa.activities.MainActivity","platformVersion":"platform","platformName":"Android","udid":"************","deviceName":"SM-G360H","version":"4.4.4"},"requiredCapabilities":{}}} [debug] [MJSONWP] Bad parameters: BadParametersError: Parameters were incorrect. We wanted {"required":["desiredCapabilities"],"optional":["requiredCapabilities","capabilities","sessionId","id","sessionId","id","sessionId","id"]} and you sent ["capabilities"] [HTTP] <-- POST /wd/hub/session 400 5 ms - 205


El motivo es porque Appium ya ejecuta la aplicación usando la configuración de la GUI.

Al mismo tiempo, intenta volver a ejecutarlo desde su código.

Lo que debería ayudar: en Appium UI, vaya a la configuración de Android (básica)

  1. Panel de aplicaciones: no define / inicia la aplicación y sus actividades.

  2. Panel de capacidades: defina y seleccione {Nombre de la plataforma, nombre de la automatización, versión de la plataforma}


El problema es con el archivo apk en sí, utilicé otro. apk file con la misma configuración que he usado y funciona bien!