News for hackers. Stuff that matters.
Re:Playwright for .NET is now stable by philliphaydon on Thursday June 10, 2021 @06:33AM (#27459098)
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 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...

Re:Playwright for .NET is now stable by pjerem on Thursday June 10, 2021 @08:25AM (#27459819)
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.

Re:Playwright for .NET is now stable by polskibus on Thursday June 10, 2021 @11:54AM (#27462147)
Is it less flaky than Cypress? We're constantly running into Cypress bugs, when we find a workaround for one, two more show up.
Re:Playwright for .NET is now stable by lucasmullens on Thursday June 10, 2021 @12:23PM (#27462468)
In my experience yes. We ran into a Cypress bug that was bad enough that we just switched to Playwright and it works great.
Re:Playwright for .NET is now stable by starik36 on Thursday June 10, 2021 @02:52PM (#27464158)
As others mentioned, the same guy is involved in Playwright. One thing I wanted to mention is that he is extremely responsive. I posted several issues a number of years ago and he fixed them pronto. And even dug into the underlying Chromium issues.
Re:Playwright for .NET is now stable by philliphaydon on Thursday June 10, 2021 @11:19PM (#27468910)
Yeah he’s good. Helped me with an issue I had. The particular issue I have is actually in puppeteer. But I need a .net library so that’s why I mentioned it.

Not trying to downplay his project cos it’s actually really good.

Re:Playwright for .NET is now stable by leaveyou on Thursday June 10, 2021 @10:05AM (#27460920)
you need to put this before the Screenshot ?

await page.WaitForLoadStateAsync(LoadState.NetworkIdle);

Re:Playwright for .NET is now stable by philliphaydon on Thursday June 10, 2021 @11:21AM (#27461759)
I’ll give it a go thanks.
Re:Playwright for .NET is now stable by tren on Thursday June 10, 2021 @07:15AM (#27459350)
Same guy does playwright sharp, he should really have more supporters
Re:Playwright for .NET is now stable by philliphaydon on Thursday June 10, 2021 @07:37AM (#27459492)
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 by 9wzYQbTYsAIc on Thursday June 10, 2021 @11:46AM (#27462060)
.NET Foundation is where a lot of the contribution back to the community happens, I believe.
Re:Playwright for .NET is now stable by MauroIksem on Thursday June 10, 2021 @06:38AM (#27459123)
Have you tried selinium and phantomjs headless ? I was using that a few years ago and it worked very well.
Re:Playwright for .NET is now stable by lloydatkinson on Thursday June 10, 2021 @07:52AM (#27459576)
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 by tester34 on Thursday June 10, 2021 @08:07AM (#27459684)
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 by lbriner on Thursday June 10, 2021 @07:23AM (#27459402)
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 by Rapzid on Thursday June 10, 2021 @11:01AM (#27461540)
I have built selenium test harnesses using webdriverjs and Jest as the runner at my two most recent jobs. Been using the webdriverjs 4 alpha which has/had been in progress forever. I've never had a flakey-ness issue that was the fault of selenium.

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.

Re:Playwright for .NET is now stable by philliphaydon on Thursday June 10, 2021 @06:45AM (#27459163)
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.
Re:Playwright for .NET is now stable by caseymarquis on Thursday June 10, 2021 @08:08AM (#27459697)
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 by philliphaydon on Thursday June 10, 2021 @09:19AM (#27460381)
I can run puppeteer in a Lambda fine, it's just that when you navigate to a webpage with a background loaded as a css image it doesn't wait for that to load before taking the screen grab. :(

https://github.com/puppeteer/puppeteer/issues/4046

Re:Playwright for .NET is now stable by hbcondo714 on Thursday June 10, 2021 @04:45PM (#27465568)
Could be the same reason why this doesn't work as an Azure Function either:

https://github.com/microsoft/playwright-dotnet/issues/1076