52 Commits
Author SHA1 Message Date
Dan Graham 644208fe60 Copy W3C/Element keys instead of renaming them (#290) 2018-12-10 13:24:36 -08:00
Mykola Mokhnach 3141e831cb Properly synchronize applications caching (#274) 2018-10-22 16:10:35 +02:00
Mykola Mokhnach 14cfcfcef7 Make it possible to pass multiple supported extensions to configureApp helper (#271) 2018-10-19 20:27:54 +02:00
Jonathan Lipps 02b3b87164 add custom locator strategy (#268)
* add custom locator strategy

* address review comments

* allow customFindModules cap to register multiple modules as an object

* add unit tests for custom element finding plugin
2018-10-12 10:19:57 -07:00
Isaac A. Murchie 04af064564 Update appium-gulp-plugins (#266) 2018-10-03 09:00:58 -04:00
Mykola Mokhnach 5231fae89b Apply additional fixes to timeouts handler (#250)
* Apply additional fixes to timeouts handler

* Address comments

* Update the rest of tests

* Remove unused import

* fix the unit test
2018-08-15 15:26:47 +02:00
Jonathan Lipps ec72948de2 add -image locator strategy and related logic (#235)
* add -image locator strategy and related logic

* use appium-support jimp helper

* handle find multiple elements by image

* update staleness check variable name

* ensure that a settings object always exists so we can rely on global settings always existing too

* only fix template size if user requests it in settings

* add note about implicit wait error handling

* only automatically update image element position if user turns on an appropriate setting

* add setting to control whether we check for image element staleness

* add setting to determine the image element tap strategy (w3c or mjsonwp)

* prefer single quotes

* add setting to turn off screenshot resizing if not desired

* add docstrings (except for cache class which we may not keep)

* address additional review comments

* add better jsdoc arg info

* use lru-cache npm package instead of rolling our own

* use new versino of appium-support

* make sure the lru cache is checking element size correctly

* give better names and tighten up logic around image el tap strategies

* add some unit tests for image elements

* ensure DeviceSettings has a default no-op update method

* check that driver implements action strategies and fall back / throw as appropriate

* finish out image element unit tests

* have basedriver set noop onSettingsUpdate rather than doing it in DeviceSettings

* move route avoidance detection from protocol to driver

* handle proxying actions to downstream drivers during image tap

* tighten up logic for deciding whether to proxy based on presence of image element

* add find by image specs and fix issues that arose in the process

* clean up regexes

* don't try to be smart and proxy actions for drivers; let them set it up themselves to support image elements

* change default match threshold based on experimentation

* export which settings are handled by basedriver so downstream drivers can utilize this information

* make sure to include a duration for the initial pointerMove action

* add docstring to proxyRouteIsAvoided
2018-07-30 13:17:54 -07:00
Isaac Murchie d98c9afe2b Fix reset tests 2018-06-29 16:26:56 -04:00
Isaac A. Murchie 5f318b4eef Remove list of valid automation names (#229) 2018-06-29 11:02:08 -04:00
Dan Graham 850ab93833 Fix: Add 'app' cap to reset tests (#226)
* This test worked fine in base driver but these tests also run in fake driver and don't work beause `app ` is a required capability
* Added `app=fake` to caps
2018-06-23 18:58:38 -07:00
Isaac A. Murchie 87d2f9b672 Fix reset tests for importation (#224) 2018-06-12 07:49:21 -04:00
Dan Graham f72dc5a3ac Fix: Make 'reset' re-use same protocol (#219)
* Before, reset was creating a new session and using the processed caps
* The problem with is, if it was W3C it would create a MJSONWP
* Now it checks the protocol before resetting and passes in the appropriate args to createSession depending on the protocol type
2018-06-07 13:15:28 -07:00
greenkeeper[bot] 8439803500 Update dependencies to enable Greenkeeper 🌴 (#216)
* chore(package): update dependencies

* docs(readme): add Greenkeeper badge

* chore: adapt code to updated dependencies
2018-06-04 14:48:50 -04:00
Mykola Mokhnach 72dd453b9a Enforce UTF-8 encoding on request headers (#214)
* Enforce UTF-8 encoding on request headers

* Return all headers in lowercase as per HTTP/2 requirement
2018-05-29 07:15:23 +02:00
Isaac A. Murchie 1f87d0e289 Update dependencies (#206)
* Update deps

* Fix a couple of tests

* Fix protocol tests

* Fix timeout in helper and protocol tests
2018-04-27 11:08:08 -04:00
Mykola Mokhnach 6311b34615 Add an universal endpoint for images comparison (#203)
* Add an universal endpoint for images comparison

* Rename arguments

* Add documentation

* Raise appium-support version
2018-04-19 15:53:15 +02:00
Mykola Mokhnach 2cb6695446 Send request along with websocket instance (#200) 2018-03-29 14:29:22 +02:00
Dan Graham f7f822611c Parse protocol from executeCommand (#195)
* If`executeCommand` returns an object that has a property 'protocol' and either a 'value' property or an 'error' property, respond with the provided protocol
* If the object is of this form, than it came from another driver that knows what protocol is being used so we re-assign the protocol to whatever was reported
* Added to delay in the 'unexpected exits' test because I was getting a race condition
2018-03-27 14:00:36 -07:00
Mykola Mokhnach 8a48eb3f94 Tune prefix handling for web socket pathnames (#198) 2018-03-23 18:44:33 +01:00
Mykola Mokhnach b1648467dc Add common websocket handlers (#196)
* Add common websocket handlers

* tune the default prefix

* Add integration test

* Tune the test

* Fix the functional test

* Tune socket import

* Address review comments

* Tune some expectations
2018-03-22 16:21:02 +01:00
Isaac Murchie 1cd44cf1b5 Distinguish new window from plain window in static page 2018-03-15 15:24:56 -04:00
Dan Graham da4f28f7d9 Fix: Determine protocol in createSession (#194)
* Previously, we were only checking the HTTP payload to see what protocol should be
* This is inadequate, in the case of drivers that don't proxy W3C Capabilities yet
* The fix now is to set the protocol in `createSession` to see if the W3C caps were proxied through, if they're not, set protocol to MJSONWP
* Added unit test and one e2e test to confirm that this works
2018-03-14 15:44:50 -07:00
Isaac A. Murchie b143cff884 Add logging commands to the base driver (#191)
* Add logging commands to the base driver

* Address comments
2018-02-23 12:02:20 -05:00
Mykola Mokhnach c0bb5166c8 Print more advanced error message for non-supported protocols (#189) 2018-02-21 17:20:48 +01:00
Dan Graham 97c02c8af0 Rename 'mjsonwp' to 'protocol' (#178)
* Rename 'mjsonwp' to 'protocol'
  * Renamed folder from 'mjsonwp' to 'protocol' in `lib/` and `test/`
  * Renamed 'mjsonwp.js' to 'protocol.js'
  * Renamed any import statements that use 'mjsonwp'
  * _Possible breaking change_: MJSONWireProtocol class exposed in index was renamed to just Protocol.... checked Appium repo and found no libraries that use MJSONWireProtocol
* Lint fix
2018-01-29 12:41:14 -08:00
Dan Graham 129dd86976 Rename ELEMENT key to W3C format (#175)
* If server encounters a response that has the wrong key name (ELEMENT when it should be 'element-6066-11e4-a52e-4f735466cecf'), rename all instances of that key
* Added a helper method (with tests) that recursively finds instances of a 'key' and renames it
* Added e2e test that mocks `findElements`, calls `/elements` endpoint and verifies that the payload was correctly renamed
2018-01-19 11:43:24 -08:00
Dan Graham 9ac3bdd634 Consolidate non-prefixed caps warnings (#174)
* Previously, it was going through alwaysMatch and all of the firstMatch caps and individually logging when any of them had unprefixed, non-standard caps
* Now it does them all at once
  * Made a helper function that takes a caps object ({alwaysMatch, firstMatch}) and finds all of the non-prefixed caps in all of them
  * Calls that function and logs warning
2018-01-18 12:50:57 -08:00
Isaac A. Murchie fff1edfe3b Get rid of arrow functions in mocha aparatus (#173) 2018-01-18 07:27:05 -05:00
Mykola Mokhnach 5308c4a47e Assume a file is located on SMB server if the path starts with double backslash (#172)
* Assume a file is located on SMB server if the path starts with double backslash

* Add more logging

* Update the test
2018-01-18 07:27:54 +01:00
Dan Graham 98251e0b4f Check that W3C capabilities is a plain object (#171)
* If 'capabilities' and 'desiredCapabilities' were provided, and 'capabilities' is NOT a plain object, fall back to 'desiredCapabilities'
* Added more logging to the W3C vs. MJSONWP determination logic
* Rename `createSession` args to be more descriptive
* Added basic W3C unit tests for above fix
2018-01-15 14:49:36 -08:00
Kazuaki Matsuo 31f16ac92f Fix implicit wait for w3c (#164)
* fix timeouts for w3c

* revert lock file

* add validation for previous timeouts

* implement custom validator for W3C

* improve if condition

* define isW3CProtocol

* rewrite validation a bit

* apply util.hasValue and string protocol

* add tests

* refactor timeouts for mjsonwp and w3c

* use const

* remove previous timeouts

* use undefined

* rename to timeouts again

* wrap some commands

* remove ...args

* define each command
2018-01-12 08:55:38 +09:00
Dan Graham 45e31b15ac Set automations in one file (#167)
* Made an 'automations.js' file that lists all valid automations as an Object instead of hard-coding it
* appium/appium will use this instead of hardcoding automation names
* Make desired-caps pull in the values of those automations for validation instead of hard-coding them
* Expose 'validAutomations' to Driver object
2018-01-11 10:07:33 -08:00
Dan Graham 281916ffee W3C remediations (#165)
* Fixed a defect in 'firstMatch' validation
  * Previously, it was validating the firstMatch capabilities and was failing on the first validation failure, which is a problem if firstMatch has a length > 1 and it fails before finding a potentially passing capabilities set is found
  * Now, it doesn't error-out on the first failure. If it fails, it skips over it to the next one until it finds one that passes and returns that.

* Altered the 'presence' constraint validation
  *  Don't validate 'presence' on 'alwaysMatch' because if a capability isn't present on 'alwaysMatch' it may be present in one of the 'firstMatch' capabilities
  *  Validate presence on all of the 'firstMatch' capabilities, except for the keys that are present in 'alwaysMatch'. If the key is in 'alwaysMatch', strip out the presence constraint because we know that it has passed already

* Changed the default protocol
  * If MJSONWP _and_ W3C are provided, initiate a W3C session by default. If clients are passing in W3C parameters to create a session, we can safely assume that they've implemented the rest of the W3C spec

* Improved error logging
  * If errors were found, show a message saying `Could not find matching capabilities: ${errors}` where `errors` are a list of all the validation error messages for each of the attempts to validate `firstMatch` caps
  * If `firstMatch` caps has a length of one, then don't show the message saying `Could not find matching capabilities` portion of it, just show the errors

* Other remediations
  * Allow `alwaysMatch` and `firstMatch` to be `null` or `undefined`
  * Added single quotes around names of capabilities when showing their errors
2018-01-10 10:37:11 -08:00
Dan Graham 376a0d3089 Make it so that 'status' is only returned for MJSONWP (#160)
Also:
* Make the 'fake-driver' a MJSONWP driver
* Fix unit tests that were broken when being called in 'appium-fake-driver'
2017-12-22 12:20:48 -08:00
Dan Graham d41b3629aa Don't validate 'presence' on firstMatch caps (#159)
* Doesn't make sense to validate 'presence' in the firstMatch caps, because the firstMatch caps extend alwaysMatch
* Only 'alwaysMatch' should validate 'presence'
2017-12-21 09:55:27 -08:00
Dan Graham 53de387100 Handle capabilities prefixes (#153)
* Strip out 'appium:' prefixes
* Reject standard capabilities that contain the 'appium:' prefix
* Expose 'processCapabilities' as API method
2017-12-13 14:53:05 -08:00
Dan Graham 4d2a5bd000 w3c routes (#147)
* Add aliased W3C routes
* Implement getTimeouts command
* getTimeouts returns an object containing all the timeouts and their values as key-value pairings
* Added routeHandler too
* Added w3c routes
2017-11-21 04:54:39 -08:00
Dan Graham 308e560ca1 W3C Error Formatting (#145)
* Remember protocol requested in createSession
  * Also renamed 'processCaps' to 'processCapabilities'
  * Checks the parameters in 'createSession' and determines if it's W3C or MJSONWP
* Add W3C error format
  * Add W3C status codes to errors
  * When deciding error format to return in mjsonwp.js, check format and then return eitherJSONWP or W3C format
2017-11-21 04:54:39 -08:00
Isaac A. Murchie 01e9914b66 Update linting and add coverage (#131) 2017-08-15 08:53:47 -04:00
Isaac A. Murchie 3bffc168b8 Allow downloaded app urls to have query strings (#125)
* Allow downloaded app urls to have query strings

* Readjust some of the work
2017-07-07 07:24:59 -04:00
Jonathan Lipps acd890bb20 fix bug in DeviceSettings where we could mutate external object 2017-06-15 14:35:33 -07:00
Dan Graham 0bf5acbd52 Removed adm-zip (#118)
* Added a test for unzipFile (which uses adm-zip)
* Tested that it worked with adm-zip and then failed once adm-zip was taken out
* Replaced 'adm-zip' with zip.extractAllTo from appium-supprt
2017-04-26 17:55:46 -07:00
Dan Graham 9d1b2cedae Implemented capabilities spec (#117)
* Update  hash

* Add validateCapabilities and parseCapabilities

* Added merge capabilities

* Moved capabilities into it's own file

* Added capabilities as a possible required param

* Can pass desiredCapabilities or capabilities into createSession

* Remove 'required' desiredCapabilities

* desiredCapabilities isn't required any more because we can provide capabilities as well
* Will need to  update validation logic in 'driver.createSession' to do the validation there instead

* Code cleanup

* Skip presence constraint in parseCapabilities

* We don't need to check that items are present until after we've formed the matched capabilities

* Added validation function to routes

* Function 'validate' takes params as an arg and then returns a message if the validation fails
* Uses this to validate that either "capabilities" or "desiredCapabilities" was provided

* Renamed capabilities to caps

* Move caps required validator from process to parse

* Removed InvalidParametersError

* Update BadParametersError so that if a message is added as the 3rd argument it shows a different error message

* Made validation re-usable
2017-04-07 15:12:12 -07:00
Jonathan Lipps d75bde2a0e add event timing framework to base driver 2017-03-03 13:41:02 -08:00
Jonathan Lipps 0ad8e49b8e error out if someone tries to use both fullReset and noReset together 2017-01-31 14:17:36 -08:00
Sam Park 40a9538321 Fix handling non-ZIP files
APK files were not being installed because they were being written to a file without an "apk" extension. So added back the appExt suffix logic. If it's given and the downloaded file is not a ZIP file, then everything behaves normally. If the downloaded file is a ZIP file, then regardless of what we thought initially, it will be unzipped and placed into another temp location.
2016-11-11 23:21:02 -08:00
Isaac Murchie 0df402b1b2 Add linting and pre-commit hooks 2016-07-12 09:48:01 -07:00
Isaac Murchie b883d8601b Add basic getStatus method 2016-07-08 09:21:29 -07:00
Isaac Murchie e44ed397f6 Add ability to manage delegated drivers 2016-07-01 09:15:33 -07:00
Isaac Murchie 6086ae0b29 Make sure the server is closed when we call close 2016-06-22 08:16:36 -07:00