Skip to content

Commit

Permalink
Update fork (#1)
Browse files Browse the repository at this point in the history
* Update language versions

* Fix link to Readme on hex.pm

* Update keyboard.ex w/ placeholders

* Update coverage.ex w/ placeholders

* Update download.ex w/ placeholders

* Update coverage.ex w/ placeholders

* Update file_chooser.ex w/ placeholders

* Update mouse.ex w/ placeholders

* Update touchscreen.ex w/ placeholders

* Update video.ex w/ placeholders

* Update keyboard.ex w/ placeholders

* Update mouse.ex w/ placeholders

* Update api_request.ex w/ placeholders

* Update api_request_context.ex w/ placeholders

* Update api_request_context.ex w/ placeholders

* Update api_request_context.ex w/

* Update api_response.ex w/ placeholders

* Update browser.ex w/ placeholders

* Update browser_context.ex w/ placeholders

* Update console_message.ex w/ placeholders

* Update dialog.ex w/ placeholders

* Update element_handle.ex w/ placeholders

* Update frame.ex w/ placeholders

* Update fetch_request.ex (comment: "obsolete?")

* Update js_handle.ex w/ placeholders

* Update local_utils.ex (obsolete?)

* Update locator.ex w/ placeholders

* [Fixed] `Logger.warn` -> `Logger.warning`

* Update page.ex w/ placeholders

* Update request.ex w/ placeholders

* Update response.ex w/ placeholders

* Update route.ex w/ placeholders

* Update selectors.ex w/ placeholders

* Add frame_locator.ex w/ placeholders

* Update tracing.ex w/ placeholders

* Updagte websocket.ex w/ placeholders

* Update worker.ex w/ placeholders

* [Changed] start w/ playwright-core at v1.18.1

* [Changed] bump playwright-core to v1.19.0

* [Changed] bump playwright-core to v1.20.0

* [Changed] bump playwright-core to v1.21.0

* [Changed] bump playwright-core to v1.22.0

* [Changed] bump playwright-core to v1.23.0

* [Changed] bump playwright-core to v1.24.0

* [Changed] bump playwright-core to v1.25.0

* [Changed] bump playwright-core to v1.26.0

* [Changed] bump playwright-core to v1.27.0

* [Changed] bump playwright-core to v1.28.0

* [Changed] bump playwright-core to v1.29.0

* [Changed] bump playwright-core to v1.30.0

* [Changed] bump playwright-core to v1.31.0

This version bump includes non-trivial changes to how custom route handling is
implemented.

* [Changed] bump playwright-core to v1.32.0

* [Changed] bump playwright-core to v1.33.0

* [Changed] API/SDK rebuild (2/n)

Rehomed `Playwright.ChannelOwner` into `Playwright.SDK`.

* [Changed] API/SDK rebuild (3/n)

Rehomed `Playwright.Channel` into `Playwright.SDK`.

* [Changed] API/SDK rebuild (3/n)

Rehomed `Playwright.CLI` into `Playwright.SDK`.

* [Changed] API/SDK rebuild (4/n)

Rehomed `Playwright.Config` into `Playwright.SDK`.

* [Changed] API/SDK rebuild (5/n)

Rehomed `Playwright.Transport` into `Playwright.SDK`.

* [Changed] API/SDK rebuild (6/n)

Rehomed `Playwright.Channel.*` into `Playwright.SDK`.

* [Changed] API/SDK rebuild (7/n)

Rehomed `Playwright.Extra.*` into `Playwright.SDK`.

* [Changed] API/SDK rebuild (8/n)

Rehomed `Playwright.Helpers.*` into `Playwright.SDK`.

* [Changed] API/SDK rebuild (9/n)

Rehomed `test/unit` as `test/sdk`.

* [Fixed] file rename to avoid warning

* [Fixed] Update Elixir packages

* [Changed] Upgrade NodeJS and NPM packages

* [Changed] Lay groundwork for driver.js improvements

- Switch to pinning to specific versions of playwright and electron node
  packages. We should be matching.
- Simplify the asset packaging approach. Starting at v1.38 of Playwright
  (proper), using `esbuild` got much harder, and the benefits seem less
  evident. So, we're now doing a basic `cp` of what's needed.
- Bump playwright_assets to latest, in preparation for what's to come.
- Switch to `driver.js`, replacing `playwright_cli.js`; it feels nicer and
  matches the Elixir module naming.

* [Changed] Bump playwright dep to v1.38.0

This change is primarily to prove out the rest of what was needed in order to
make this version bump to playwright.js; a follow-on will bump up to the
latest.

* [Fixed] Rename: `unit_test.ex{s,}`

It turns out the module fails to load if saved as a script.

* [Changed] Hygiene: clean up `alias` usage

* [Fix] Update transport implementation to match Server API

These changes bring playwright-elixir's integration with playwright server up
to date with playwright-core v1.38.0, which appears to have had a number of
breaking changes (for our SDK). Of note:

- Update WebSocket transport to send browser type as a header, per
  recent Playwright Server API changes.
- Implement `Playwright.connect`, for WebSocket transport sessions.
- Update `ws://...` endpoint to match Playwright Server changes
- Clarify options for `Playwright.connect` vs. `Playwright.launch`
- Add debug handling of a potential serialization bug. Note that this
  may have occurred as a side effect of other Playwright Server
  integration issues that have been fixed.

* [Changed] Bump playwright-core to v1.44.0

Yet again, this upgrade changes how the Playwright CLI/program is execute. So,
this change also includes a more static defintion of `driver.js`; one that will
probably need to be reworked periodically.

* [Fixed] Resolves a number of test issues

Some of which stem from internal changes, some from changes to playwright-core.

* [Fixed] Mark `Page.Accessibility.snapshot/2` as `@deprecated`

According to Playwright.dev, accessibility testing should be executed with
separate, spacialized libraries. The Playwright implementation is deprecated.

This change also removes a failing test, in keeping with the matching removal
from Playwright proper. It appears that the browser behavior was considered to
be too inconsistent.

* [Changed] Bump package version to v1.44.0-alpha.1

Also, clean up locked deps.

* [Changed] Roll back playwright-core to v1.33.0

- Major changes to how playwright-core is vendored will come with the
  next version bump.
- Restore `esbuild` approach to `mix assets.build`.
- Fix a number of quirks stemming from rebase mistakes.

* check: v1.34.0 w/ :skip of console

* check: v1.35.0 w/ :skip of route

* check: v1.36.0 - no change

* check: v1.37.0 - no change

* check: v1.38.0 - major changes to assets.build

* check: v1.38.0 - fixes for build & install changes

* check: v1.39.0 - no change

* check: v1.40.0 w/ :skip of `Locator.set_input_files`

* check: v1.41.0 - no change

* check: v1.42.0 - BIG (temp?) changes

Fundamental changes within playwright-core are proving difficult to match for
the driver and browser installation tooling. While undesireable, for the
timebeing, the entire nodejs package tree is being vendored into `priv/static`.
The aim is to continue making progress toward upgrading to the latest
playwright-core. Once that's done, we're revisit the vendoring approach.

This change also removes Electron from the package, as it is massive and not
currently covered, exercised, or supported.

* check: v1.43.0 - no change

* check: v1.44.0 - no change

* Implement basic versions of Page.Keyboard

What changed?
=============

We implement a basic version of `Page.Keyboard` functions whose specs
were commented out in the module.

The test cases are the simplest versions I could come up with (having
borrowed heavily from [Python's keyboard tests])

The implementation also follows [Python's implementations].

[Python's keyboard tests]: https://github.com/microsoft/playwright-python/blob/2402e1283de6049cb66ea8ec6f303ba681890d2a/tests/async/test_keyboard.py#L1
[Python's implementations]: https://github.com/microsoft/playwright-python/blob/2402e1283de6049cb66ea8ec6f303ba681890d2a/playwright/_impl/_input.py#L25-L38

Noteworthy Highlights
----------------------

1. Our implementation takes a `%Page{}` struct rather than what the
   specs suggested (a `Keyboard.t()`). I don't know if it's possible to
   pass down a narrower type, but as far as I could tell `Page` had both
   the `session` and `guid` (which are needed for the `Channel.post`
   call).

2. We namespace `Playwright.Keyboard` under `Page` (i.e.
   `Playwright.Page.Keyboard`)  to match the directory structure and
   since that seems to match the Playwright documentation as well.

3. Finally, we add a new `test/assets/` directory where we include a new
   `inputs/keyboard.html` page. That page is [copied directly from
   Python][keyboard.html], so it follows Python's style of testing. In
   particular, our tests needed the `getResult()` function to get the
   values back for our test assertions.

[keyboard.html]: https://github.com/microsoft/playwright-python/blob/2402e1283de6049cb66ea8ec6f303ba681890d2a/tests/assets/input/keyboard.html#L1

* Adjust `Keyboard` to `use ...ChannelOwner`

* Tidy: alpha-sort & group functions

* Tidy/fix: Remove `keyboard.html` test asset

A reasonable idea, but unnecessary:

The [`playwright-assets`](https://github.com/mechanical-orchard/playwright-assets)
dependency provides all of the test assets. Indeed, the `keyboard.html` file
that was being utilized in the new keyboard tests is that from the
`playwright-assets` server, and not this (removed) file in `test/assets`.

* Fix: Remove `npm install` from CI build

For the time being, Node packages are installed directly into `priv/static`,
and utilized from there. This is not the desired long-term solution, but is
what is needed for the moment.

* Fix: Add browser install step to CI

* Fix: `mix playwright.install` also installs deps

* Fix: bump test timeouts: 200ms -> 500ms

200ms allows for some flakiness. Most things will still finish faster. If the
event doesn't happen in 500ms, that's probably interesting, finally.

* SDK: add `ChannelOwner.post!/3`

A long-overdue helper. This implementation also introduces a new pattern for
return values in `ChannelOwner` implementations: for calls that have simple,
"success" results, we will start returning "self" (the owner), instead of
`:ok`. The change is in support of better pipelining.

* Tidy: alpha-sort Keyboard tests

* Remove proof-of-concept implementations

- Remove proof-of-concept implementations in `lib/playwright/api/...`. We've
  decided to abanon the approach.
- Related: restore top-level, exemplar `PlaywrightTest`.

* Fix `BrowserType.connect/2` to provide correction options to `WebSocket.setup/1`.

* API: fix specs for `Keyboard`

* Minor cleanup of docs and advertised version

* Docs: improve structure

* Restructure: move API tests into test/api

* Fix:  resolve changes in v1.34.0 affecting `Page.on("console")`

A couple changes of note:

1. An `updateSubscription` message needs to be sent to indicate interest in the event.
2. Event binding has moved to `BrowserContext`.

* Fix: ensure that `BrowserContext.close/1` is idempotent

* Fix: remove `chromium` from default `ws_endpoint`

* Fix: correct the message method for `Locator.set_input_files`

**NOTE:** Of `payloads`, `local_paths`, and `streams` playwright-core
capabilities, only `local_paths` is currently supported by playwright-elixir.

* Fix: add lingering changes related to console/route fixes

* Fix make `Page.close` idempotent

* Fix: `Browser.close` should be idempotent

And some stragglers.

* API: add start of `@moduledoc` for `Keyboard`

* Fix: update repo/license with correct org

* v1.44.0-alpha.2

* Update getting-started.md

followup mechanical-orchard@42aa38f 

Playwright.launch/2 returns tuple.

* Fix: `Playwright.launch/2` returns an ok tuple

Inspired by the PR from kimihito, refrences to the return value and arity for
`Playwright.launch/2` are now correct.

* Fix: make `Locator.wait_for` timeout safe

Previously, failures due to the timeout being reached were treated as
unknown, unexpected errors. In such cases, `Channel.recv/2` would `raise`.

With this change, we can now match on `%Error{type: "TimeoutError"}`,
which avoids the `raise` and improves the API.

Note that the change also includes a small "hack": an attempt to ensure
that the related `GenServer` timeout does not occur before the
Playwright server timeout.

Fixes [issue mechanical-orchard#55](mechanical-orchard#55).

* v1.44.0-alpha.3

* Doc: use `@doc deprecated` for `Accessibility.snapshot/2`

Where as `@deprecated` issues a warning during runtime, which is annoying (in
particular, when developing playwright-elixir), the `@doc` form will mark the
function as deprecated in the documentation, without the annoyance.

* Fix: switch to latest GitHub Action for BEAM

* Add: `Locator.all/1`

Relatedly, refactor `Locator.count/1`, used by `all/1`, to make use of the new
`Frame.query_count/2`.

Also, extract some `Locator` module docs which will soon find their way into
guides.

* Doc: improve module/test docs for some `Locator` functions

* Add `Page.expose_binding/4` and `.expose_function/3`

* Add `Locator.blur/2`

* Add `Locator.clear/2`

* Add `Locator.drag_to/3`

...which in turn drives out the implementation of:

- `Frame.drag_and_drop/4`
- `Page.drag_and_drop/4`

* Increase the error-handling timeout adjustment

This attempts to ensure the browser server has time to timeout and communicate that timeout to our GenServer, before the GenServer call times out

Co-authored-by: German Velasco <[email protected]>
Co-authored-by: Corey Innis <[email protected]>

* Ignore Jetbrains config files

Co-authored-by: Corey Innis <[email protected]>
Co-authored-by: Ryan Spore <[email protected]>

* Doc: deprecation notices and whitespace cleanup

* Adds Page, Frame, and Locator get_by_text/3 functions

* Make `Locator.get_by_text_selector/2` private

Also, the `options` argument is always provided.

* Make `Locator.get_by_text_selector/2` public

It's also used by `Frame`.

* Adds Releasing guide to README

* Adds function docs for get_by_text

Also clarifies types for get_by_text options map, marks get_by_text_selector as public-but-internal,
and adds a commented out function head for get_by_text to accept a regex as a reminder.

Co-authored-by: German Velasco <[email protected]>

* Bump to 1.44.0-alpha.4

Co-authored-by: Ryan Spore <[email protected]>

* Fixes Locator.wait_for support for waiting for hidden state elements

* Fix typo

* Add test for `.content`

* Add support for `.content` to Page and Frame

* Update spec

* Add test showing user agent can be set

* Show other ways of setting userAgent

* Document setting user agent

* Update README with release/version notes

---------

Co-authored-by: Corey Innis <[email protected]>
Co-authored-by: Steven Nunez <[email protected]>
Co-authored-by: German Velasco <[email protected]>
Co-authored-by: kimihito <[email protected]>
Co-authored-by: Ryan Spore <[email protected]>
Co-authored-by: German Velasco <[email protected]>
Co-authored-by: Martin Feckie <[email protected]>
  • Loading branch information
8 people authored Oct 14, 2024
1 parent d1dc043 commit cffcd73
Show file tree
Hide file tree
Showing 563 changed files with 134,085 additions and 64,745 deletions.
10 changes: 4 additions & 6 deletions .envrc
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
#!/bin/env bash

source_up
export PROJECT="$(expand_path .)"
source_up_if_exists
export REPO="$(expand_path .)"
export ERL_AFLAGS="-kernel shell_history enabled" # persistent iex history

# default: true
# export PLAYWRIGHT_HEADLESS=false

# default: driver
# default transport: driver (websocket is the one alternative)
# export PLAYWRIGHT_TRANSPORT=websocket

# default: ws://localhost:3000/playwright
# export PLAYWRIGHT_ENDPOINT="ws://localhost:3000/chromium"
# export PLAYWRIGHT_ENDPOINT="ws://localhost:3000/"

# put your custom/local overrides in here:
source_env_if_exists .local/envrc
Expand Down
14 changes: 9 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,17 @@ jobs:
steps:
- uses: actions/checkout@v2
- name: Set up Elixir
uses: erlef/setup-elixir@v1
uses: erlef/setup-beam@v1
with:
elixir-version: '1.12.0'
otp-version: '24.0.1'
elixir-version: '1.16.2'
otp-version: '26.2.5'
- name: Install Elixir dependencies
run: mix deps.get
- name: Install Node dependencies
run: npm install --prefix assets
- name: Install Playwright dependencies (e.g., browsers)
run: mix playwright.install
# NOTE: not needed for now, while assets are
# directly installed to `priv/static`.
# - name: Install Node dependencies
# run: npm install --prefix assets
- name: Run tests
run: mix test
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,5 @@ playwright-*.tar
.medic/skipped/
.doctor.out
.vscode
*.iml
/.idea/
6 changes: 3 additions & 3 deletions .tool-versions
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
elixir 1.14.4-otp-25
erlang 25.3
nodejs 19.8.1
elixir 1.16.2-otp-26
erlang 26.2.5
nodejs 22.2.0
4 changes: 1 addition & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

### Changed

- **BREAKING:** **(WIP/UNSTABLE)** - Substantial API/usage changes are underway. e.g.:
- We intend to restore the use of tagged-tuple results (`{:ok, _}` and `{:error, _}`) throughout the code base, internally as well as for the "API".
- Bulk Package renaming.
- ...

---

Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2021 geometerio
Copyright (c) 2024 Mechanical Orchard

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
20 changes: 14 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# Playwright for Elixir

**NOTE:** This package is currently in "preview". The features are not yet at parity with other Playwright implementations. Once `playwright-elixir` is at or near parity with [`playwright`](https://github.com/microsoft/playwright), the version number will be updated to mirror the supported version of `playwright`.
**NOTE:** This package is currently in "preview" (or "alpha"). The features are not yet at parity with other Playwright implementations. Once `playwright-elixir` is at or near parity with [`playwright`](https://github.com/microsoft/playwright), the version number will be updated to mirror the supported version of `playwright`.

## Overview

[Playwright](https://github.com/geometerio/playwright-elixir) is an Elixir library to automate Chromium, Firefox and WebKit with a single API. Playwright is built to enable cross-browser web automation that is **ever-green**, **capable**, **reliable** and **fast**. [See how Playwright is better](https://playwright.dev/docs/why-playwright).
[Playwright](https://github.com/mechanical-orchard/playwright-elixir) is an Elixir library to automate Chromium, Firefox and WebKit with a single API. Playwright is built to enable cross-browser web automation that is **ever-green**, **capable**, **reliable** and **fast**. [See how Playwright is better](https://playwright.dev/docs/why-playwright).

## Installation

Expand All @@ -13,14 +13,14 @@ The package can be installed by adding `playwright` to your list of dependencies
```elixir
def deps do
[
{:playwright, "~> 1.18.0-alpha.1"}
{:playwright, "~> 1.44.0-alpha.4"}
]
end
```

## Usage

- [README](https://hexdocs.pm/playwright/README.html)
- [README](https://hexdocs.pm/playwright/readme.html)
- [Getting started](https://hexdocs.pm/playwright/basics-getting-started.html)
- [API Reference](https://hexdocs.pm/playwright/api-reference.html)

Expand All @@ -45,6 +45,10 @@ defmodule Test.ExampleTest do
end
```

## Releases

This project aims to track the release versioning found in [Playwright proper](https://github.com/microsoft/playwright).

## Contributing

### Getting started
Expand All @@ -60,6 +64,10 @@ end
- Start server: `bin/dev/start`
- Run tests and push: `bin/dev/shipit`

### Building assets for a release
### Releasing

`mix assets.build`
1. Update the version in `mix.exs`
a. Search for and update the version anywhere it appears in the repo, such as this README
2. `git tag -a v${version_number}` such that the tag look like `v1.44.0-alpha.3` or `v1.44.0`
3. `git push --tags`
4. `mix hex.publish`
Loading

0 comments on commit cffcd73

Please sign in to comment.