Git Product home page Git Product logo

appium-remote-debugger's Introduction

appium-remote-debugger

Release

A Node.js frontend for the Remote Debugger protocol used by Appium to connect to iOS webviews and Safari. Written using ES6+.

Safari's version of the WebKit API

Safari implements a wonky version of the WebKit API. It is not documented. The JSON version of the protocol is documented in the WebKit source code, in Source/JavaScriptCore/inspector/protocol/.

There is good documentation for the closely related API from Chrome DevTools, to be found here.

API

This is an event emitter, which emits a RemoteDebugger.EVENT_PAGE_CHANGE event when there has been a change to the page. This should be caught and handled as the calling code wishes. It also emits a RemoteDebugger.EVENT_DISCONNECT event when the server disconnects the last application connected.

The steps to using the RemoteDebugger involve instantiating an object, then running connect and selectApp. After this the instance will be listening for events from the server (i.e., the webview or browser).

Selenium "atoms"

The remote debugger uses the standard Selenium Atoms to interact with web pages. These need to be manually updated when necessary. To do so, simply update the branch in the scripts/common.js, by modifying the SELENIUM_BRANCH constant at the top of the file. Then run npm run build:atoms, test and create a pull request with the resulting changed atoms directory.

Note that to build the atoms it is required that you have the bazel tool installed. Selenium will also require that it be installed at a particular version relative to the version of Selenium that has been checked out by our build script. It is most convenient simply to install bazelisk and have it available on your PATH.

One caveat is that there are some changes that are needed for Appium, that are not yet in the Selenium codebase. See the atoms notes for details.

Test

npm test
npm e2e-test

appium-remote-debugger's People

Contributors

anorimaki avatar christian-bromann avatar dependabot-preview[bot] avatar dependabot[bot] avatar dpgraham avatar erustusagutu avatar greenkeeper[bot] avatar imurchie avatar jlipps avatar jonahss avatar kazucocoa avatar li-zhixin avatar mwakizaka avatar mykola-mokhnach avatar rkavalap avatar semantic-release-bot avatar ssynix avatar thomasfettsauce avatar umutuzgur avatar yaphatak avatar yfangsl 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

Watchers

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

appium-remote-debugger'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.

Appium Safari tests on iOS 10 simulator are unstable

When creating a new Appium driver and navigating to a certain URL, 1 out of 2 test runs fails in my environment if a new simulator has to be started. I am using Appium 1.6.1 beta 1 with xcuitest automation on an iOS 10 simulator (MacOS Sierra).

From the log output it seems that the RemoteDebugger receives web site URLs during page change events even though these URLs are not open in the browser (i.e. there is only a single browser tab open). It seems that these URLs are always search engines like https://www.yahoo.com/, https://www.bing.com/ or https://www.google.com so probably Safari does some sort of requests to these search engines when the browser is opened up.

Subsequently a "_rpc_applicationDisconnected" message is received so that the connection to the existing browser tab is closed. Finally the test execution hangs in the call "Sending '_rpc_forwardSocketData:..." where it tries to verify if the page is ready - until the connection times out.

The log output is slightly different each time I execute my test, so there might be some timing issues involved.

Log output:
...
2016-11-14 14:02:25,170 [MJSONWP] Calling AppiumDriver.setUrl() with args: ["http://localhost/index.html/","88c97274-7c7b-4dbc-95a2-760c0c43fbf0"]
2016-11-14 14:02:25,171 [debug] [XCUITest] Executing command 'setUrl'
2016-11-14 14:02:25,173 [debug] [iOS] Attempting to set url 'http://localhost/index.html/'
2016-11-14 14:02:25,174 [debug] [RemoteDebugger] Navigating to new URL: http://localhost/index.html/
2016-11-14 14:02:25,174 [debug] [RemoteDebugger] Sending '_rpc_forwardSocketData:' message to remote debugger
2016-11-14 14:02:25,178 [debug] [RemoteDebugger] Received applicationSentData response
2016-11-14 14:02:25,178 [debug] [RemoteDebugger] Found data handler for response
2016-11-14 14:02:25,179 [debug] [RemoteDebugger] Received data response from socket send: '{}'
2016-11-14 14:02:25,179 [debug] [RemoteDebugger] Original command: setUrl
2016-11-14 14:02:25,180 [debug] [RemoteDebugger] Received applicationSentData response
2016-11-14 14:02:25,187 [debug] [RemoteDebugger] Receiving data from remote debugger: '{"__argument":{"WIRApplicationIdentifierKey":"PID:1026","WIRListingKey":{"6":{"WIRTitleKey":"Yahoo","WIRTypeKey":"WIRTypeWeb","WIRURLKey":"https://www.yahoo.com/","WIRPageIdentifierKey":6,"WIRConnectionIdentifierKey":"6498242f-9e42-4723-b0fa-fcc74b61ff56"}}},"__selector":"_rpc_applicationSentListing:"}'
2016-11-14 14:02:25,188 [debug] [RemoteDebugger] Page changed: {"6":{"WIRTitleKey":"Yahoo","WIRTypeKey":"WIRTypeWeb","WIRURLKey":"https://www.yahoo.com/","WIRPageIdentifierKey":6,"WIRConnectionIdentifierKey":"6498242f-9e42-4723-b0fa-fcc74b61ff56"}}
2016-11-14 14:02:25,188 [debug] [iOS] Remote debugger notified us of a new page listing: {"appIdKey":"1026","pageArray":[{"id":6,"title":"Yahoo","url":"https://www.yahoo.com/","isKey":true}]}
2016-11-14 14:02:25,188 [debug] [iOS] Checking if page needs to load
2016-11-14 14:02:25,189 [debug] [iOS] Page load needed. Loading.
2016-11-14 14:02:25,189 [debug] [RemoteDebugger] Page loaded, verifying whether ready
2016-11-14 14:02:25,214 [debug] [RemoteDebugger] Received applicationSentData response
2016-11-14 14:02:25,217 [debug] [RemoteDebugger] Received applicationSentData response
2016-11-14 14:02:25,223 [debug] [RemoteDebugger] Received applicationSentData response
2016-11-14 14:02:25,224 [debug] [RemoteDebugger] Received applicationSentData response
2016-11-14 14:02:25,387 [debug] [RemoteDebugger] Received applicationSentData response
2016-11-14 14:02:25,389 [debug] [RemoteDebugger] Receiving data from remote debugger: '{"__argument":{"WIRRemoteAutomationEnabledKey":false,"WIRIsApplicationActiveKey":1,"WIRIsApplicationReadyKey":true,"WIRApplicationIdentifierKey":"PID:1026","WIRIsApplicationProxyKey":true,"WIRApplicationNameKey":"","WIRApplicationBundleIdentifierKey":"com.apple.WebKit.WebContent","WIRHostApplicationIdentifierKey":"PID:1020"},"__selector":"_rpc_applicationDisconnected:"}'
2016-11-14 14:02:25,389 [debug] [RemoteDebugger] Application 'PID:1026' disconnected. Removing from app dictionary.
2016-11-14 14:02:25,389 [debug] [RemoteDebugger] Current app is PID:1026
2016-11-14 14:02:25,389 [debug] [RemoteDebugger] No longer have app id. Attempting to find new one.
2016-11-14 14:02:25,390 [debug] [RemoteDebugger] Found app id key 'PID:1020' for bundle 'com.apple.mobilesafari'
2016-11-14 14:02:25,390 [debug] [RemoteDebugger] Found separate bundleId 'com.apple.WebKit.WebContent' acting as proxy for 'com.apple.mobilesafari', with app id 'PID:1024'
2016-11-14 14:02:25,390 [debug] [RemoteDebugger] Using proxied app id 'PID:1024'
2016-11-14 14:02:26,185 [debug] [RemoteDebugger] Waiting for frame navigated message...
2016-11-14 14:02:26,689 [debug] [RemoteDebugger] Frame navigated in 0.503 sec from source: timeout
2016-11-14 14:02:26,689 [debug] [RemoteDebugger] Waiting for dom...
2016-11-14 14:02:26,690 [debug] [RemoteDebugger] Page loaded, verifying whether ready
2016-11-14 14:02:26,369 [debug] [RemoteDebugger] Sending javascript command (function (){ return document.readyState; })()
2016-11-14 14:02:26,369 [debug] [RemoteDebugger] Sending '_rpc_forwardSocketData:' message to remote debugger
...

Appium hangs on unresponsive webview

Our app uses WKWebviews and has built a number of custom functionality surrounding URL navigation. For example, if the app has no internet access, the webview navigates to a native page which displays the proper error message. Navigating to certain URLs within the webview also triggers the creation of a new webview and disabling the original webview.

Appium naturally does not expect this behavior, so I've resorted to handling URL navigation by executing javascript, as I don't believe it is logical for Appium to handle our convoluted webview navigation logic. The issue that I've run into is that if the app ends up in one of these unresponsive webviews, or if the URL navigation is interrupted by a native page, Appium hangs since IWDP never returns a response.

The simplest solution from my end is to add a timeout to the promise that's expecting a response from the webview, which results in an exception that I can catch and handle appropriately from my end.

Let me know if this is the right solution, and whether it has any potential side effects on the rest of the remote-debugger that I should be aware of. I'm definitely open to submitting the PR.

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.

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.