Live data from Hacker News

Playwright for .NET is now stable

github.com

11–20 of 66 posts

Re: Playwright for .NET is now stable

#11

Oh, I didn't know this existed. Definitely going to try this. I'm currently using Puppeteer Sharp ( https://github.com/hardkoded/puppeteer-sharp ) and something like: > 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 bef…

Same guy does playwright sharp, he should really have more supporters

Re: Playwright for .NET is now stable

#12

Oh, I didn't know this existed. Definitely going to try this. I'm currently using Puppeteer Sharp ( https://github.com/hardkoded/puppeteer-sharp ) and something like: > 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 bef…

Have you tried selinium and phantomjs headless ? I was using that a few years ago and it worked very well.

Selenium is still very flaky. We have almost zero problems with playwright except where we made the mistake. On the other hand, we get all sorts of weird glitches with Selenium and often have to re-run tests for them to pass with no other changes.

Re: Playwright for .NET is now stable

#13
post #8

Does anyone know if this can be used for effective performance testing? It’s not clear from the Playwright documentation, but I know Selenium (a similar tool) does not recommend performance testing.

It depends exactly what you mean by performance testing. The problem with a lot of UI tests is that you might need to add artificial slowness to make the tests more likely to pass. Even waiting for something to appear can take longer than it would in a browser. If you want a basic number to see regression, sure you can use this.

If you want to get a sense of how far the system can scale, you would be better with a proper performance testing framework that can run multiple threads, ideally from multiple locations (to avoid any network limits) and built-in support for accurate timing. Apache Bench is pretty common and relatively easy to setup and use. There is also JMeter and even SaaS services to do it for you.

Re: Playwright for .NET is now stable

#14
post #11

Oh, I didn't know this existed. Definitely going to try this. I'm currently using Puppeteer Sharp ( https://github.com/hardkoded/puppeteer-sharp ) and something like: > 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 bef…

Same guy does playwright sharp, he should really have more supporters

OH WOW! I had no idea! Yeah he does deserve more support. I still donno why MS can't contribute to projects directly. But I'm happy there's another possible solution to my problem.

Re: Playwright for .NET is now stable

#15
post #3

really curious about peoples experience with this compared to things like Cypress.

I've had some issues with Cypress selectors randomly failing to find matching elements, even though they are clearly present. Like if I run the same script 10 times it goes through ~7 times. I wanted to try Playwright for another application to avoid such issues. And then I was very surprised to get almost the exact same issues with Playwright. Running against a different application with different test cases. Has an…

Got less once I started using dom-testing-library :)

Re: Playwright for .NET is now stable

#16

Oh, I didn't know this existed. Definitely going to try this. I'm currently using Puppeteer Sharp ( https://github.com/hardkoded/puppeteer-sharp ) and something like: > 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 bef…

Have you tried selinium and phantomjs headless ? I was using that a few years ago and it worked very well.

PhtantomJS was abandoned officially a long time ago because of all these new and better tools.

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.

Re: Playwright for .NET is now stable

#17
post #3

really curious about peoples experience with this compared to things like Cypress.

I've had some issues with Cypress selectors randomly failing to find matching elements, even though they are clearly present. Like if I run the same script 10 times it goes through ~7 times. I wanted to try Playwright for another application to avoid such issues. And then I was very surprised to get almost the exact same issues with Playwright. Running against a different application with different test cases. Has an…

Were you able to use the DOM snapshots to debug why the selectors did not resolve? Would love to know more.

Re: Playwright for .NET is now stable

#18

Earlier quoted context omitted.

Have you tried selinium and phantomjs headless ? I was using that a few years ago and it worked very well.

PhtantomJS was abandoned officially a long time ago because of all these new and better tools. 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 pro…

it reflects my experience

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

Re: Playwright for .NET is now stable

#19

Earlier quoted context omitted.

Have you tried selinium and phantomjs headless ? I was using that a few years ago and it worked very well.

I couldn't get it working in an AWS Lambda. May work now but I haven't had time this year to re-visit that project.

Assuming those run a container? With puppeteer on Heroku, I had to install chrome as part of the container, then pass it no-sandbox on startup. I'd guess you'd need something similar with chrome (I'm on mobile, so excuse the formatting):

  #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"
                        },
                        });

Re: Playwright for .NET is now stable

#20

Oh, I didn't know this existed. Definitely going to try this. I'm currently using Puppeteer Sharp ( https://github.com/hardkoded/puppeteer-sharp ) and something like: > 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 bef…

I'm using Playwright right now, migrating horrendous Selenium tests at work and it's a real breeze of fresh air. It just works, it comes battery included with superb debugging tools (step by step execution directly in the browser, trace dumping for further analysis, reliable interactions recorder with pretty decent code generation ...).

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.

Post reply on HN