Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use the first created webview for webkit2gtk automation callbacks #383

Merged
merged 2 commits into from
Aug 17, 2021

Conversation

chippers
Copy link
Member

What kind of change does this PR introduce? (check at least one)

  • Bugfix
  • Feature
  • Code style update
  • Refactor
  • Documentation
  • Build-related changes
  • Other, please describe:

Does this PR introduce a breaking change? (check one)

  • Yes. Issue #___
  • No

The PR fulfills these requirements:

  • When resolving a specific issue, it's referenced in the PR's title (e.g. fix: #xxx[,#xxx], where "xxx" is the issue number)
  • A change file is added if any packages will require a version bump due to this PR per the instructions in the readme.

If adding a new feature, the PR's description includes:

  • A convincing reason for adding this feature (to avoid wasting your time, it's best to open a suggestion issue first and wait for approval before working on it)

Other information:
This is the real fix for #379. A reference to the webview passed in the automation callback is the default webview (called window in WebDriver world) that gets attached when connected to the application from a WebDriver server. With the previous partial fix, you could find the actual window and switch to it, but this fix makes it that the first created webview is the default window that is attached to. This is the same behavior as before the WebContext changes in #359 which allowed multi-window to work with WebDriver.

I checked this with Selenium and WebdriverIO on Linux. Using https://github.com/chippers/hello_tauri. Recreate the steps by building cargo b --release && cd webdriver && yarn && yarn workspaces run test. That should build everything then run both the Selenium and WebdriverIO tests against the example application using this wry branch.

I also successfully tested single and multi-window WebDriver tests from my mini-scripts available at https://gist.github.com/chippers/db4305dac38e53399ee6775d6380b31a. main.js is for testing detect_js_ecma and multi.js is for multi_window. Note that you need to add something like

// enable automation on TAURI_AUTOMATION=true (set automatically by tauri-driver)
web_context.set_allows_automation(std::env::var("TAURI_AUTOMATION").as_deref() == Ok("true"));

to enable the automation on those two examples when testing them.

@chippers chippers requested a review from a team as a code owner August 17, 2021 05:24
@chippers chippers requested a review from a team August 17, 2021 05:24
@wusyong wusyong merged commit f9d7049 into dev Aug 17, 2021
@wusyong wusyong deleted the fix/webcontext-first-webview branch August 17, 2021 05:38
@github-actions github-actions bot mentioned this pull request Aug 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants