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

Add caching #179

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open

Add caching #179

wants to merge 6 commits into from

Conversation

gladyshcodes
Copy link

@gladyshcodes gladyshcodes commented Dec 26, 2024

Issue #124

This PR introduces basic caching mechanism to reduce costs and increase effectiveness of running test suites.

Performance Boost: Achieves an average speedup of 400%-600%, automations like "Find Lionel Messi Wikipedia page" now completing about 5x faster

Flow diagram


Note: This PR is WIP and still on early stage. It's there early to gather feedback. Future tests, refinements and enhancements will be made to make it reliable and even more performant

Copy link

vercel bot commented Dec 26, 2024

@gladyshcodes is attempting to deploy a commit to the Antiwork Team on Vercel.

A member of the Team first needs to authorize it.

@CLAassistant
Copy link

CLAassistant commented Dec 26, 2024

CLA assistant check
All committers have signed the CLA.

@gladyshcodes
Copy link
Author

gladyshcodes commented Dec 27, 2024

One challenge is:

async getComponentStringByCoords(x: number, y: number) {
    return await this.getPage().evaluate(
      ([x, y]) => {
        const elem = document.elementFromPoint(x, y);
        return elem?.outerHTML.trim().replace(/\s+/g, ' ');
      },
      [x, y]
    );
  }

The function above retrieves normalized component string given X and Y coordinates. The reason it's implemented this way is that currently, Playwright does not support selecting DOM elements using coordinates (see this closed issue). The only way I have found was to use native document func. If you have any other ideas in mind, please suggest 👍

Copy link

vercel bot commented Dec 27, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
shortest ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 27, 2024 10:30pm

@m2rads
Copy link
Contributor

m2rads commented Dec 27, 2024

Would be nice to resolve the conflicts and then I can test your branch locally.

@gladyshcodes
Copy link
Author

Would be nice to resolve the conflicts and then I can test your branch locally.

@m2rads I have resolved conflicts now. You can check it out.

@gladyshcodes
Copy link
Author

Refinements / Improvements:

  1. Write new text execution to cache file only after it has been successfully completed. That way we can be sure cached tests are only successful ones
  2. Delete cache entry if it fails to run (e.g UI change) and rewrite it

@m2rads
Copy link
Contributor

m2rads commented Dec 27, 2024

@gladyshcodes sorry we made some more changes. Please resolve the conflicts again and I will test soon. Thank you :)

@gladyshcodes
Copy link
Author

@gladyshcodes sorry we made some more changes. Please resolve the conflicts again and I will test soon. Thank you :)

Hi there @m2rads. Those conflicts actually do not interfere with functionality added. I resolved them 👍 .

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.

3 participants