-
Notifications
You must be signed in to change notification settings - Fork 10k
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
Run Selenium tests on Playwright via an adapter [experiment] #45284
Conversation
|
||
<ItemGroup> | ||
<Compile Include="..\E2ETest\Infrastructure\ServerFixtures\*.cs" LinkBase="Infrastructure\ServerFixtures" /> | ||
<Compile Include="..\E2ETest\Tests\StandaloneAppTest.cs" LinkBase="Tests" /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here you can see we're actually using the real StandaloneAppTest.cs
test fixture, and it now does run and succeed on Playwright.
public void Dispose() | ||
{ | ||
// Make the tests run faster by navigating back to the home page when we are done | ||
// If we don't, then the next test will reload the whole page before it starts | ||
Browser.Exists(By.LinkText("Home")).Click(); | ||
} | ||
#endif |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's probably possible to make this work without being #if
-ed out. I only disabled it because of an execution ordering issue (it was tearing down the Playwright browser first, then calling this, which threw because it could no longer talk to the browser).
…t now builds (and all that builds passes)
Can you share more on this? Would you say most of the difficulty came from complexity in our repo or with Playwright itself?
Agree with this! Although I think we can alleviate this a little bit by putting all the tests that use the adapter in a separate directory or otherwise labeling them in a way that says "this isn't really selenium, it just looks like it". |
It's been a few months so I don't have a fresh memory of it, but some of the issues were:
|
Looks like this PR hasn't been active for some time and the codebase could have been changed in the meantime. |
I'm closing this now since it's been here for months and we don't have any immediate plan to take action on it. It could be reopened if we change our minds. @mkArtakMSFT |
This is just an experiment to see what the team thinks.
Premise
Even though the Selenium-based E2E tests have been very reliable for more than a year now, we still incur costs from them:
But we can't just casually rewrite all these tests in Playwright. For one thing, there are a lot of them and this would be many weeks (maybe months) of effort, but also there's a huge amount of subtle thought behind they way they are constructed. For example they are testing things like which UI updates should occur synchronously vs asynchronously, and when certain updates should not occur. A casual rewrite is likely to end up producing tests that pass but don't capture all the behaviors we captured before, and we lose vital coverage.
An adapter
If the problem isn't the existing tests themselves, but rather is the having to depend on Selenium's underlying technology stack (and keep updating it, etc.), then what about if we had an adapter so the existing tests could run on Playwright?
This PR is a quick experiment to see how practical that might be. I've set up a new test project and pulled in an existing test fixture (
StandaloneAppTest.cs
) via shared-source. To make it build, I've made a set of APIs equivalent to the shape of Selenium's APIs, and their implementation uses Playwright. This does work and the existing test code from that fixture passes. I did have to skip the fixture'sDispose
method but otherwise the test code is unchanged.If we were to do this fully, the test coverage should be unchanged, and the payoff would be:
There are certainly drawbacks though:
OpenQA.Selenium
) but it actually doesn't.someTask.Result
or callingtask.Wait()
). Obviously that's horrible, but what else can an adapter like this do?Microsoft.AspNetCore.BrowserTesting
does, or what we've done to make things run in Helix).Let's come up with a plan
I'm OK with discarding this approach if people aren't into it. If we were going to do something like this, we would need to make a plan for finishing the work, i.e., switching over each of the test fixture classes (possibly incrementally) and expanding the adapter API surface as we go to make it all still build and pass.