Appium + Selenium

Dear
I’m doing an automation of a hybrid application and it throws me the following error.

org.openqa.selenium.WebDriverException: unknown error: operation is unsupported on Android
(Session info: webview=33.0.0.0)
(Driver info: chromedriver=2.33.506120 (e3e53437346286c0bc2d2dc9aa4915ba81d9023f),platform=Windows NT 6.1.7601 SP1 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 81 milliseconds
Build info: version: ‘unknown’, revision: ‘unknown’, time: ‘unknown’
System info: host: ‘SAN-CMGCF72’, ip: ‘192.168.0.107’, os.name: ‘Windows 7’, os.arch: ‘amd64’, os.version: ‘6.1’, java.version: ‘1.8.0_141’
Driver info: io.appium.java_client.android.AndroidDriver
Capabilities [{applicationCacheEnabled=false, rotatable=false, mobileEmulationEnabled=false, chrome={chromedriverVersion=2.33.506120 (e3e53437346286c0bc2d2dc9aa4915ba81d9023f)}, takesHeapSnapshot=true, pageLoadStrategy=normal, databaseEnabled=false, handlesAlerts=true, hasTouchScreen=false, version=33.0.0.0, platform=ANDROID, browserConnectionEnabled=false, nativeEvents=true, acceptSslCerts=true, locationContextEnabled=true, webStorageEnabled=true, browserName=chrome, takesScreenshot=true, javascriptEnabled=true, cssSelectorsEnabled=true, setWindowRect=false, unexpectedAlertBehaviour=}]
Session ID: 02a819e9-d85d-4c6f-bd6e-8011aaba4bb3
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:216)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:168)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:638)
at io.appium.java_client.DefaultGenericMobileDriver.execute(DefaultGenericMobileDriver.java:46)
at io.appium.java_client.AppiumDriver.execute(AppiumDriver.java:1)
at io.appium.java_client.android.AndroidDriver.execute(AndroidDriver.java:1)
at org.openqa.selenium.remote.RemoteWebDriver$RemoteWebDriverOptions$RemoteWindow.maximize(RemoteWebDriver.java:895)
at com.everis.EFASelenium.startSelenium(EFASelenium.java:216)
at com.everis.EFA.cs_startTool(EFA.java:75)
at com.everis.Manager.loadDriver(Manager.java:53)
at com.everis.EFASelenium.setCapabilitiesSelenium(EFASelenium.java:567)
at com.everis.EFA.setCapabilities(EFA.java:792)
at BelieveMobile.HomeMobile.beforeTest(HomeMobile.java:94)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:24)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
at org.junit.rules.TestWatcher$1.evaluate(TestWatcher.java:55)
at org.junit.rules.RunRules.evaluate(RunRules.java:20)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.junit.runners.Suite.runChild(Suite.java:128)
at org.junit.runners.Suite.runChild(Suite.java:27)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)

java.lang.AssertionError: Expected $ 200 but was null
at org.junit.Assert.fail(Assert.java:88)
at com.everis.EFA.finishExecution(EFA.java:1232)
at com.everis.webautomation.ExecutionWrapper.afterRunTest(ExecutionWrapper.java:74)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:33)
at org.junit.rules.TestWatcher$1.evaluate(TestWatcher.java:55)
at org.junit.rules.RunRules.evaluate(RunRules.java:20)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.junit.runners.Suite.runChild(Suite.java:128)
at org.junit.runners.Suite.runChild(Suite.java:27)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)

Your post is not clear, you didnt post any code what exactly you are trying.

from the logs i can make it out, appium is working fine but some thing wrong with your element identification. May be you are not fetching values from right element. that is the reason you are getting null value, i think you are using gettext method.

Correct your element identification and try it again, if that doesn’t works, post the full code next time with more details.

@kumarsiva This is the code that I am using.

package BelieveMobile;

import java.io.File;
import java.io.IOException;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.List;

import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.junit.runners.Parameterized.Parameters;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.remote.DesiredCapabilities;

import com.everis.Action;
import com.everis.EFA;
import com.everis.Element;
import com.everis.ExecutionInfo;
import com.everis.GlobalData;
import com.everis.data.DataDictionary;
import com.everis.webautomation.ExecutionWrapper;

import Believe.Mobile.Pages.BelieveMain;
import Believe.web.pages.HomePage;
import android.pages.ConsultarContato;
import android.pages.NewSMS;
import io.appium.java_client.android.AndroidDriver;
import io.appium.java_client.remote.MobileCapabilityType;
import io.appium.java_client.remote.MobilePlatform;


@RunWith(Parameterized.class)
public class HomeMobile extends ExecutionWrapper
{
	String mensaje="";
	BelieveMain page;
	BelieveMain formulario = new BelieveMain();
	/**
	 * Script: Web simple form test
	 * 
	 * @param executionName
	 *            Test name
	 * @param data
	 *            Data for current interaction
	 * @throws Exception 
	 */
	public HomeMobile(String executionName, DataDictionary data)
	{
		ExecutionInfo.setExecutionName(executionName);
		ExecutionInfo.setTestPlanName("xXXXXX");
		// Fill Global Dictionary
		GlobalData.load(data);
	}

	/**
	 * Load data for all interactions
	 * 
	 * @return List all interactions with data for the test
	 * @throws Exception
	 */
	@Parameters(name = "{0}")
	public static List<Object> loadTestData() throws Exception
	{
		// Call data loader for all interactions
		return loadData();
	}
	/**
	 * Scenario - Precondition for the test
	 * 
	 * @throws IOException
	 * @throws IllegalArgumentException
	 */
	@Before
	public void beforeTest() throws Exception
	{
		page = new BelieveMain();
		File app = new File("src/test/resources/android/android-26Oct2017.apk");
		DesiredCapabilities cap = new DesiredCapabilities();
		cap.setCapability("appActivity", GlobalData.getData("AppActivity"));
		cap.setCapability("appPackage", GlobalData.getData("AppPackage"));
		//cap.setCapability("platformName", GlobalData.getData("Device"));
		//cap.setCapability("deviceName", GlobalData.getData("DeviceName"));
		cap.setCapability("platformVersion", GlobalData.getData("PlatformVersion"));
		cap.setCapability(MobileCapabilityType.PLATFORM_NAME, MobilePlatform.ANDROID);
		cap.setCapability(MobileCapabilityType.DEVICE_NAME, GlobalData.getData("DeviceName"));
		cap.setCapability(MobileCapabilityType.AUTO_WEBVIEW, true);
		cap.setCapability(MobileCapabilityType.APP, app.getAbsolutePath());
		//AndroidDriver<WebElement> driver = new AndroidDriver<>(new URL("http://127.0.0.1:4723/wd/hub"), cap);
		if (((AndroidDriver) EFA.cv_driver) == null)
			EFA.setCapabilities(cap);
		EFA.loadExecutionInfo();
	}

	/**
	 * Simple example
	 */
	@Test
	public void script() throws MalformedURLException 
	{
		try
		{	
			EFA.waitForPageToLoad(120000);
			formulario.type();
			switch (GlobalData.getData("Test Case")){
			case "Caso 1":
				mensaje = (String)EFA.executeAction(Action.GetText, new Element("xpath", "//DIV[@id='divSaldoActivo']"));
				EFA.executeAction(Action.Click, new Element("xpath", "//div[@id='tab_perfil']"));
				EFA.executeAction(Action.Click, new Element("xpath", "//div[@class='icon-salir']"));
			break;
			case "Caso 2":
				EFA.executeAction(Action.WaitForElementPresent, new Element("xpath", "//div[@class='header-numero ng-binding'][text()='"+GlobalData.getData("vNum")+"']"));
				mensaje = (String)EFA.executeAction(Action.GetText, new Element("xpath", "//DIV[@id='divSaldoActual']"));
				EFA.executeAction(Action.Click, new Element("xpath", "//div[@id='tab_perfil']"));
				EFA.executeAction(Action.Click, new Element("xpath", "//div[@class='icon-salir']"));
			break;
			
default:
			break;
			}
		}
		
		
		catch (Exception e)
		{
			StringWriter sw = new StringWriter();
			PrintWriter pw = new PrintWriter(sw);
			e.printStackTrace(pw);
			// stack trace as a string
			EFA.stackTrace = sw.toString();
		}
		finally
		{
		
		}
		ExecutionInfo.setResult(mensaje);

	}

}


package Believe.Mobile.Pages;

import org.openqa.selenium.remote.DesiredCapabilities;

import com.everis.Action;
import com.everis.EFA;
import com.everis.Element;
import com.everis.GlobalData;

//Steps
public class BelieveMain {
		
	public void type() throws Exception{
	
		EFA.executeAction(Action.SendKeys, new Element("id", "loginRut"),GlobalData.getData("vRut"));
		EFA.executeAction(Action.SendKeys, new Element("id", "contraseña"),GlobalData.getData("vPassword"));
		EFA.executeAction(Action.Click, new Element("xpath", "//BUTTON[@id='submit']"));
		//EFA.waitForPageToLoad(120000);
		EFA.executeAction(Action.WaitForElementPresent, new Element("xpath", "//div[@id='seleccionarLinea']"));
		EFA.executeAction(Action.Click, new Element("xpath", "//div[@id='seleccionarLinea']"));
		//Espera hasta encontrar el objeto
		EFA.executeAction(Action.WaitForElementPresent, new Element("xpath", "//SPAN[@class='ng-binding'][text()='"+GlobalData.getData("vNum")+"']"));
		//Enfoca exactamente en el objeto
		//EFA.executeAction(Action.SendKeys, new Element("xpath", "//SPAN[@class='ng-binding'][text()='"+GlobalData.getData("vNum")+"']"), (""));
		EFA.executeAction(Action.Click, new Element("xpath", "//SPAN[@class='ng-binding'][text()='"+GlobalData.getData("vNum")+"']"));
		EFA.executeAction(Action.WaitForElementPresent, new Element("xpath", "//BUTTON[@id='recargar_home']"));
		//EFA.executeAction(Action.Click, new Element("xpath", "//BUTTON[@id='recargar_home']"));
		//EFA.waitForPageToLoad(120000);
		//SPAN[@class='ng-binding'][text()='991862579']
	}
		
}

You are getting null pointer exception in EFA file at line 1232. So look at that line, and check the given element text fetching code is correct or not. Run your script in debug mode by keeping a break point before to this line, after reaching this line execute step by step. then only you can make it out why null value returning from your element.

Thans @kumarsiva I’ll try to do it, to see how it’s going