microsoft / playwright-dotnet

.NET version of the Playwright testing and automation library.
https://playwright.dev/dotnet/
MIT License
2.47k stars 235 forks source link

Install in VS2022 ? Help please :) #2472

Closed CyrilIDsoft closed 1 year ago

CyrilIDsoft commented 1 year ago

Hello Playwright noob so be kind. 🙂

I installed Microsoft.Playwright 1.30.0 + Microsoft.Playwright.MSTest 1.30.0 + Microsoft.Playwright.TestAdapter 1.30.0 in my Visual Studio 2022. Trying to run samples found (https://playwright.dev/) I have a compiling error on this sentence :

using var playwright = await Playwright.CreateAsync();

Any idea on what I may have missed ?

Thanks.

mxschmitt commented 1 year ago

Whats the error which you are getting?

CyrilIDsoft commented 1 year ago

No definition for CreateAsync in IPlaywright.

mxschmitt commented 1 year ago

Did you add a using for using Microsoft.Playwright;?

CyrilIDsoft commented 1 year ago

Yes I did.

using System.Threading.Tasks; using Microsoft.Playwright; using Microsoft.Playwright.MSTest; using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace CRMImmo.Tests.Playwright { [TestClass] public class UnitTest5 : PageTest { [TestMethod] public async Task MyTest() { using var playwright = await Playwright.CreateAsync(); var firefox = playwright.Firefox; var browser = await firefox.LaunchAsync(new BrowserTypeLaunchOptions { Headless = false }); var page = await browser.NewPageAsync(); await page.GotoAsync("https://www.bing.com"); await browser.CloseAsync(); } } }

CyrilIDsoft commented 1 year ago

I tried in Visual Studio Code and it works ... What's the matter ? ClassLibrary and Net7.0 in both.

mxschmitt commented 1 year ago

Super weird! Maybe the dependencies were not restored in VS. Have you tried following the official intro? https://playwright.dev/dotnet/docs/intro

Might also be a .NET 7 issue, since I've never tested in it, but since it works in VSCode for you, that seems not very reasonable.

CyrilIDsoft commented 1 year ago

Well in VS2022 I used the NuGet package manager to install Microsoft.Playwright.MSTest. I also desinstall and reinstall this package to test, without improvment.

mxschmitt commented 1 year ago

This is most likely an issue on your machine, with the way VS is installed etc. since you are the first person reporting it. Since we are unfortunately not able to reproduce it, we have to close it for now as part of the triaging process. Feel free to put research / investigation notes down below to help further users.

I'd recommend to re-install VS 2022.

ArpitaJanaAnthology commented 1 year ago

I see the same issue , Playwright does not even show up in the list of extensions that Visual Studio 2022 offers for the IDE

Screenshot 2023-10-17 165556
mxschmitt commented 1 year ago

I see the same issue , Playwright does not even show up in the list of extensions that Visual Studio 2022 offers for the IDE Screenshot 2023-10-17 165556

This is expected, there is no Visual Studio Playwright extension, only for Visual Studio Code and Node.js: https://playwright.dev/docs/getting-started-vscode

eggman211 commented 3 months ago

I know this post is an old and closed but I just had this issue. Found out it was because Playwright was referencing PlaywrightTest and not Microsoft.Playwright.Playwright

image