Giter VIP home page Giter VIP logo

theapp's Introduction

TheApp

This is a cross-platform test application used primarily to expose views useful for showcasing Appium automation features. There is also a test suite for the application the demonstrates good Appium testing practices. See the CI doc for a writeup on the most salient features of the test suite and how CI is achieved for this app.

Release versions of TheApp (typically as .apk and .app.zip are available at the Releases section of this repo.

Building locally

First, make sure you have the various React Native prerequisites ready to go (like Ruby, Gem, Bundler, Pod, etc... for iOS, Android Studio and tools for Android, etc...).

Then install deps:

npm install
pod install --project-directory=ios

Now you can npm start which will start the JS bundler.

Build/launch the iOS app

npx react-native run-ios

Build/launch the Android app

npx react-native run-android --appId=com.appiumpro.the_app --main-activity=com.appiumpro.the_app.MainActivity

Build the iOS app in release mode

Note this is not how to build an .ipa file (that requires signing and provisioning profiles). This just builds the .app which can be run on the simulator but with the JS bundle in it.

npx react-native run-ios --mode Release

The .app will be put in the Derived Data path (right-click on the output in the Xcode file viewer and you will be able to view it in the Finder).

Build the Android apk for release

cd android
./gradlew assembleRelease
# install and test the app
adb install -r ./app/build/outputs/apk/release/app-release.apk

Testing

You can run Appium tests locally on a running Android emulator or iOS simulator, after having first built the apps. Make sure you have an Appium 2.x server running with the XCUITest and UiAutomator2 drivers installed, then you can kick off a suite for either platform:

IOS=1 npm test     # run iOS suite
ANDROID=1 npm test # run Android suite

See the CI documentation for a fuller description of how the test suite is designed and implemented according to good Appium testing practices.

theapp's People

Contributors

jlipps avatar

Stargazers

Adriano Saadeh avatar Matheus Bereta avatar Jonatas Faria @QAJONATASMARTINS avatar Veera avatar Dzmitry Krakadzeyau avatar Sivasankaramalan Gunasekarasivam avatar Douglas Turner avatar JeanC Ch. H. avatar chenqiang avatar Nuttapon Pichetpongsa avatar Ihor avatar  avatar  avatar Sudharsan Selvaraj avatar Thiện Lâm avatar

Watchers

 avatar Denis Lukyanov avatar

theapp's Issues

No public method 'raiseToast' is defined on class com.appiumpro.the_app.MainApplication

Hi,
I was following through Jonathan Lipps's advanced appium course on Linkedin Learning. Also described in blog:
https://www.headspin.io/blog/calling-methods-inside-your-app-from-appium

In the lecture titled "State Shortcut3: Application backdoors", call to the application internal method raiseToast is made which should display a toast message on the screen titled "Hello from the test script!".

I initialized my driver with Espresso. Here is the test code:

ImmutableMap<String, Object> scriptArgs = ImmutableMap.of(
                "target", "application",
                "methods", Arrays.asList(ImmutableMap.of(
                        "name", "raiseToast",
                        "args", Arrays.asList(ImmutableMap.of(
                                "value", "Hello from the test script!",
                                "type", "String"
                        ))
                ))
        );

driver.executeScript("mobile: backdoor", scriptArgs);

When i executed my tests, I received the following error:
org.openqa.selenium.WebDriverException: An unknown server-side error occurred while processing the command. Original error: No public method 'raiseToast' is defined on class com.appiumpro.the_app.MainApplication or its parents which takes [class java.lang.String] arguments

I also tried to look for this method raiseToast in the application source code but i am unable to see this method both in the current version as well as deprecated version of the TheApp.

My test environment is setup as:

  • JDK 11.0.2
  • Appium 2.0.0-rc.3
  • appium-java-client 8.5.1
  • appium espresso driver 2.23.1
  • selenium-java 4.9.1
  • Node v18.16.0
  • NPM 9.6.7
  • macOS Ventura 13.4
  • Android emulator Pixel 5 with android 13

Here are the full logs of appium java client:

org.openqa.selenium.WebDriverException: An unknown server-side error occurred while processing the command. Original error: No public method 'raiseToast' is defined on class com.appiumpro.the_app.MainApplication or its parents which takes [class java.lang.String] arguments
Build info: version: '4.10.0', revision: 'c14d967899'
System info: os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.16', java.version: '11.0.2'
Driver info: io.appium.java_client.android.AndroidDriver
Command: [6cc38515-b7de-4c63-8a9b-1816dd1ce593, executeScript {script=mobile: backdoor, args=[{methods=[{name=raiseToast, args=[{type=String, value=Hello from the test script!}]}], target=application}]}]
Capabilities {appium:adbExecTimeout: 30000, appium:app: /Users/xxxx/dev/appium/Appi..., appium:autoGrantPermissions: true, appium:autoWebviewTimeout: 10000, appium:automationName: Espresso, appium:chromedriverExecutableDir: /Users/xxxx/dev/appium/Appi..., appium:udid: emulator-5554, platformName: ANDROID}
Session ID: 6cc38515-b7de-4c63-8a9b-1816dd1ce593

	at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
	at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:490)
	at org.openqa.selenium.remote.codec.w3c.W3CHttpResponseCodec.createException(W3CHttpResponseCodec.java:199)
	at org.openqa.selenium.remote.codec.w3c.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:132)
	at org.openqa.selenium.remote.codec.w3c.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:51)
	at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:191)
	at io.appium.java_client.remote.AppiumCommandExecutor.execute(AppiumCommandExecutor.java:250)
	at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:531)
	at org.openqa.selenium.remote.RemoteWebDriver.executeScript(RemoteWebDriver.java:476)
	at com.itkhanz.linkedin.advancedappium.tests.BackDoorTest.testBackdoor(BackDoorTest.java:62)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
	at org.testng.internal.invokers.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:139)
	at org.testng.internal.invokers.TestInvoker.invokeMethod(TestInvoker.java:664)
	at org.testng.internal.invokers.TestInvoker.invokeTestMethod(TestInvoker.java:227)
	at org.testng.internal.invokers.MethodRunner.runInSequence(MethodRunner.java:50)
	at org.testng.internal.invokers.TestInvoker$MethodInvocationAgent.invoke(TestInvoker.java:957)
	at org.testng.internal.invokers.TestInvoker.invokeTestMethods(TestInvoker.java:200)
	at org.testng.internal.invokers.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:148)
	at org.testng.internal.invokers.TestMethodWorker.run(TestMethodWorker.java:128)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1540)
	at org.testng.TestRunner.privateRun(TestRunner.java:848)
	at org.testng.TestRunner.run(TestRunner.java:621)
	at org.testng.SuiteRunner.runTest(SuiteRunner.java:443)
	at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:437)
	at org.testng.SuiteRunner.privateRun(SuiteRunner.java:397)
	at org.testng.SuiteRunner.run(SuiteRunner.java:336)
	at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
	at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:95)
	at org.testng.TestNG.runSuitesSequentially(TestNG.java:1280)
	at org.testng.TestNG.runSuitesLocally(TestNG.java:1200)
	at org.testng.TestNG.runSuites(TestNG.java:1114)
	at org.testng.TestNG.run(TestNG.java:1082)
	at com.intellij.rt.testng.IDEARemoteTestNG.run(IDEARemoteTestNG.java:66)
	at com.intellij.rt.testng.RemoteTestNGStarter.main(RemoteTestNGStarter.java:105)

Attached you will also find the appium server logs
appium-espressp-logs.txt

If we look closely at the logs, I can see that the appium sent the request to server but recieved response with staus code 500.

[HTTP] {"script":"mobile: backdoor","args":[{"methods":[{"name":"raiseToast","args":[{"type":"String","value":"Hello from the test script!"}]}],"target":"application"}]}
[debug] [EspressoDriver@478c (6cc38515)] Calling AppiumDriver.execute() with args: ["mobile: backdoor",[{"methods":[{"name":"raiseToast","args":[{"type":"String","value":"Hello from the test script!"}]}],"target":"application"}],"6cc38515-b7de-4c63-8a9b-1816dd1ce593"]
[EspressoDriver@478c (6cc38515)] Executing native command 'mobile: backdoor'
[debug] [EspressoDriver@478c (6cc38515)] Proxying [POST /appium/execute_mobile/backdoor] to [POST http://127.0.0.1:8301/session/b2686608-63f7-43ad-ad08-191fe9cca5e8/appium/execute_mobile/backdoor] with body: {"target":"application","methods":[{"name":"raiseToast","args":[{"type":"String","value":"Hello from the test script!"}]}]}
[EspressoDriver@478c (6cc38515)] Got response with status 500: {"id":"666996bc-9b6d-4c4a-8d48-2e94b0a3a75f","sessionId":"b2686608-63f7-43ad-ad08-191fe9cca5e8","value":{"error":"unknown error","message":"No public method 'raiseToast' is defined on class com.appiumpro.the_app.MainApplication or its parents which takes [class java.lang.String] arguments","stacktrace":"io.appium.espressoserver.lib.handlers.exceptions.AppiumException: No public method 'raiseToast' is defined on class com.appiumpro.the_app.MainApplication or its parents which takes [class java.lang.String] arguments\n\tat io.appium.espressoserver.lib.helpers.InvocationOperation.findCompatibleMethod(InvocationOperation.java:76)\n\tat io.appium.espressoserver.lib.helpers.InvocationOperation.apply(InvocationOperation.java:43)\n\tat io.appium.espressoserver.lib.handlers.MobileBackdoor.invokeBackdoorMethods(MobileBackdoor.kt:43)\n\tat io.appium.espressoserver.lib.handlers.MobileBackdoor.handleInternal(MobileBackdoor.kt:21)\n\tat io.appium.espressoserver.lib.handlers.MobileBackdoor.handleInternal(MobileBackdoor.k...
[debug] [W3C] Matched W3C error code 'unknown error' to UnknownError
[debug] [EspressoDriver@478c (6cc38515)] Encountered internal error running command: An unknown server-side error occurred while processing the command. Original error: No public method 'raiseToast' is defined on class com.appiumpro.the_app.MainApplication or its parents which takes [class java.lang.String] arguments
[debug] [EspressoDriver@478c (6cc38515)] io.appium.espressoserver.lib.handlers.exceptions.AppiumException: No public method 'raiseToast' is defined on class com.appiumpro.the_app.MainApplication or its parents which takes [class java.lang.String] arguments

Could you please verify if this method does not exist in the updated version of the app? and is there any alternative way to test the backdoor method of appium using this application?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.