It's an amazing piece of software for a domain that was kept on the side of the road for years.
If you already tried Cypress, then it's Cypress but with true multiple browser support, available in 4 languages, without the bloat and a cleaner and more idiomatic API.
Not trying to downplay his project cos it’s actually really good.
await page.WaitForLoadStateAsync(LoadState.NetworkIdle);
Selenium is a source of constant bugs and misery - it's truly a waste of time maintaining its usage in a codebase because randomly sometimes tests fail. The C# wrapper for it is even worse, as it does not follow the idioms of C# and is a straight 1:1 port from the Java version. Highlights include getting exceptions from properties when you hover over them during debug in Visual Studio.
rerunning tests because always a few of them fail on first run
but I noticed that the biggest reason was that often my browser was a little ahead when it comes to version than engine, and after updating both of them the situation was a kinda better.
Anyway I don't recommend Selenium, it wastes too much time
I don't understand why it doesn't get more love and support. You can build higher level testing frameworks right on top of it.
#Install Chrome for Puppeteer:
RUN curl -LO https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
RUN apt-get update -y
RUN apt-get install -y ./google-chrome-stable_current_amd64.deb
RUN rm google-chrome-stable_current_amd64.deb
ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true
ENV PUPPETEER_EXECUTABLE_PATH=/usr/bin/google-chrome-stable
browser = await Puppeteer.LaunchAsync(
new LaunchOptions {
//If we're debugging, then open actual chrome:
Headless = !Debugger.IsAttached,
Args = new string[] {
"--no-sandbox"
},
});
> await page.GotoAsync("https://playwright.dev/dotnet");
> await page.ScreenshotAsync(new PageScreenshotOptions() { Path = "screenshot.png" });
Is broken, if you have background images in CSS the screenshot happens after Page Load is completed but before all CSS images are loaded so you end up not getting backgrounds in the screenshot. The only solution is to try add a delay before taking the screen grab, and it there's any sort of latency then the delay could result in not getting a good screenshot...