Commit Graph

78 Commits

Author SHA1 Message Date
Mykola Mokhnach dd64a48fca fix(base-driver): Restore the legacy proxy url behaviour (#21021) 2025-02-20 15:24:46 -08:00
Mykola Mokhnach 8a664a4eef fix(base-driver): Optimize the logic of getUrlForProxy (#21018) 2025-02-20 19:59:15 +01:00
Kazuaki Matsuo 419661013b chore(appium): returns this.caps for /session/:sessionId/appium/capabilities (#20979)
* return the same value of getSession

* chore: update docs and implementation

* remove event stuff

* add type in return

* add AppiumSessionCapabilities type

* update the syntax

* rename

* add test in e2e

* remove unnecessary type

* use fake driver name
2025-02-14 08:08:42 -08:00
Kazuaki Matsuo 7edd3bdc11 chore: use RegExp to check session id requirement (#20947)
* chore: use regext to check session id requirement

* update docs

* add test case

* use match of path-to-regexp

* use another name to avoid conflict

* accept appium prefix for non-session id
2025-02-01 01:03:15 -08:00
Kazuaki Matsuo eeb59cab07 feat: add /appium/sessions, /session/:sessionId/appium/capabilities and deprecated marks will be removed in the future (#20936)
* feat: add /appium/sessions, /session/:sessionId/appium/capabilities and deprecated marks will be removed in the future

* add a dymmy implementation

* move entire deprecated endpoints in bottom of each section

* define GET_APPIUM_SESSION_CAPABILITIES and add it to isAppiumDriverCommand

* adds _COMMAND

* remove unnecessary method definition

* move deprecated endpoints

* add temporary implementation
2025-01-28 10:14:51 -08:00
Mykola Mokhnach a6b6077ecd feat: Add /appium/extensions API to list available extensions (#20931) 2025-01-25 17:02:41 +01:00
Mykola Mokhnach 059f1cb698 feat(base-driver): Add an API to list commands (#20914) 2025-01-23 19:07:16 +01:00
Mykola Mokhnach 65658ccbdd fix: Reduce linter warnings (#20860) 2024-12-28 09:30:05 +01:00
Mykola Mokhnach 25ea9f73bc chore: Migrate to flat ESLint config (v9) (#20856) 2024-12-27 20:42:36 +01:00
Mykola Mokhnach f0de55da0d fix(appium): Return hostname as web socket url for BiDi if a broadcast address is assigned to the server (#20603) 2024-09-24 08:40:04 +02:00
renovate[bot] 63cb664af1 fix(base-driver): update dependency path-to-regexp to v8 (#20520)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Mykola Mokhnach <mokhnach@gmail.com>
2024-09-04 18:47:07 +02:00
Mykola Mokhnach 16015de1b5 chore(driver-test-support): Bump chai and chai-as-promised (#20344) 2024-07-08 22:56:16 +02:00
Mykola Mokhnach ac912606e7 chore(base-driver): Optimize routeToCommandName logic (#20331) 2024-07-07 08:04:26 +02:00
renovate[bot] a746eefbbb fix(base-driver): update dependency path-to-regexp to v7 (#20279) 2024-06-25 08:50:56 +02:00
Kazuaki Matsuo 0363aab8ba feat(appium): Add session signature to all logs (#20202) (#20214)
* feat(appium): Add session signature to all logs (#20202) (#20214)

* test(logger): add tests for unleakString (#20222)

---------

Co-authored-by: Mykola Mokhnach <mokhnach@gmail.com>
Co-authored-by: Edgars Eglītis <37242620+eglitise@users.noreply.github.com>
2024-06-07 13:13:39 -07:00
Kazuaki Matsuo 40def9dbdb fix(appium): Revert changes in 20203 and 20202 (#20209)
* Revert "feat(appium): Add session signature to all logs (#20202)"

This reverts commit b3f8a47c2d.

* Revert "feat(logger): Add the 'debug' level to the default logger (#20203)"

This reverts commit 7fd9d5f626.
2024-06-06 16:17:57 -07:00
Mykola Mokhnach b3f8a47c2d feat(appium): Add session signature to all logs (#20202) 2024-06-06 22:46:52 +02:00
Mykola Mokhnach 275790ec01 fix(base-driver): Update the web socket upgrade behavior (#20142) 2024-05-24 19:57:54 +02:00
Kazuaki Matsuo b83bd04265 chore(base-driver): remove mobileRotation as no references (#19379)
* chore(base-driver): remove mobileRotation as no references

* docs: remove unused endpoint

* test: fix test
2023-11-06 23:12:11 -08:00
Mykola Mokhnach 5926919177 feat(base-driver): Add server support of TLS and SPDY protocols (#19105) 2023-09-08 08:02:56 +02:00
Mykola Mokhnach 2f69e6db2a chore(base-driver): Improve bad parameters error message (#19002) 2023-08-19 08:27:31 +02:00
Christopher Hiller 2b351705d4 fix(base-driver): pass thru all type args to ExternalDriver
- `core` module is now TS
- `constants` module is now TS
- export missing `W3C_ELEMENT_KEY`
- `JWProxy.command` returns `Promise<unknown>`.  deal with it
- updated some type tests
2023-07-03 13:10:51 -07:00
Christopher Hiller 01061b2919 fix(types,base-driver): remove deviceName from base constraints
This cap was conflicting with constraints defined in subclasses.  Currently, it isn't possible to cleanly "override" constraints.  Given `deviceName` is not used anywhere within base-driver's source, this seems like a decent workaround for now.
2023-07-03 13:10:51 -07:00
Christopher Hiller deb631b456 fix(basedriver): convert main driver implementation to typescript
This seems to fix the bug in #18379.  There must be some sort of bug in TypeScript w/r/t `@implements` or maybe even it was not treating `@typedef` as a proper alias.  Perhaps it's user error--omitting optional type args in alias-style typedefs may end up making a new type entirely.  idk, but this was easier to deal with.

Closes #18379.
2023-03-27 17:07:51 -07:00
Christopher Hiller 238c489f3a chore(base-driver): add a failing type test 2023-03-27 17:07:51 -07:00
Christopher Hiller be86627595 fix(base-driver): use new mixin strategy
also fix a broken type in fake-driver
2023-03-02 15:47:24 -08:00
Jonathan Lipps 7055a0b281 feat(base-driver): deprecate non-standard routes
and add deprecation warnings in the log when these routes are accessed
2023-01-12 10:11:08 -08:00
Jonathan Lipps d8588e107c docs: add ExternalDriver docstrings (#17985) 2023-01-10 14:36:48 -08:00
Jonathan Lipps 23224cf002 fix(appium): inability to find automationName inside appium:options (#17966)
* fix(appium): inability to find automationName inside appium:options

we fixed this before but only fixed it in basedriver's createSession, which is not
actually called by Appium's createSession (though maybe it should be)

* test(base-driver): remove appium:options test
2022-12-28 10:54:39 -08:00
Kazuaki Matsuo 316ecca8b1 feat(base): add get computed role and label in W3C v2 (#17928)
* feat(base): add get computed role and label in W3C v2

* add command names

* chore: add type

* chore: use `?` instead of `| null`

Co-authored-by: Christopher Hiller <boneskull@boneskull.com>

* Revert "chore: use `?` instead of `| null`"

This reverts commit 62af5e80ac.

Co-authored-by: Christopher Hiller <boneskull@boneskull.com>
2022-12-15 20:46:44 -08:00
Christopher Hiller f715bb4fd8 chore(base-driver,base-plugin,execute-driver-plugin,fake-driver,fake-plugin,images-plugin): update some types for typedoc 2022-11-22 14:32:10 -08:00
Mykola Mokhnach 91901153a1 fix(base-driver): Properly validate capabilities inside appium:options map (#17781) 2022-11-20 08:52:29 +01:00
Christopher Hiller 51d6d69ff1 fix(basedriver): ensure "opts" is defined at time of construction 2022-10-14 14:01:07 -07:00
Christopher Hiller b20d0b82a2 chore(appium,base-driver,driver-test-support,types): overhaul types for constraints and caps
The big idea here is:

1. `desiredCapConstraints` should always contain the constraints _for that driver_; it no longer contains the "base" constraints. This is the only thing that really required any logic changes (though they are somewhat spread out).  The "merged" constraints object is available via `_desiredCapConstraints`.
2. `Capabilities` and W3C-style `W3CCapabilities` are now _derived from_ constraints.  This absolves us (and extension authors) from needing to create an interface describing their capabilities.
3. Changes to caps and constraints now reflect in `DriverOpts` (`this.opts`) in drivers
4. `caps` and `originalCaps` declarations have moved from `Core` to `Driver`
5. TypeScript compiles the JS output from `@appium/types` (which is just a static "constraints" object)

Resolves #17518
2022-10-06 15:30:22 -07:00
Christopher Hiller c37f4500c2 test(base-driver): use @appium/driver-test-support 2022-08-23 13:42:47 -07:00
Christopher Hiller 70d88cb86f feat(appium,base-driver,base-plugin,test-support,types): move test fixtures into test-support
- `@appium/test-support` now exports the e2e setup for plugins, and e2e/unit suites for drivers from base-driver.  it also generates declarations.
- `appium` exports this as `appium/test`.
- The `capability.spec.js` unit test for basedriver now avoids spying on the "global" logger, due to test flake.  It now spies directly on the function which calls the global logger. (@mykola_mokhnach)
- removed homebrew ansi-stripping code from `test-support` and replaced with `@colors/colors`
- type fixes and refactors for `@appium/test-support`
- type fixes for `appium`
- simplify `lib/index.js` of `@appium/base-driver`
2022-07-18 15:58:21 -07:00
Christopher Hiller 133db5355f chore: reformat everything
this reformats all `.js`, `.ts`, and `.d.ts` files.
2022-05-09 19:09:50 -07:00
Christopher Hiller 2d76923e72 fix(base-driver): do not throw if updateSettings aren't provided
BREAKING CHANGES

Some plugin tests were calling code which called the `update()` method of `DeviceSettings`, but there's apparently no code that actually sets the `onUpdateSettings` listener anywhere (maybe drivers can opt-in to this behavior?), which was causing exceptions to get thrown.

The E2E tests expected this code to reject, but the plugin tests expected it to _not_ reject, so I'm not sure what's right.

- adds unit tests for `DeviceSettings`

_Note: after further investigation, I think this was throwing simply due to `base-plugin` using an old version of `appium-fake-driver` which used an old `appium-base-driver`.  @jlipps says this change is OK._
2022-04-14 14:30:00 -07:00
Mykola Mokhnach 78a46375ae feat(base-driver): Add a route for new window creation (#16748)
* feat(base-driver): Add a route for new window creation

* Update param name

* Update types
2022-04-12 14:51:16 -07:00
Mykola Mokhnach ff3b290c77 chore(base-driver): Update ws dependency (#16739) 2022-04-09 22:56:01 +02:00
Mykola Mokhnach a9651d3c59 fix(base-driver): Update/simplify the logic for logger prefix (#16683) 2022-04-01 22:34:57 +02:00
Mykola Mokhnach d8a9b4da36 feat(base-driver): Add more shadow root-related W3C routes (#16700) 2022-03-31 17:46:44 +02:00
Christopher Hiller 164bedb2f1 feat(base-driver): generate declaration files
This was not as easy as the other two.  The main issue involves the `BaseDriver` class and is threefold:

1. `BaseDriver` and a valid external subclass thereof (a `Driver`) are not the same, because the former is essentially _abstract_. There is no notion of an abstract class in JS nor in TS for JS.
2. Splitting `BaseDriver` into several modules and "mixing in" some modules is just not well-understood by TS.
3. `AppiumDriver` inherits _most_ of `BaseDriver`, but overrides some functions with differing signatures. This is unsupported by TS.

To work around these problems, I had to:

1. Move the `Driver` interface into `@appium/types`, since other packages may depend on it.  We do not want circular dependencies, which is likely to occur otherwise.  Further, there is no way to tell TS for JS that a class _implements_ an interface or type.
2. Refactor the mixins (in `basedriver/commands/`) into "mixin classes", as understood by typescript. These are dynamic classes returned by functions which accept a class parameter, and _extend_ that class. The result is marginally better, but the implementation is ... well, see for yourself.  It is not possible to use declaration merging to just "trick" TS into thinking that `BaseDriver` has all of these extra methods; classes cannot be merged, and even if you could, you can't use declaration merging to "add" methods afaict.
3. `BaseDriver` is now an empty class which inherits from all mixins applied to `DriverCore`.  Due to syntactic restrictions, it must be a `class` statement in order to use the `@implements` tag, which causes TS to check that the result fully implements `Driver`.  `AppiumDriver` _also_ inherits from `DriverCore`, since it does not override `BaseDriver` "properly".  `BaseDriverCore` itself is pretty small, containing only those functions which `AppiumDriver` defines as differing.

Otherwise:

- `BaseDriver` does not inherit from `Protocol`, which is just an empty class. `Protocol` was removed.
- All of the error classes are exported from `protocol/errors`, because TS cannot see them otherwise.
- Exported missing `GET_STATUS_COMMAND` from `protocol/index`
- Re-exported `normalizeBasePath` from `server` instead of `protocol`, since that's where it's defined
- Removed `index.d.ts`
- Mixins use `@implements` as well. Note that `@implements` does not support `import('..')` syntax.

chore(base-driver): attempted to make types for mixins less awful

fixed a couple issues in the types in `driver.js`

core(base-driver): add capabilities types

- also move the bluebird config into the index
- fix references to `DriverOpts`
- add `assignServer()` to `BaseDriverCore`, used by `AppiumDriver`

chore(base-driver): fix more types

add missing reference to `@appium/types` in `tsconfig.json`

fix(base-driver): ensure getLogEvents is async

fix(base-driver): add some more type checks and fix logCustomEvent to be async

chore(base-driver): reformat
2022-03-25 14:54:45 -07:00
Christopher Hiller 35d9dc7ebc chore(base-driver): ungulpify
This PR removes Gulp from `@appium/base-driver` and reorganizes the test files.

The build needs to be a little different since other modules depend on its `build/test/basedriver` module.  IMO this should probably get moved elsewhere, but this does not break compatibility.
2022-03-22 18:12:02 -07:00
Kazuaki Matsuo 3ee93ba5bd fix: revert 15809 (#16621)
* fix: revert 15809

* change comment
2022-03-21 10:10:35 -07:00
Christopher Hiller 5be33381fd test(base-driver): rewrite some assertions in capability-specs
simplified some stuff that was giving me problems.

instead of doing a try..await..catch and calling `fail()` if the catch block wasn't called, just use `sinon-chai`'s `.should.eventually.be.rejectedWith(ErrorClass, /message/)`

depending on the order in which this test file is run versus others, it's possible that some will fail because of global logging weirdness.  but normally this doesn't happen... keep an eye on it!
2022-03-09 14:50:45 -08:00
Christopher Hiller 2781805c05 chore: ban direct usage of sinon (#16485)
* chore: ban direct usage of sinon

Calling `sinon.stub()`, `sinon.mock()` etc., directly is error-prone. Care must be taken to explicitly restore any stub created.

Using a sandbox (via `sinon.createSandbox()`), you don't need to remember to restore everything you fiddled with.

To that end, I've converted all direct `sinon` calls into sandbox calls and **BANNED** direct usage of `sinon` via ESLint.

# Conflicts:
#	.eslintrc

* test(base-driver): replace restricted sinon.spy() usage in server-specs.js

* test(support): formatting
2022-03-09 14:50:45 -08:00
Mykola Mokhnach 493c48d190 feat: Add a missing route for element shadow root (#16538) 2022-03-09 18:51:41 +01:00
Mykola Mokhnach 83493941ee refactor: Make loggers connected to the particular driver instances (#16478) 2022-02-23 07:49:42 +01:00
Christopher Hiller 79772d7a4f test(base-driver): replace direct calls to sinon with a sandbox
This is safer, because test failures can happen due to lack of isolation and order in which tests are executed
2022-02-17 11:52:52 -08:00