venom icon indicating copy to clipboard operation
venom copied to clipboard

Feature: Playwright executor

Open zikani03 opened this issue 6 months ago • 5 comments

This PR adds a Playwright support to venom to allow users to perform end-to-end/integration Browser tests using Playwright. It uses the playwright-go library to perform the steps.

Steps to execute actions within playwright are called "Actions" and we have several actions supported so far (see the readme).

Some elements that may need further discussion before merging (if this feature is approved) include

  • Configuration and handling of timeouts
  • Ability to pass options to different actions (currently most actions use the default options playwright-go uses)
  • Whether to support running tests with multiple browsers (instead of just one)

Example usage

This PR enables the following

name: Playwright testsuite
testcases:
- name: Check the title
  steps:
    - type: playwright
      url: https://localhost:5173
      headless: true
      actions:
        - Fill "#email" "[email protected]"
        - Fill "#email" "[email protected]"
        - Fill "#password" "password"
        - Click "#loginButton"
        - WaitFor ".welcome-dashboard"
      assertions:
        - result.page.body ShouldContainSubstring Test Application
        - result.document.body ShouldContainSubstring Hello, Zikani
        - result.document.body ShouldContainSubstring Logout

zikani03 avatar Apr 20 '25 16:04 zikani03

Hi @zikani03 , thank you for this new executor.

About default values, adding options, this should be ok with the following syntax:

name: Playwright testsuite
testcases:
- name: Check the title
  steps:
    - type: playwright
      url: https://localhost:5173
      headless: true
      actions:
        - action: fill
          search: "#email"
          value: "[email protected]"

What do you think about this?

yesnault avatar May 05 '25 07:05 yesnault

Hello @yesnault ,

I think that approach is fine. Though, writing and reading the actions as one string felt like it would be faster and more human-friendly. I don't know if there is a way we can strike a balance between typing structured YAML and that shorter syntax.

Besides that, I would just suggest that the action have the keys named differently, I'd suggest the following

actions:
  - action: fill
    selector: "#email"
    content: "[email protected]"

zikani03 avatar May 06 '25 11:05 zikani03

@zikani03 Yes, it is possible to have both syntaxes, but probably more complicated to maintain and explain over time.

Another way could be something as:

actions:
  - action: Fill "#email" "[email protected]"
    options: "optional "

yesnault avatar May 07 '25 06:05 yesnault

@yesnault I have pushed some changes and settled for the more structured approach for now. I created a separate repo to explore the DSL but I think for this PR the more structured approach works better as it requires less explanation to users. I am also comfortable with it since those who want to keep the file compact, like me, can always write the actions in one line like this :)

- { action: Fill, selector: "#password", content: "password" }

zikani03 avatar May 10 '25 22:05 zikani03

Playwright options for the actions are now supported

    actions:
      - action: Fill
        selector: "#email"
        content: "[email protected]"
        options:
          timeout: 60000

zikani03 avatar May 10 '25 22:05 zikani03