Code Monkey home page Code Monkey logo

appium-android-driver's Introduction

Stand With Ukraine

Appium

Cross-platform test automation for native, hybrid, mobile web and desktop apps.

NPM version Monthly Downloads FOSSA Status StandWithUkraine


Documentation | Get Started | Ecosystem | Changelog | Roadmap | Discussion Forum


Appium is an open-source automation framework that provides WebDriver-based automation possibilities for a wide range of different mobile, desktop and IoT platforms. Appium is modular and extensible, and supports multiple programming languages, which means there is an entire ecosystem of related software:

  • Drivers add support for automating specific platforms
  • Clients allow writing Appium tests in your programming language of choice
  • Plugins allow to further extend Appium functionality

Migrating From Appium 1 to Appium 2

As of January 1st, 2022, the Appium team no longer maintains or supports Appium 1. All officially supported platform drivers are only compatible with Appium 2.

Please read the Migration Guide if you are still using Appium 1.

Warning

If you use Appium Desktop or Appium Server GUI, you will not be able to upgrade to Appium 2, as both of these tools have been deprecated. Please use Appium Inspector in combination with a standalone Appium 2 server.

Installation

Appium can be installed using npm (other package managers are not currently supported). Please check the installation docs for the system requirements and further information.

If upgrading from Appium 1, make sure Appium 1 is fully uninstalled (npm uninstall -g appium). Unexpected errors might appear if this has not been done.

npm i -g appium

Note that this will only install the core Appium server, which cannot automate anything on its own. Please install drivers for your target platforms in order to automate them.

Drivers

Appium supports app automation across a variety of platforms, like iOS, Android, macOS, Windows, and more. Each platform is supported by one or more "drivers", which know how to automate that particular platform. You can find a full list of officially-supported and third-party drivers in Appium Ecosystem's Drivers page.

Driver management is done using Appium's Extension command-line interface:

# Install an official driver from npm (see documentation for a list of such drivers)
appium driver install <driver-name>
# Install any driver from npm
appium driver install --source=npm <driver-name>
# See documentation for installation from other sources

# List already installed drivers
appium driver list --installed
# Update a driver (it must be already installed)
# This will NOT update the major version, in order to prevent breaking changes
appium driver update <driver-name>
# Update a driver to the most recent version (may include breaking changes)
appium driver update <driver-name> --unsafe
# Uninstall a driver (it won't last forever, will it?)
appium driver uninstall <driver-name>

Clients

Client libraries enable writing Appium tests in different programming languages. There are officially-supported clients for Java, Python, Ruby, and .NET C#, as well as third-party clients for other languages. You can find a full list of clients in Appium Ecosystem's Clients page.

Plugins

Plugins allow you to extend server functionality without changing the server code. The main difference between drivers and plugins is that the latter must be explicitly enabled on Appium server startup (all installed drivers are enabled by default):

appium --use-plugins=<plugin-name>

You can find a full list of officially-supported and third-party plugins in Appium Ecosystem's Plugins page.

Similarly to drivers, plugin management is also done using Appium's Extension command-line interface:

# Install an official plugin from npm (see documentation for a list of such plugins)
appium plugin install <plugin-name>
# Install any plugin from npm
appium plugin install --source=npm <plugin-name>
# See documentation for installation from other sources

# List already installed plugins
appium plugin list --installed
# Update a plugin (it must be already installed)
# This will NOT update the major version, in order to prevent breaking changes
appium plugin update <plugin-name>
# Update a plugin to the most recent version (may include breaking changes)
appium plugin update <plugin-name> --unsafe
# Uninstall a plugin
appium plugin uninstall <plugin-name>

Server Command Line Interface

In order to start sending commands to the Appium server, it must be running on the URL and port where your client library expects it to listen. Appium's command-line interface is used to launch and configure the server:

# Start the server on the default host (0.0.0.0) and port (4723)
appium server
# You can also omit the 'server' subcommand
appium
# Start the server on the given host, port and use a custom base path prefix (the default prefix is '/')
appium --address 127.0.0.1 --port 9000 --base-path /wd/hub

Appium supports execution of parallel server processes, as well as parallel driver sessions within a single server process. Refer the corresponding driver documentations regarding which mode is optimal for the particular driver or whether it supports parallel sessions.

Why Appium?

  1. You usually don't have to recompile your app or modify it in any way, due to the use of standard automation APIs on all platforms.
  2. You can write tests with your favorite dev tools using any WebDriver-compatible language such as Java, Python, Ruby and C#. There are also third party client implementations for other languages.
  3. You can use any testing framework.
  4. Some drivers like xcuitest and uiautomator2 have built-in mobile web and hybrid app support. Within the same script, you can switch seamlessly between native app automation and webview automation, all using the WebDriver model that's already the standard for web automation.
  5. You can run your automated tests locally and in a cloud. There are multiple cloud providers that support various Appium drivers (mostly targeting iOS and Android mobile automation).
  6. Appium Inspector can be used to visually inspect the page source of applications across different platforms, facilitating easier test development.

Investing in the WebDriver protocol means you are betting on a single, free, and open protocol for testing that has become a web standard. Don't lock yourself into a proprietary stack.

For example, if you use Apple's XCUITest library without Appium, you can only write tests using Obj-C/Swift, and you can only run tests through Xcode. Similarly, with Google's UiAutomator or Espresso, you can only write tests in Java/Kotlin. Appium opens up the possibility of true cross-platform native app automation, for mobile and beyond!

If you are looking for a more comprehensive description of what this is all about, please read our documentation on How Does Appium Work?.

Sponsors

Appium has a Sponsorship Program! If you or your company uses Appium and wants to give back financially to the project, we use these funds to encourage development and contributions, as well as support other open source projects we rely on. Become a sponsor via our OpenCollective page.

Development and Strategic Partners

Appium is incredibly grateful to our Development and Strategic Partners for their sustained contribution of project development and leadership!

HeadSpin

Browserstack

Sauce Labs

Other Sponsors

A full list of sponsors is available at our Sponsors page.

License

Apache-2.0

FOSSA Status

@appium/logger package is under ISC License.

appium-android-driver's People

Contributors

alizelzele avatar anandsadu avatar blutter avatar boneskull avatar christian-bromann avatar dependabot-preview[bot] avatar dependabot[bot] avatar dpgraham avatar greenkeeper[bot] avatar heeseon avatar imurchie avatar jlipps avatar jonahss avatar kazucocoa avatar midopa avatar moizjv avatar mwakizaka avatar mykola-mokhnach avatar neofreko avatar rgonalo avatar scottdixon avatar semantic-release-bot avatar spearminty avatar sravanmedarapu avatar srinivasantarget avatar tiagoshibata avatar vmaxim avatar vrunoa avatar yaphatak avatar yaumu3 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

appium-android-driver's Issues

Action required: Greenkeeper could not be activated 🚨

🚨 You need to enable Continuous Integration on Greenkeeper branches of this repository. 🚨

To enable Greenkeeper, you need to make sure that a commit status is reported on all branches. This is required by Greenkeeper because it uses your CI build statuses to figure out when to notify you about breaking changes.

Since we didn’t receive a CI status on the greenkeeper/initial branch, it’s possible that you don’t have CI set up yet. We recommend using Travis CI, but Greenkeeper will work with every other CI service as well.

If you have already set up a CI for this repository, you might need to check how it’s configured. Make sure it is set to run on all new branches. If you don’t want it to run on absolutely every branch, you can whitelist branches starting with greenkeeper/.

Once you have installed and configured CI on this repository correctly, you’ll need to re-trigger Greenkeeper’s initial pull request. To do this, please click the 'fix repo' button on account.greenkeeper.io.

Support touch actions that don't start with press

Hi all! I have one more request for a fix on touch actions.

The problem

For some specific tests I'd like to be able to start a drag action and then zoom in the screen (start with a single finger and later touch another finger). The following Python code exemplifies my desired behavior:

#!/usr/bin/env python3
import appium
from appium.webdriver.common.touch_action import TouchAction
from appium.webdriver.common.multi_action import MultiAction

capabilities = {
    'appActivity': "<activity>",
    'appPackage': "<package>",
    'deviceName': "Android",
    'platformName': "Android",
    'noReset': False
}

webdriver = appium.webdriver.Remote("http://localhost:4723/wd/hub", capabilities)
try:
    contact_1 = TouchAction(webdriver).press(x=14, y=14).wait(5).move_to(x=5, y=-5).release()
    contact_2 = TouchAction(webdriver).wait(5).press(x=24, y=24).wait(5).move_to(x=0, y=4).release()
    multi_touch = MultiAction(webdriver)
    multi_touch.add(contact_1)
    multi_touch.add(contact_2)
    multi_touch.perform()
finally:
    webdriver.quit()

However, Appium crashes when the touch action doesn't start with a press checking the yet undefined x/y coordinates. In the example above, it crashes on the second contact, which starts with wait.

Environment

  • Appium version (or git revision) that exhibits the issue: e026a14141230416e945fb6b49883b9993833f31
  • Desktop OS/version used to run Appium: Linux
  • Node.js version: v6.3.0
  • Mobile platform/version under test: Android
  • Real device
  • Appium CLI

Link to Appium logs

Here, relevant parts:

[HTTP] --> POST /wd/hub/session/52783d80-5081-4bcc-8c45-4b8ca858a159/touch/multi/perform {"sessionId":"52783d80-5081-4bcc-8c45-4b8ca858a159","actions":[[{"action":"press","options":{"x":14,"y":14}},{"action":"moveTo","options":{"x":5,"y":-5}},{"action":"release","options":{}}],[{"action":"wait","options":{"ms":5}},{"action":"press","options":{"x":24,"y":24}},{"action":"moveTo","options":{"x":0,"y":4}},{"action":"release","options":{}}]]}
[MJSONWP] Calling AppiumDriver.performMultiAction() with args: [[[{"action":"press","optio...
[MJSONWP] Encountered internal error running command: TypeError: Cannot read property 'x' of null
    at AndroidDriver.callee$0$0$ (lib/commands/touch.js:258:32)
    at tryCatch (/home/tiago/code/appium/node_modules/babel-runtime/regenerator/runtime.js:67:40)
    at GeneratorFunctionPrototype.invoke [as _invoke] (/home/tiago/code/appium/node_modules/babel-runtime/regenerator/runtime.js:315:22)
    at GeneratorFunctionPrototype.prototype.(anonymous function) [as next] (/home/tiago/code/appium/node_modules/babel-runtime/regenerator/runtime.js:100:21)
    at GeneratorFunctionPrototype.invoke (/home/tiago/code/appium/node_modules/babel-runtime/regenerator/runtime.js:136:37)

Code To Reproduce Issue

Given above.


Could some of you provide a fix? I might try to get a PR done if you guys are busy with other issues.

Thanks!

touch actions & 'cancel'

"Rethink the gesture API in light of spec changes. Cancel might not even be there."

commands.doTouchAction = async function (action, opts) {
   ...
    case 'cancel':
      // TODO: clarify behavior of 'cancel' action and fix this
      log.warn("Cancel action currently has no effect");
      break;
   ...

touchMultiPerform fails with error Cannot read property 'action' of undefined

[debug] [MJSONWP] Calling AppiumDriver.performMultiAction() with args: [[{"action":"press","options":{"x":100,"y":250}},{"action":"moveTo","options":{"x":300,"y":100}},{"action":"release"}],null,null,null,null,null,"cdb0e76b-e809-4ce5-a52e-1a83766464e0"]
[MJSONWP] Encountered internal error running command: TypeError: Cannot read property 'action' of undefined
    at AndroidDriver.callee$0$0$ (../../../lib/commands/touch.js:198:32)
    at tryCatch (C:\Users\andrey.pshenkin\AppData\Roaming\npm\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:67:40)
    at GeneratorFunctionPrototype.invoke [as _invoke] (C:\Users\andrey.pshenkin\AppData\Roaming\npm\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:315:22)
    at GeneratorFunctionPrototype.prototype.(anonymous function) [as next] (C:\Users\andrey.pshenkin\AppData\Roaming\npm\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:100:21)
    at invoke (C:\Users\andrey.pshenkin\AppData\Roaming\npm\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:136:37)
    at enqueueResult (C:\Users\andrey.pshenkin\AppData\Roaming\npm\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:185:17)
    at Promise.F (C:\Users\andrey.pshenkin\AppData\Roaming\npm\node_modules\appium\node_modules\core-js\library\modules\$.export.js:30:36)
    at AsyncIterator.enqueue (C:\Users\andrey.pshenkin\AppData\Roaming\npm\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:184:12)
    at AsyncIterator.prototype.(anonymous function) [as next] (C:\Users\andrey.pshenkin\AppData\Roaming\npm\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:100:21)
    at Object.runtime.async (C:\Users\andrey.pshenkin\AppData\Roaming\npm\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:209:12)
    at AndroidDriver.callee$0$0 (../../../lib/commands/touch.js:271:21)
    at AndroidDriver.callee$1$0$ (../../../lib/commands/touch.js:301:23)
    at tryCatch (C:\Users\andrey.pshenkin\AppData\Roaming\npm\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:67:40)
    at GeneratorFunctionPrototype.invoke [as _invoke] (C:\Users\andrey.pshenkin\AppData\Roaming\npm\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:315:22)
    at GeneratorFunctionPrototype.prototype.(anonymous function) [as next] (C:\Users\andrey.pshenkin\AppData\Roaming\npm\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:100:21)
    at invoke (C:\Users\andrey.pshenkin\AppData\Roaming\npm\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:136:37)
    at enqueueResult (C:\Users\andrey.pshenkin\AppData\Roaming\npm\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:185:17)
    at Promise.F (C:\Users\andrey.pshenkin\AppData\Roaming\npm\node_modules\appium\node_modules\core-js\library\modules\$.export.js:30:36)
    at AsyncIterator.enqueue (C:\Users\andrey.pshenkin\AppData\Roaming\npm\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:184:12)
    at AsyncIterator.prototype.(anonymous function) [as next] (C:\Users\andrey.pshenkin\AppData\Roaming\npm\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:100:21)
    at Object.runtime.async (C:\Users\andrey.pshenkin\AppData\Roaming\npm\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:209:12)
    at callee$1$0 (../../../lib/commands/touch.js:300:53)
    at asyncmap$ (lib/asyncbox.js:75:24)
    at tryCatch (C:\Users\andrey.pshenkin\AppData\Roaming\npm\node_modules\appium\node_modules\asyncbox\node_modules\babel-runtime\regenerator\runtime.js:67:40)
    at GeneratorFunctionPrototype.invoke [as _invoke] (C:\Users\andrey.pshenkin\AppData\Roaming\npm\node_modules\appium\node_modules\asyncbox\node_modules\babel-runtime\regenerator\runtime.js:294:22)
    at GeneratorFunctionPrototype.prototype.(anonymous function) [as next] (C:\Users\andrey.pshenkin\AppData\Roaming\npm\node_modules\appium\node_modules\asyncbox\node_modules\babel-runtime\regenerator\runtime.js:100:21)
    at invoke (C:\Users\andrey.pshenkin\AppData\Roaming\npm\node_modules\appium\node_modules\asyncbox\node_modules\babel-runtime\regenerator\runtime.js:136:37)
    at enqueueResult (C:\Users\andrey.pshenkin\AppData\Roaming\npm\node_modules\appium\node_modules\asyncbox\node_modules\babel-runtime\regenerator\runtime.js:167:17)
    at Promise.exp (C:\Users\andrey.pshenkin\AppData\Roaming\npm\node_modules\appium\node_modules\asyncbox\node_modules\core-js\library\modules\$.def.js:38:36)
    at AsyncIterator.enqueue (C:\Users\andrey.pshenkin\AppData\Roaming\npm\node_modules\appium\node_modules\asyncbox\node_modules\babel-runtime\regenerator\runtime.js:166:12)
    at AsyncIterator.prototype.(anonymous function) [as next] (C:\Users\andrey.pshenkin\AppData\Roaming\npm\node_modules\appium\node_modules\asyncbox\node_modules\babel-runtime\regenerator\runtime.js:100:21)
    at Object.runtime.async (C:\Users\andrey.pshenkin\AppData\Roaming\npm\node_modules\appium\node_modules\asyncbox\node_modules\babel-runtime\regenerator\runtime.js:192:12)
    at asyncmap (lib/asyncbox.js:74:16)
    at AndroidDriver.callee$0$0$ (../../../lib/commands/touch.js:300:22)
    at tryCatch (C:\Users\andrey.pshenkin\AppData\Roaming\npm\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:67:40)
    at GeneratorFunctionPrototype.invoke [as _invoke] (C:\Users\andrey.pshenkin\AppData\Roaming\npm\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:315:22)
    at GeneratorFunctionPrototype.prototype.(anonymous function) [as next] (C:\Users\andrey.pshenkin\AppData\Roaming\npm\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:100:21)
    at invoke (C:\Users\andrey.pshenkin\AppData\Roaming\npm\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:136:37)
    at enqueueResult (C:\Users\andrey.pshenkin\AppData\Roaming\npm\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:185:17)
    at Promise.F (C:\Users\andrey.pshenkin\AppData\Roaming\npm\node_modules\appium\node_modules\core-js\library\modules\$.export.js:30:36)
    at AsyncIterator.enqueue (C:\Users\andrey.pshenkin\AppData\Roaming\npm\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:184:12)
    at AsyncIterator.prototype.(anonymous function) [as next] (C:\Users\andrey.pshenkin\AppData\Roaming\npm\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:100:21)
    at Object.runtime.async (C:\Users\andrey.pshenkin\AppData\Roaming\npm\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:209:12)
    at AndroidDriver.callee$0$0 [as performMultiAction] (../../../lib/commands/touch.js:300:13)
    at ../../../lib/basedriver/driver.js:173:24
    at tryCatcher (C:\Users\andrey.pshenkin\AppData\Roaming\npm\node_modules\appium\node_modules\bluebird\js\main\util.js:26:23)
    at Promise._settlePromiseFromHandler (C:\Users\andrey.pshenkin\AppData\Roaming\npm\node_modules\appium\node_modules\bluebird\js\main\promise.js:510:31)
    at Promise._settlePromiseAt (C:\Users\andrey.pshenkin\AppData\Roaming\npm\node_modules\appium\node_modules\bluebird\js\main\promise.js:584:18)
    at Promise._settlePromiseAtPostResolution (C:\Users\andrey.pshenkin\AppData\Roaming\npm\node_modules\appium\node_modules\bluebird\js\main\promise.js:248:10)
    at Async._drainQueue (C:\Users\andrey.pshenkin\AppData\Roaming\npm\node_modules\appium\node_modules\bluebird\js\main\async.js:128:12)
    at Async._drainQueues (C:\Users\andrey.pshenkin\AppData\Roaming\npm\node_modules\appium\node_modules\bluebird\js\main\async.js:133:10)
    at Immediate.Async.drainQueues (C:\Users\andrey.pshenkin\AppData\Roaming\npm\node_modules\appium\node_modules\bluebird\js\main\async.js:15:14)
    at runCallback (timers.js:637:20)
    at tryOnImmediate (timers.js:610:5)
    at processImmediate [as _immediateCallback] (timers.js:582:5)
[HTTP] <-- POST /wd/hub/session/cdb0e76b-e809-4ce5-a52e-1a83766464e0/touch/multi/perform 500 26 ms - 213

appium version: 1.6.1
Node version 6.9.1

Cannot create new session after run few sessions

I wrote a test script to measure long run capability of Appium.
However after a few sessions, the appium stub at create new session

[debug] [JSONWP Proxy] Proxying [POST /session] to [POST http://127.0.0.1:8000/wd/hub/session] with body: {"desiredCapabilities":{"chromeOptions":{"androidPackage":"com.android.chrome","androidDeviceSerial":"988633304d4b323634"}}}

I used 'adb' to check "chrome" process on device and see that many chrome processes are leaking

./adb shell ps | grep chrome                        
u0_a85    2757  3184  1578696 194580 SyS_epoll_ 0000000000 S com.android.chrome
u0_i39    2804  3184  1201756 86092 SyS_epoll_ 0000000000 S com.android.chrome:sandboxed_process0
u0_a85    2836  3184  1212104 93312 SyS_epoll_ 0000000000 S com.android.chrome:privileged_process0
u0_a86    10842 3183  1664788 59756 SyS_epoll_ 0000000000 S com.sec.android.app.chromecustomizations
u0_a85    30465 3184  1548556 182592 SyS_epoll_ 0000000000 S com.android.chrome
u0_a85    30671 3184  1234504 89732 SyS_epoll_ 0000000000 S com.android.chrome

Because my device is non-root so I cannot kill "chrome" process by 'shell pkill' or 'am force-stop com.android.chrome'.
Now my device cannot work with appium any more until restarting to clean up leaking processes

Environment:
Appium: 1.6.1/1.6.2
Chromedriver: 2.25
Nodejs: v6.8.0
NPM: 3.10.8

Device:
Galaxy S7: SM-G930F
Android: 6.0.1
Chrome: 54.0.2840.85

Start commands:

  • Appium
    node build/lib/main.js --command-timeout "7200" --debug-log-spacing --default-capabilities '{"platformName":"Android"}' --default-device

  • Client
    UDID=988633304d4b323634 PLATFORM=Android npm run wd

Appium's log: https://gist.github.com/nghiadhd/88c8bf0e14ac32f2f47f3e3052d2ddfa
Testscript: https://gist.github.com/nghiadhd/8388fe2b2e9e1917298e0b9d4d52d952

npm install task is running iOS tests

A snippet of my log when running npm install on this project

> [email protected] install /Users/malugus/Code/appium-android-driver/node_modules/fsevents
> node-pre-gyp install --fallback-to-build

[fsevents] Success: "/Users/malugus/Code/appium-android-driver/node_modules/fsevents/lib/binding/Release/node-v47-darwin-x64/fse.node" is installed via remote

> [email protected] install /Users/malugus/Code/appium-android-driver/node_modules/ios-webview-app
> node -e "require('grunt').tasks(['default']);"

Running "cleanAll" task

Running "clean:iphonesimulator9.2" (clean) task

Running "clean:iphoneos9.2" (clean) task

Running "buildAll" task

Running "build:iphonesimulator9.2" (build) task
Building app...done building ios app for idk iphonesimulator9.2
Running "build:iphoneos9.2" (build) task
Building app...>> Failed building app
>> Build settings from command line:
>>     SDKROOT = iphoneos9.2
>> 
>> === BUILD TARGET WebViewApp OF PROJECT WebViewApp WITH THE DEFAULT CONFIGURATION (Release) ===
>> 
>> Check dependencies
>> Code Sign error: No code signing identities found: No valid signing identities (i.e. certificate and private key pair) were found.
>> 
>> ** BUILD FAILED **
>> 
>> 
>> The following build commands failed:
>>  Check dependencies
>> (1 failure)

Running "renameAll" task

> [email protected] install /Users/malugus/Code/appium-android-driver/node_modules/ios-uicatalog
> node -e "require('grunt').tasks(['default']);"

Running "cleanAll" task

Running "clean:iphonesimulator9.2" (clean) task

Running "clean:iphoneos9.2" (clean) task

Running "buildAll" task

Running "build:iphonesimulator9.2" (build) task
Building app...done building ios app for idk iphonesimulator9.2
Running "build:iphoneos9.2" (build) task
Building app...>> Failed building app
>> Build settings from command line:
>>     SDKROOT = iphoneos9.2
>> 
>> === BUILD TARGET UICatalog OF PROJECT UICatalog WITH THE DEFAULT CONFIGURATION (Release) ===
>> 
>> Check dependencies
>> Code Sign error: No code signing identities found: No valid signing identities (i.e. certificate and private key pair) were found.
>> 
>> ** BUILD FAILED **
>> 
>> 
>> The following build commands failed:
>>  Check dependencies
>> (1 failure)

Running "renameAll" task

> [email protected] install /Users/malugus/Code/appium-android-driver/node_modules/ios-test-app
> ./build-js/install.js

info iOSTestApp cleaning apps
dbug iOSTestApp cleaning app for iphonesimulator9.2
dbug iOSTestApp cleaning app for iphoneos9.2
info iOSTestApp finished cleaning apps
info iOSTestApp building apps
dbug iOSTestApp building app for iphonesimulator9.2
dbug iOSTestApp building app for iphoneos9.2
ERR! iOSTestApp Error: Command 'xcodebuild -sdk iphoneos9.2' exited with code 65
ERR! iOSTestApp     at ChildProcess.<anonymous> (lib/teen_process.js:56:19)
ERR! iOSTestApp     at emitTwo (events.js:100:13)
ERR! iOSTestApp     at ChildProcess.emit (events.js:185:7)
ERR! iOSTestApp     at maybeClose (internal/child_process.js:827:16)
ERR! iOSTestApp     at Process.ChildProcess._handle.onexit (internal/child_process.js:211:5)
ERR! iOSTestApp  { [Error: Command 'xcodebuild -sdk iphoneos9.2' exited with code 65]
ERR! iOSTestApp   stdout: 'Build settings from command line:\n    SDKROOT = iphoneos9.2\n\n=== BUILD TARGET TestApp OF PROJECT TestApp WITH THE DEFAULT CONFIGURATION (Release) ===\n\nCheck dependencies\nCode Sign error: No code signing identities found: No valid signing identities (i.e. certificate and private key pair) were found.\n\n',
ERR! iOSTestApp   stderr: '** BUILD FAILED **\n\n\nThe following build commands failed:\n\tCheck dependencies\n(1 failure)\n',
ERR! iOSTestApp   code: 65 }
info iOSTestApp finished building apps
info iOSTestApp renaming apps
WARN iOSTestApp could not rename apps
ERR! iOSTestApp Error: ENOENT: no such file or directory, rename '/Users/malugus/Code/appium-android-driver/node_modules/ios-test-app/build/Release-iphoneos/TestApp.app' -> '/Users/malugus/Code/appium-android-driver/node_modules/ios-test-app/build/Release-iphoneos/TestApp-iphoneos.app'
ERR! iOSTestApp     at Error (native)
ERR! iOSTestApp  { [Error: ENOENT: no such file or directory, rename '/Users/malugus/Code/appium-android-driver/node_modules/ios-test-app/build/Release-iphoneos/TestApp.app' -> '/Users/malugus/Code/appium-android-driver/node_modules/ios-test-app/build/Release-iphoneos/TestApp-iphoneos.app']
ERR! iOSTestApp   cause: 
ERR! iOSTestApp    { [Error: ENOENT: no such file or directory, rename '/Users/malugus/Code/appium-android-driver/node_modules/ios-test-app/build/Release-iphoneos/TestApp.app' -> '/Users/malugus/Code/appium-android-driver/node_modules/ios-test-app/build/Release-iphoneos/TestApp-iphoneos.app']
ERR! iOSTestApp      errno: -2,
ERR! iOSTestApp      code: 'ENOENT',
ERR! iOSTestApp      syscall: 'rename',
ERR! iOSTestApp      path: '/Users/malugus/Code/appium-android-driver/node_modules/ios-test-app/build/Release-iphoneos/TestApp.app',
ERR! iOSTestApp      dest: '/Users/malugus/Code/appium-android-driver/node_modules/ios-test-app/build/Release-iphoneos/TestApp-iphoneos.app' },
ERR! iOSTestApp   isOperational: true,
ERR! iOSTestApp   errno: -2,
ERR! iOSTestApp   code: 'ENOENT',
ERR! iOSTestApp   syscall: 'rename',
ERR! iOSTestApp   path: '/Users/malugus/Code/appium-android-driver/node_modules/ios-test-app/build/Release-iphoneos/TestApp.app',
ERR! iOSTestApp   dest: '/Users/malugus/Code/appium-android-driver/node_modules/ios-test-app/build/Release-iphoneos/TestApp-iphoneos.app' }

> [email protected] install /Users/malugus/Code/appium-android-driver/node_modules/appium-chromedriver
> node install-npm.js

How can I tell if a commit is in a particular version of Appium?

I am looking at #83. By examining the date and tags on the associated commit I can make a fair guess about the Appium version this commit is in. But is there a command to achieve the same? I tried git branch -a -contains 6a048ef386aae3b2200648a16c7922dcd7d42cb3 but that doesn't help get Appium version numbers. Any idea?

android emulator open and close like IOS or browser

When appium is working with Browser or IOS, it will open a browser (simulator) at the start of session and close it at the end.

I am going to make android behave the same way. For example we can read deviceName and platformVersion and create AVD name according to these parameters, launch AVD (it needs these avds to be predefined [or maybe create avd if it did not find it!!]), and close it at the end of session.

this way the behavior will be almost the same as other platforms. What do you think about it? any suggestions?

The appium-android-driver cannot unlock the screen on some devices

[email protected]
Issue devices:

  1. Galaxy Note 3: Model: SM-N9005, version: 4.4.2
  2. Galaxy S4: Model: GT-I9500, version: 4.4.2
  3. HTC one: Model: HTC6525LVW, version: 5.0.1

Other devices still work well

Note: In the past, the Galaxy S4 still works well, but after upgrade to newer OS version, it doesn't work any more

Issue: "Encountered internal error running command: Error: Screen did not unlock successfully"
Expectation: The screen should be unlocked


After do some investigating, found that the adb command to start the unlock doesn't work
adb with args: ["-P",5037,"-s","xxxxxxxxxx","shell","am","start","-n","io.appium.unlock/.Unlock","-S","-a","android.intent.action.MAIN","-c","android.intent.category.LAUNCHER","-f","0x10200000"]

I can reproduce the issue by adb command

adb -s shell am start -n 'io.appium.unlock/.Unlock' -S -a 'android.intent.action.MAIN' -c 'android.intent.category.LAUNCHER' -f '0x10200000'

Some addresses

The '-S' option doesn't work (should be remove from command)
If the unlock is on foreground, the command doesn't make effect

My solution, use 'adb shell am force-stop' to kill 'unlock' and 'adb shell am start' to restart 'unlock' app. I tested on issue devices and confirm it works well

adb -s <UDID>  shell am force-stop 'io.appium.unlock
adb -s <UDID>  shell am start -n 'io.appium.unlock/.Unlock' -a 'android.intent.action.MAIN' -c 'android.intent.category.LAUNCHER' -f '0x10200000'
adb -s <UDID>  shell am start -n 'io.appium.unlock/.Unlock' -a 'android.intent.action.MAIN' -c 'android.intent.category.LAUNCHER' -f '0x10200000'

Weird that after force-stop, we should call 'am start' 2 times to invoke the 'unlock' app. That's should be the reason why '-S' option doesn't work

Turning airplane mode on hangs

After turning airplane_mode on, broadcasting airplane mode often hangs.

adb -s {DEVICE} shell settings put global airplane_mode_on 1
adb -s {DEVICE} shell am broadcast -a android.intent.action.AIRPLANE_MODE --ez state true

The command results in:

Broadcasting: Intent { act=android.intent.action.AIRPLANE_MODE (has extras) }
Broadcast completed: result=0
*hang*

adb logcat output:

09-08 11:55:22.054  3259  3259 D AndroidRuntime: Calling main entry com.android.commands.am.Am
09-08 11:55:22.064  1525  1525 W Settings: Setting airplane_mode_on has moved from android.provider.Settings.System to android.provider.Settings.Global, returning read-only value.
09-08 11:55:22.083  1283  1324 D ConnectivityService: NetworkAgentInfo [MOBILE (UMTS) - 101] EVENT_NETWORK_INFO_CHANGED, going from CONNECTED to DISCONNECTED
09-08 11:55:22.083  1283  1324 D ConnectivityService: NetworkAgentInfo [MOBILE (UMTS) - 101] got DISCONNECTED, was satisfying 2
09-08 11:55:22.097  1525  1664 D DcNetworkAgent: NetworkAgent: NetworkAgent channel lost
09-08 11:55:22.097  1525  1664 D DcNetworkAgent: NetworkAgent: DcNetworkAgent: unwanted found mNetworkAgent=null, which isn't me.  Aborting unwanted
09-08 11:55:22.100  1283  1324 D ConnectivityService: notifyType LOST for NetworkAgentInfo [MOBILE (UMTS) - 101]
09-08 11:55:22.104  1347  1721 D ConnectivityManager.CallbackHandler: CM callback handler got msg 524292

The device updates, showing the airplane icon but any additional ADB command hangs.

Turning airplane_mode off works fine.

Testing on Android 6.0 - API Level 23

setcontext throws error when available contexts are only NATIVE_APP and CHROMIUM

Hybrid app based app using crosswalk web driver. Testing on real devices.
Works with appium 1.3.5 with crosswalk web driver.

Latest version 1.5.2 throws error.
Based on investigation
Latest version throws NoSuchContextError()

If the available contexts are only NATIVE_APP, CHROMIUM, I would expect the defaults to be chosen from one of them instead of WEBVIEW_{apppackage}.

v1.3.5 was exiting gracefully
return cb(null, {
status: status.codes.NoSuchContext.code
, value: "Context '" + name + "' does not exist"
});

code paths where it's called

this.defaultWebviewName called from initautowebview (lib/driver.js) - line no 202
The above line is based on appium server flags autowebview (true, false)

this.defaultWebviewName called from setcontext (lib/commands/context.js) - line no 39
function itself is present in context.js at line no 89

Issues with select date from the datepicker with Appium for Android Driver

Hi,I am facing issues to select date from the datepicker with Appium for Android Driver.Please check the attached screenshots of the Calender I am looking for.

I have already tried with element.clear() followed by element.sendkeys("text"),but its not working.

Also I tried to work with Scroll to followed by TouchAction ,where its working till selecting the Year ,but after that its failed to select the date and month which should be selected from the screenshot named as DatePicker2.

Can anyone please suggest me any workout .
daypicker1
daypicker2
daypicker3

Delay before adb.keyevent() might not be required

The previous implementation of toggleSetting had a 2000ms delay before calling adb.keyevent().

adb.keyevent() seems to work without this delay (tested on 6.0/23). toggleSettings calls adb.keyevent() numerous times. Removing the delay could save ~10 seconds.

We should test all API versions to see if it's required.

https://github.com/appium/appium-android-driver/blob/master/lib/commands/network.js#L159-L163

Update: abd.keyevent() is being replaced with bootstrap.sendAction(“keyPressCode").

How to run tests?

I am trying to figure out how to run E2E/functional tests, can someone point me at right direction?

gulp once - only ran unit tests

gulp e2eTest didn't work

I made partial progress by first
gulp transpile

and the mocha build/path/to/testfile but it failed with lack of correct timeout

  1) Find - basic "before all" hook: callee$1$0:
     Error: timeout of 2000ms exceeded. Ensure the done() callback is being called in this test.

1.5 Cleanup - phase 1

  • Make sure dependencies are up to date. Waiting for beta tag on appium-adb package
  • Remove unused dependencies. Done
  • Review TODOs and see if we need to resolve any before release. In Progress
  • Ensure code conforms to style guide. Done
  • Ensure we're not using any sync functions. Filed issue for AdmZip module

Add package-lock.json back

Hi, thanks for your great work.

I cloned v7.1.4 yesterday, but it couldn't work with npm i

It takes me half a day to fix it like your fix in v7.1.5.

The root cause is the different versions of @appium/types exist after npm i. The dependencies I got are different from those in the v7.1.4 ci.

So, I'm proposing to add package-lock.json back to avoid similar issues in the future. Because it could also happen for other libs.

In this way, we can ensure if the released version passes ci, then it should also work after other developers clone it to the local.

What do you think?

noReset/fullReset ignored when using appActivity/appPackage

The problem

When the appActivity and appPackage capabilities are used instead of app, noReset and fullReset are ignored. This is due to the reset logic being contained in function installApkRemotely, which is not called when not using the app capability.

Environment

  • Git revision that exhibits the issue: 53fa62e
  • Desktop OS/version used to run Appium: Linux
  • Node.js version: v6.2.1
  • Mobile platform/version under test: Android
  • Real device or emulator/simulator: Real device
  • Appium CLI or Appium.app|exe: CLI

Link to Appium logs

Gist log

Code To Reproduce Issue

In the following example, the app data remains on the phone instead of being erased.

#!/usr/bin/env python3
import appium
import time

capabilities = {
    'appActivity': "com.ansca.corona.CoronaActivity",
    'appPackage': "br.com.tapps.vloggergoviral",
    'deviceName': "Android",
    'platformName': "Android",
    'noReset': False
}

webdriver = appium.webdriver.Remote("http://localhost:4723/wd/hub", capabilities)
time.sleep(15)
webdriver.quit()

Expected behavior: app is reset when noReset = false and an error is raised then fullReset = true and no app capability is provided.

I will create a pull request for this soon.

Macos Big Sur : Opencv4nodejs and mjepg consumer installation is failing.

Warning:

These issues are not tracked. Please create new issues in the main Appium
repository: https://github.com/appium/appium/issues/new
npm ERR! code 1
npm ERR! path /usr/local/lib/node_modules/opencv4nodejs
npm ERR! command failed
npm ERR! command sh -c node ./install/install.js
npm ERR! info install using lib dir: /usr/local/lib/node_modules/opencv4nodejs/node_modules/opencv-build/opencv/build/lib
npm ERR! /usr/local/lib/node_modules/opencv4nodejs/install/install.js:37
npm ERR! throw new Error('library dir does not exist: ' + libDir)
npm ERR! ^
npm ERR!
npm ERR! Error: library dir does not exist: /usr/local/lib/node_modules/opencv4nodejs/node_modules/opencv-build/opencv/build/lib
npm ERR! at Object. (/usr/local/lib/node_modules/opencv4nodejs/install/install.js:37:9)
npm ERR! at Module._compile (node:internal/modules/cjs/loader:1092:14)
npm ERR! at Object.Module._extensions..js (node:internal/modules/cjs/loader:1121:10)
npm ERR! at Module.load (node:internal/modules/cjs/loader:972:32)
npm ERR! at Function.Module._load (node:internal/modules/cjs/loader:813:14)
npm ERR! at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:76:12)
npm ERR! at node:internal/main/run_main_module:17:47

npm ERR! A complete log of this run can be found in:
npm ERR! /Users/jitu-patel/.npm/_logs/2021-04-18T11_10_47_360Z-debug.log

Jitu-Patel:~ jitu-patel$ npm -g list
/usr/local/lib
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
└── [email protected]

setGeoLocation returns random info

The spec says we should be returning the location. If it is not possible in our new scheme to find the actual location, we should, if there is no error in setting, return the location that was requested.

Use any random available port when starting ChromeDriver

When I launch tests that use Chrome on multiple devices at the same time, all but one fails. This is because all the ChromeDriver sessions are trying to start on the same port, 9515.

I suggest that Appium uses the first available random port found for each ChromeDriver session. This will enable parallel Android browser tests on the same machine with no extra effort from users' POV.

Action required: Greenkeeper could not be activated 🚨

🚨 You need to enable Continuous Integration on all branches of this repository. 🚨

To enable Greenkeeper, you need to make sure that a commit status is reported on all branches. This is required by Greenkeeper because it uses your CI build statuses to figure out when to notify you about breaking changes.

Since we didn’t receive a CI status on the greenkeeper/initial branch, it’s possible that you don’t have CI set up yet. We recommend using Travis CI, but Greenkeeper will work with every other CI service as well.

If you have already set up a CI for this repository, you might need to check how it’s configured. Make sure it is set to run on all new branches. If you don’t want it to run on absolutely every branch, you can whitelist branches starting with greenkeeper/.

Once you have installed and configured CI on this repository correctly, you’ll need to re-trigger Greenkeeper’s initial pull request. To do this, please delete the greenkeeper/initial branch in this repository, and then remove and re-add this repository to the Greenkeeper App’s white list on Github. You'll find this list on your repo or organization’s settings page, under Installed GitHub Apps.

Webview of main app incorrectly flagged as zero pages when related browser app's webview has zero pages

I've come across an odd issue that I can't fully explain with this. Running automation tests via robot framework using pip modules/packages listed in Environment section below.

Recently upgraded the test machines for Fedora 39 and updated all automation tools to latest.

Afterwards we started seeing regular failures (not always but almost always) on units just after a browser webview app separate (but related) to our main webview app had been closed. Our main app launches the browser app (a separate apk), which opens its own webview, while the main app stays open/active/alive in the background. The browser was being tested using native context and the tests were attempting to switch back to the chrome webview context of the main app.

The tests were failing with a "NoSuchContextException: Message: No such context found" error. This can be see in the attached appium log at 2023-12-01 20:00:48:243. The reason that the main app's webview is not listed is given in the attached appium log as being due to the fact that it reported having zero pages.

appium_zero_page_webview.log

(note the provided log is from a test run where the empty browser webview is present at the start of the tests so the failure comes sooner and the logs are shorter)

However I ran a script in parallel to the appium tests and the webview for the main app is not empty at the time of the failure nor is it ever populated as empty (following is from querying the webview info in the same way as https://github.com/appium/appium-android-driver/blob/master/lib/helpers/webview.ts#L351 and using the same adb executable as appium does).

INFO FOR WEBVIEW webview_devtools_remote_4867

{ "Android-Package": "com.mycompany.ourmainapp", "Browser": "Chrome/119.0.6045.163", "Protocol-Version": "1.3", "User-Agent": "Mozilla/5.0 (Linux; Android 7.1.2; p212 Build/NHG47L; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/119.0.6045.163 Safari/537.36", "V8-Version": "11.9.169.6", "WebKit-Version": "537.36 (@e87d8ea31f029f62cebd71af35a9059e00c18d1e)", "webSocketDebuggerUrl": "ws://127.0.0.1:12345/devtools/browser" }

[ { "description": "{\"attached\":true,\"empty\":false,\"height\":1080,\"never_attached\":false,\"screenX\":0,\"screenY\":0,\"visible\":true,\"width\":1920}", "devtoolsFrontendUrl": "https://chrome-devtools-frontend.appspot.com/serve_rev/@e87d8ea31f029f62cebd71af35a9059e00c18d1e/inspector.html?ws=127.0.0.1:12345/devtools/page/A695EA9671A465380E4CA97C3B286ADC", "faviconUrl": "https://localhost/favicon.ico", "id": "A695EA9671A465380E4CA97C3B286ADC", "title": "ourmainapp", "type": "page", "url": "https://localhost/index.html/", "webSocketDebuggerUrl": "ws://127.0.0.1:12345/devtools/page/A695EA9671A465380E4CA97C3B286ADC" } ]

INFO FOR WEBVIEW webview_devtools_remote_5807

{ "Android-Package": "com.mycompany.browser", "Browser": "Chrome/119.0.6045.163", "Protocol-Version": "1.3", "User-Agent": "Mozilla/5.0 (Linux; Android 7.1.2; p212 Build/NHG47L; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/119.0.6045.163 Safari/537.36", "V8-Version": "11.9.169.6", "WebKit-Version": "537.36 (@e87d8ea31f029f62cebd71af35a9059e00c18d1e)", "webSocketDebuggerUrl": "ws://127.0.0.1:12345/devtools/browser" }

[ ]

The browser app's webview is indeed empty at this time though and it appears as though the presence of this empty browser webview is somehow affecting the interpretation of the main app's webview page info. Since querying the webview info directly using the same methodology and same adb executable as Appium clearly shows that the main app's webview is not empty, I am unsure as to where this is going wrong internally to the Android driver but that seems to be the case.

The above logs are from an Android 7 STB (with Chrome 119 webview) but we also see exactly the same issue on an Android 11 terminal device running same webview. Downgrading to 117 webview didn't help.

To further muddy the waters, I cannot reproduce this issue on another machine running Fedora 38. As far as I can ascertain, it has all the same environment as below with the obvious exception of the OS (Fedora 38 instead of 39) and python (v3.11.6 instead of v3.12.0). It never gives this issue when running the same tests against the same devices.

Environment is as follows:
os name: NAME="Fedora Linux"
os version: VERSION="39 (Workstation Edition)"
appium: 2.2.2
appium-doctor: 2.0.28
appium driver:
✔ Listing installed drivers

(pip modules/packages)
Appium-Python-Client 3.1.0
robotframework 6.1.1
robotframework-appiumlibrary 2.0.0
robotframework-pythonlibcore 4.3.0
robotframework-seleniumlibrary 6.2.0
robotframework-sshlibrary 3.8.0
selenium 4.15.2
wheel 0.42.0

google-chrome: Google Chrome 119.0.6045.159
/usr/bin/chromedriver: ChromeDriver 119.0.6045.105 (38c72552c5e15ba9b3117c0967a0fd105072d7c6-refs/branch-heads/6045@{#1103})
/usr/local/bin/chromedriver: ChromeDriver 119.0.6045.105 (38c72552c5e15ba9b3117c0967a0fd105072d7c6-refs/branch-heads/6045@{#1103})
~/.appium/.../chromedriver/linux/: chromedriver-linux64_v119.0.6045.105

Python version v3.12.0

android sdk:
Installed packages:=====================] 100% Fetch remote repository...

Path Version Description Location
build-tools;29.0.2 29.0.2 Android SDK Build-Tools 29.0.2 build-tools/29.0.2
build-tools;30.0.2 30.0.2 Android SDK Build-Tools 30.0.2 build-tools/30.0.2
build-tools;30.0.3 30.0.3 Android SDK Build-Tools 30.0.3 build-tools/30.0.3
build-tools;32.0.0 32.0.0 Android SDK Build-Tools 32 build-tools/32.0.0
build-tools;33.0.0 33.0.0 Android SDK Build-Tools 33 build-tools/33.0.0
build-tools;33.0.2 33.0.2 Android SDK Build-Tools 33.0.2 build-tools/33.0.2
cmake;3.18.1 3.18.1 CMake 3.18.1 cmake/3.18.1
cmake;3.22.1 3.22.1 CMake 3.22.1 cmake/3.22.1
emulator 32.1.15 Android Emulator emulator
ndk;21.0.6113669 21.0.6113669 NDK (Side by side) 21.0.6113669 ndk/21.0.6113669
patcher;v4 1 SDK Patch Applier v4 patcher/v4
platform-tools 34.0.5 Android SDK Platform-Tools platform-tools
platforms;android-29 5 Android SDK Platform 29 platforms/android-29
platforms;android-30 3 Android SDK Platform 30 platforms/android-30
platforms;android-31 1 Android SDK Platform 31 platforms/android-31
platforms;android-32 1 Android SDK Platform 32 platforms/android-32
platforms;android-33 3 Android SDK Platform 33 platforms/android-33

ACCESS_MOCK_LOCATION

When I try to set a mock location on an emulator (Nexus_5_API_22) the appium settings is killed and I get the following info in the emulator log:

06-10 13:17:03.080: E/AndroidRuntime(7966): FATAL EXCEPTION: main
06-10 13:17:03.080: E/AndroidRuntime(7966): Process: io.appium.settings, PID: 7966
06-10 13:17:03.080: E/AndroidRuntime(7966): java.lang.RuntimeException: Unable to start service io.appium.settings.LocationService@21c91729 with Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=io.appium.settings/.LocationService (has extras) }: java.lang.SecurityException: Requires ACCESS_MOCK_LOCATION secure setting
06-10 13:17:03.080: E/AndroidRuntime(7966):     at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:2911)
06-10 13:17:03.080: E/AndroidRuntime(7966):     at android.app.ActivityThread.access$2100(ActivityThread.java:151)
06-10 13:17:03.080: E/AndroidRuntime(7966):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1401)
06-10 13:17:03.080: E/AndroidRuntime(7966):     at android.os.Handler.dispatchMessage(Handler.java:102)
06-10 13:17:03.080: E/AndroidRuntime(7966):     at android.os.Looper.loop(Looper.java:135)
06-10 13:17:03.080: E/AndroidRuntime(7966):     at android.app.ActivityThread.main(ActivityThread.java:5254)
06-10 13:17:03.080: E/AndroidRuntime(7966):     at java.lang.reflect.Method.invoke(Native Method)
06-10 13:17:03.080: E/AndroidRuntime(7966):     at java.lang.reflect.Method.invoke(Method.java:372)
06-10 13:17:03.080: E/AndroidRuntime(7966):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
06-10 13:17:03.080: E/AndroidRuntime(7966):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
06-10 13:17:03.080: E/AndroidRuntime(7966): Caused by: java.lang.SecurityException: Requires ACCESS_MOCK_LOCATION secure setting
06-10 13:17:03.080: E/AndroidRuntime(7966):     at android.os.Parcel.readException(Parcel.java:1546)
06-10 13:17:03.080: E/AndroidRuntime(7966):     at android.os.Parcel.readException(Parcel.java:1499)
06-10 13:17:03.080: E/AndroidRuntime(7966):     at android.location.ILocationManager$Stub$Proxy.addTestProvider(ILocationManager.java:1054)
06-10 13:17:03.080: E/AndroidRuntime(7966):     at android.location.LocationManager.addTestProvider(LocationManager.java:1216)
06-10 13:17:03.080: E/AndroidRuntime(7966):     at io.appium.settings.MockLocationProvider.pushLocation(MockLocationProvider.java:20)
06-10 13:17:03.080: E/AndroidRuntime(7966):     at io.appium.settings.LocationService.onStartCommand(LocationService.java:25)
06-10 13:17:03.080: E/AndroidRuntime(7966):     at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:2894)
06-10 13:17:03.080: E/AndroidRuntime(7966):     ... 9 more

I'm running appium 1.5.3 on MacOSX 10.11.5
any hints?

npm run watch failed

After git clone and run npm run watch, I don't know why, need help

λ npm run watch

> [email protected] watch C:\Project\x5-driver\build\hook\appium-android-driver
> gulp

[16:25:38] Using gulpfile C:\Project\x5-driver\build\hook\appium-android-driver\gulpfile.js
[16:25:38] Starting 'watch'...
[16:25:38] Finished 'watch' after 5.33 ms
[16:25:38] Starting 'default'...
[16:25:38] Finished 'default' after 5.42 μs
Error: spawn C:\Project\x5-driver\build\hook\appium-android-driver\node_modules\.bin\gulp ENOENT
    at exports._errnoException (util.js:855:11)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:178:32)
    at onErrorNT (internal/child_process.js:344:16)
    at nextTickCallbackWith2Args (node.js:455:9)
    at process._tickCallback (node.js:369:17)
    at Function.Module.runMain (module.js:432:11)
    at startup (node.js:141:18)
    at node.js:980:3

npm ERR! Windows_NT 6.1.7601
npm ERR! argv "C:\\Software\\nodejs\\node.exe" "C:\\Users\\tianyuzou\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js" "run" "watch"
npm ERR! node v5.3.0
npm ERR! npm  v3.5.2
npm ERR! code ELIFECYCLE
npm ERR! [email protected] watch: `gulp`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] watch script 'gulp'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the appium-android-driver package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     gulp
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs appium-android-driver
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls appium-android-driver
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     C:\Project\x5-driver\build\hook\appium-android-driver\npm-debug.log

Flick command arguments are not bound correctly

When executing POST /wd/hub/session/<session_id>/touch/flick with payload:

{
  "element": "25",
  "xoffset": 0,
  "yoffset": -100,
  "speed": 100
}

... the command that is ran under the hood is the following (according to the logs):

{
  "cmd": "action",
  "action": "element:swipe",
  "params": {
    "startX": "25",
    "endY": 0,
    "steps": 6,
    "elementId": 100
  }
}

It looks like the payload arguments are not bound correctly to the command arguments, leading to a 500. See the full log below:

[HTTP] --> POST /wd/hub/session/ca72033a-5e56-444a-bf97-60507b7aaefb/touch/flick {"element":"25","xoffset":0,"yoffset":-100,"speed":100}
[MJSONWP] Calling AppiumDriver.flick() with args: ["25",null,null,0,-100,100,"ca72033a-5e56-444a-bf97-60507b7aaefb"]
[debug] [AndroidBootstrap] Sending command to android: {"cmd":"action","action":"element:swipe","params":{"startX":"25","endY":0,"steps":6,"elementId":100}}
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got data from client: {"cmd":"action","action":"element:swipe","params":{"startX":"25","endY":0,"steps":6,"elementId":100}}
[debug] [AndroidBootstrap] Received command result from bootstrap
[HTTP] <-- POST /wd/hub/session/ca72033a-5e56-444a-bf97-60507b7aaefb/touch/flick 500 3 ms - 154
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command of type ACTION
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command action: swipe
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Command returned error:java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String java.lang.Object.toString()' on a null object reference
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Returning result: {"status":13,"value":"Attempt to invoke virtual method 'java.lang.String java.lang.Object.toString()' on a null object reference"}

Find an AdmZip alternative

Find an AdmZip alternative to zip files in the commands.pullFolder method.

commands.pullFolder = async function (remotePath) {
  let localFolder = temp.path({prefix: 'appium'});
  await this.adb.pull(remotePath, localFolder);
  // TODO: find a better alternative to the AdmZip module
  let zip = new AdmZip();
  zip.addLocalFolder(localFolder);
  return new Promise((resolve, reject) => {
    zip.toBuffer((buffer) => {
      logger.debug("Converting in-memory zip file to base64 encoded string");
      resolve(buffer.toString('base64'));
    }, (err) => {
      reject(err);
    });
  });
};

multiTouchPerform is broken

Hi! I've encountered with such error:

Sun, 17 Oct 2021 18:03:07 GMT [debug] [WD Proxy] Matched '/wd/hub/session/7c1249a8-335f-406f-b896-4de763450808/elements' to command name 'findElements'
Sun, 17 Oct 2021 18:03:08 GMT [debug] [WD Proxy] Proxying [POST /wd/hub/session/7c1249a8-335f-406f-b896-4de763450808/elements] to [POST http://127.0.0.1:8000/wd/hub/session/11e8cf5c008df135834898f574187b26/elements] with body: {"using":"xpath","value":"//ion-toolbar/following::*[text() = 'Settings']"}
Sun, 17 Oct 2021 18:03:08 GMT [debug] [WD Proxy] Got response with status 200: {"value":[{"element-6066-11e4-a52e-4f735466cecf":"73f5694e-4214-4b04-b644-d6e1f355ec40"}]}
Sun, 17 Oct 2021 18:03:08 GMT [HTTP] <-- POST /wd/hub/session/7c1249a8-335f-406f-b896-4de763450808/elements 200 56 ms - 139
[HTTP] 
[HTTP] --> POST /wd/hub/session/7c1249a8-335f-406f-b896-4de763450808/touch/multi/perform
[HTTP] {"actions":[{"action":"press","options":{"element":{"sessionId":"7c1249a8-335f-406f-b896-4de763450808","elementId":"73f5694e-4214-4b04-b644-d6e1f355ec40","element-6066-11e4-a52e-4f735466cecf":"73f5694e-4214-4b04-b644-d6e1f355ec40","selector":"//ion-toolbar/following::*[text() = 'Settings']","parent":{"sessionId":"7c1249a8-335f-406f-b896-4de763450808","capabilities":{"platform":"LINUX","webStorageEnabled":false,"takesScreenshot":true,"javascriptEnabled":true,"databaseEnabled":false,"networkConnectionEnabled":true,"locationContextEnabled":false,"warnings":{},"desired":{"platformName":"Android","deviceName":"Android Emulator","app":"C:\\Workspaces\\_IDL\\mobile-repo\\android\\app\\build\\outputs\\apk\\debug\\app-debug.apk","autoWebview":true,"appPackage":"com.indifferentlanguages.mobile","appActivity":".MainActivity","automationName":"UiAutomator2","udid":"emulator-5554","fullReset":false,"noReset":true,"dontStopAppOnReset":true},"platformName":"Android","deviceName":"emulator-5554","app":"C:\\Workspaces\\_ID...
Sun, 17 Oct 2021 18:03:08 GMT [debug] [W3C (7c1249a8)] Calling AppiumDriver.performMultiAction() with args: [[{"action":"press","options":{"element":{"sessionId":"7c1249a8-335f-406f-b896-4de763450808","elementId":"73f5694e-4214-4b04-b644-d6e1f355ec40","element-6066-11e4-a52e-4f735466cecf":"73f5694e-4214-4b04-b644-d6e1f355ec40","selector":"//ion-toolbar/following::*[text() = 'Settings']","parent":{"sessionId":"7c1249a8-335f-406f-b896-4de763450808","capabilities":{"platform":"LINUX","webStorageEnabled":false,"takesScreenshot":true,"javascriptEnabled":true,"databaseEnabled":false,"networkConnectionEnabled":true,"locationContextEnabled":false,"warnings":{},"desired":{"platformName":"Android","deviceName":"Android Emulator","app":"C:\\Workspaces\\_IDL\\mobile-repo\\android\\app\\build\\outputs\\apk\\debug\\app-debug.apk","autoWebview":true,"appPackage":"com.indifferentlanguages.mobile","appActivity":".MainActivity","automationName":"UiAutomator2","udid":"emulator-5554","fullReset":false,"noReset":true,"dontStopAppOnReset":true},"platformName":"Android","deviceName":"emulator-5554","app":"C:\\Workspaces\\_IDL\\mobile-...
Sun, 17 Oct 2021 18:03:08 GMT [debug] [W3C (7c1249a8)] Encountered internal error running command: TypeError: Cannot read property 'action' of undefined
Sun, 17 Oct 2021 18:03:08 GMT [debug] [W3C (7c1249a8)]     at AndroidUiautomator2Driver.parseTouch (C:\Workspaces\_IDL\mobile-repo\node_modules\appium\node_modules\appium-android-driver\lib\commands\touch.js:246:4)
[debug] [W3C (7c1249a8)]     at mapper (C:\Workspaces\_IDL\mobile-repo\node_modules\appium\node_modules\appium-android-driver\lib\commands\touch.js:334:1)
[debug] [W3C (7c1249a8)]     at asyncmap (C:\Workspaces\_IDL\mobile-repo\node_modules\appium\node_modules\asyncbox\lib\asyncbox.js:104:24)
[debug] [W3C (7c1249a8)]     at AndroidUiautomator2Driver.performMultiAction (C:\Workspaces\_IDL\mobile-repo\node_modules\appium\node_modules\appium-android-driver\lib\commands\touch.js:334:1)
[debug] [W3C (7c1249a8)]     at commandExecutor (C:\Workspaces\_IDL\mobile-repo\node_modules\appium\node_modules\appium-base-driver\lib\basedriver\driver.js:335:9)
Sun, 17 Oct 2021 18:03:08 GMT [debug] [W3C (7c1249a8)]     at C:\Workspaces\_IDL\mobile-repo\node_modules\appium\node_modules\async-lock\lib\index.js:146:12
[debug] [W3C (7c1249a8)]     at AsyncLock._promiseTry (C:\Workspaces\_IDL\mobile-repo\node_modules\appium\node_modules\async-lock\lib\index.js:280:31)
[debug] [W3C (7c1249a8)]     at exec (C:\Workspaces\_IDL\mobile-repo\node_modules\appium\node_modules\async-lock\lib\index.js:145:9)
[debug] [W3C (7c1249a8)]     at AsyncLock.acquire (C:\Workspaces\_IDL\mobile-repo\node_modules\appium\node_modules\async-lock\lib\index.js:162:3)
[debug] [W3C (7c1249a8)]     at AndroidUiautomator2Driver.executeCommand (C:\Workspaces\_IDL\mobile-repo\node_modules\appium\node_modules\appium-base-driver\lib\basedriver\driver.js:348:39)
Sun, 17 Oct 2021 18:03:08 GMT [debug] [W3C (7c1249a8)]     at AppiumDriver.executeCommand (C:\Workspaces\_IDL\mobile-repo\node_modules\appium\lib\appium.js:563:36)
[debug] [W3C (7c1249a8)]     at runMicrotasks (<anonymous>)
[debug] [W3C (7c1249a8)]     at processTicksAndRejections (internal/process/task_queues.js:93:5)
[debug] [W3C (7c1249a8)]     at asyncHandler (C:\Workspaces\_IDL\mobile-repo\node_modules\appium\node_modules\appium-base-driver\lib\protocol\protocol.js:297:21)
Sun, 17 Oct 2021 18:03:08 GMT [HTTP] <-- POST /wd/hub/session/7c1249a8-335f-406f-b896-4de763450808/touch/multi/perform 500 99 ms - 633
[HTTP] 
[HTTP] --> DELETE /wd/hub/session/7c1249a8-335f-406f-b896-4de763450808
[HTTP] {}
[debug] [W3C (7c1249a8)] Calling AppiumDriver.deleteSession() with args: ["7c1249a8-335f-406f-b896-4de763450808"]

Here code which produces the error:

  async longClickElement(selector: string): Promise<wdio.Element<'async'> | false> {
    const element = await this.client.$(selector);

    await element.waitForExist();
 
    this.client.multiTouchPerform([{ action: 'press', options: { element } },
                                   { action: 'wait', options: { ms: 1100 } }]);

    return element;
  }

I did research and found a mistake (as I understand). But I don't know how to fix it.

There is single action passed to parseTouch

const states = await asyncmap(actions, async (action) => await this.parseTouch(action, true), false);

But parseTouch function waits for array of actions

helpers.parseTouch = async function parseTouch (gestures, multi) {

and it fails on this line:

if (multi && _.last(gestures).action === 'release') {

enable/disable data fix

appium-android-driver is failing to set mobile data on API23.

adb -s emulator-5554 shell am start -n io.appium.settings/.Settings -e data off
adb -s emulator-5554 shell settings get global mobile_data // --> 1 (should be 0)

More info: http://stackoverflow.com/questions/26539445/the-setmobiledataenabled-method-is-no-longer-callable-as-of-android-l-and-later

I've tested the following commands on API23 with success:

shell svc data enable
shell settings get global mobile_data // --> 1
shell svc data disable
shell settings get global mobile_data // --> 0

This will require testing against all supported API levels.

set terminate app timeout as zero (or negative)

(Just an idea note for me.)

Then, the launching status check can be skipped. I mean appium just calls the below, then returns true without the app status check.

await this.adb.forceStop(appId);

I got a couple of reports about app termination status check.

After stopping the app process by force-stop command, the app process actually stopped, but the Android OS restarted the app process immediately (maybe the app was a service to keep running?). The app state check handled such case as still running.

I'll create a proposal later

1.5 Cleanup - phase 2

  • set up code coverage
  • set up CI (unit tests, functional tests, code coverage; should be on all relevant platforms)
  • ensure that we are using appium-support functions
  • ensure that we have high unit test code coverage
  • ensure that we have sufficient/appropriate functional test coverage
  • create a decent README, explaining (a) what the purpose of the module is, (b) how it relates to other appium modules, and (c) how to use its interface
  • ensure that code is well-commented;

WebElement.findElements(By.className()) on a parent object returns all classes on dom that match

WebElement linearLayouts = driver.findElementByXPath("//android.widget.LinearLayout[@index='1']");
List<WebElement> views = linearLayouts.findElements(By.className("android.widget.TextView"));

System.out.println(views.size());

I would expect to only get back the 2 elements for the TextViews in the tree attached. Instead all the elements with that class in the document are returned?

tree lg

Native elements off-screen but on-page are not found

Environment

  • java client build version or git revision if you use some shapshot: 3.4.1
  • Appium server version or git revision if you use some shapshot: 1.5.2
  • Desktop OS/version used to run Appium if necessary: OSX El Capitan
  • Node.js version (unless using Appium.app|exe) or Appium CLI or Appium.app|exe: 6.1.0
  • Mobile platform/version under test: Android 6.0
  • Real device or emulator/simulator: Real

Code To Reproduce Issue [ Good To Have ]

  1. Open a Appium session on an Android device
  2. Open an app that has a really long layout
  3. Try to locate an element by ID on the page that's off-screen.
  4. Fails

I opened inspector and saw that the UI hierarchy didn't include the elements that were off screen.

I scrolled down and saw the elements that are now above the screen can't be found by Appium.

Link to Appium logs

https://gist.github.com/midopa/3dbe49785caee71bd7b10f22b2f7bf81

Mobile Data always on

Mobile data isn't turning off on the device. The issue appears to be with io.appium.settings:

// WiFi sets correctly:
adb shell am start -n io.appium.settings/.Settings -e wifi on
adb shell settings get global wifi_on -> 1
adb shell am start -n io.appium.settings/.Settings -e wifi off
adb shell settings get global wifi_on -> 0

// However, data doesn't set correctly:
adb shell am start -n io.appium.settings/.Settings -e data on
adb shell settings get global mobile_data -> 1
adb shell am start -n io.appium.settings/.Settings -e data off
adb shell settings get global mobile_data -> 1 (Should be 0)

As a side note, when adb shell am start -n io.appium.settings/.Settings -e wifi on is executed, the settings application kicks off and says it's setting WiFi on, however the wifi toggle on the android device remains set to 'off'.

Testing on Android 6.0 - API Level 23

Checkboxes on Hybrid Apps have large, invalid X values

Description

On hybrid apps, visible checkboxes on the screen have negative x-axis values for center and location. X-value for size is very large as well.

element.getCenter(); // (-1356, 1296)
element.getLocation(); // (-3433, 1232)
element.getSize(); // (4154, 129)
appium.manage().window().getSize(); // (1440, 2560)

Interestingly, in Inspector, the location and size values seem OK:

type: android.widget.CheckBox
text: 
index: 4
enabled: true
location: {0, 1232}
size: {721, 129}

When I view the page source directly from Appium, I see the checkboxes have valid-looking values for their bound property.

Environment

  • java client build version or git revision if you use some shapshot: 3.4.1
  • Appium server version or git revision if you use some shapshot: 1.5.3
  • Desktop OS/version used to run Appium if necessary: OSX El Capitan
  • Node.js version (unless using Appium.app|exe) or Appium CLI or Appium.app|exe: 6.1.0
  • Mobile platform/version under test: Android 6.0
  • Real device or emulator/simulator: Real

Code To Reproduce Issue [ Good To Have ]

  1. Open a Appium session on an Android device
  2. Open a hybrid app
  3. Load a page that has a checkbox in it
  4. Locate the checkbox somehow (eg. xpath = "//android.widget.CheckBox")
  5. Investigate the above properties (center, location, size)

Link to Appium logs

https://gist.github.com/midopa/ba91923519a6b288a1cd510690c2a2b8

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.