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

[POC]- adding support for playwright #266

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

omkarkhatavkar
Copy link

@omkarkhatavkar omkarkhatavkar commented Oct 20, 2024

[POC] Playwright Support for Widgetastic

Playwright Integration in Widgetastic

Widgetastic now supports Playwright in addition to Selenium, giving users more flexibility in browser automation. With Playwright, you can perform actions such as:

  • Clicking elements
  • Hovering over elements
  • Capturing screenshots
  • Fetching attributes
  • Handling multiple elements

Running Tests with Playwright

You can easily switch between Selenium and Playwright for testing. Here's how to get started:

  1. Install Playwright:

    pip install pytest-playwright
    playwright install
    
  2. Run Tests with Playwright: Use the --engine option to select Playwright:

     pytest --engine=playwright
    
  3. Choose a Browser: You can specify which browser to use with the --browser-name option:

      pytest --browser-name=chromium --engine=playwright
    
  4. Optional Features:

  • Run tests in headless mode:
    pytest --engine=playwright --headless

  • Enable tracing for debugging:
    pytest --engine=playwright --trace_view

  • Record video of the tests:
    pytest --engine=playwright --record_video

@omkarkhatavkar omkarkhatavkar marked this pull request as draft October 20, 2024 12:39
@omkarkhatavkar omkarkhatavkar force-pushed the playwright branch 4 times, most recently from 59c5f11 to 27fa02b Compare October 20, 2024 12:57
@omkarkhatavkar omkarkhatavkar changed the title adding support for playwright [POC]- adding support for playwright Oct 22, 2024
Copy link
Collaborator

@RonnyPfannschmidt RonnyPfannschmidt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this proof of concept is quite daring and a amazing start

we'll have to figure how to properly separate the engine types
the approach to prototype getting it to work at all, we will hit thousands of paper-cuts down the line when trying to integrate it with selenium-expecting downstream projects like kaifuku and other tools

additionally managing backend selection by 2 optionals makes for very fragile code in the long run (but it is a good trade-off when demonstrating initial viability of a idea)

we need to more strictly separate them and evolve a reasonably share-able interface plus in addition to that a sane ci process to ensure it works

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this file needs to go

@@ -225,12 +227,14 @@ class as plugin.

def __init__(
self,
selenium: WebDriver,
selenium: WebDriver = None,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should try to ensure that the browser turns unaware of Webdriver vs Page

we need to investigate whether this an be done by new mixins or an additional helper that abstracts the engine

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