This reverts commit 15add13a6a.
This commit is contained in:
parent
4b8a85e69d
commit
59c32bf2c6
|
|
@ -100,7 +100,7 @@ public class TestGitHubAPI : PlaywrightTest
|
||||||
|
|
||||||
private IAPIRequestContext Request = null;
|
private IAPIRequestContext Request = null;
|
||||||
|
|
||||||
[PlaywrightTest]
|
[Test]
|
||||||
public async Task ShouldCreateBugReport()
|
public async Task ShouldCreateBugReport()
|
||||||
{
|
{
|
||||||
var data = new Dictionary<string, string>();
|
var data = new Dictionary<string, string>();
|
||||||
|
|
@ -127,7 +127,7 @@ public class TestGitHubAPI : PlaywrightTest
|
||||||
Assert.AreEqual("Bug description", issue?.GetProperty("body").GetString());
|
Assert.AreEqual("Bug description", issue?.GetProperty("body").GetString());
|
||||||
}
|
}
|
||||||
|
|
||||||
[PlaywrightTest]
|
[Test]
|
||||||
public async Task ShouldCreateFeatureRequests()
|
public async Task ShouldCreateFeatureRequests()
|
||||||
{
|
{
|
||||||
var data = new Dictionary<string, string>();
|
var data = new Dictionary<string, string>();
|
||||||
|
|
@ -224,7 +224,7 @@ public class TestGitHubAPI : PlaywrightTest
|
||||||
|
|
||||||
private IAPIRequestContext Request = null;
|
private IAPIRequestContext Request = null;
|
||||||
|
|
||||||
[PlaywrightTest]
|
[Test]
|
||||||
public async Task ShouldCreateBugReport()
|
public async Task ShouldCreateBugReport()
|
||||||
{
|
{
|
||||||
var data = new Dictionary<string, string>();
|
var data = new Dictionary<string, string>();
|
||||||
|
|
@ -251,7 +251,7 @@ public class TestGitHubAPI : PlaywrightTest
|
||||||
Assert.AreEqual("Bug description", issue?.GetProperty("body").GetString());
|
Assert.AreEqual("Bug description", issue?.GetProperty("body").GetString());
|
||||||
}
|
}
|
||||||
|
|
||||||
[PlaywrightTest]
|
[Test]
|
||||||
public async Task ShouldCreateFeatureRequests()
|
public async Task ShouldCreateFeatureRequests()
|
||||||
{
|
{
|
||||||
var data = new Dictionary<string, string>();
|
var data = new Dictionary<string, string>();
|
||||||
|
|
@ -337,7 +337,7 @@ The following test creates a new issue via API and then navigates to the list of
|
||||||
project to check that it appears at the top of the list. The check is performed using [LocatorAssertions].
|
project to check that it appears at the top of the list. The check is performed using [LocatorAssertions].
|
||||||
|
|
||||||
```csharp
|
```csharp
|
||||||
[PlaywrightTest]
|
[Test]
|
||||||
public async Task LastCreatedIssueShouldBeFirstInTheList()
|
public async Task LastCreatedIssueShouldBeFirstInTheList()
|
||||||
{
|
{
|
||||||
var data = new Dictionary<string, string>();
|
var data = new Dictionary<string, string>();
|
||||||
|
|
@ -360,7 +360,7 @@ The following test creates a new issue via user interface in the browser and the
|
||||||
it was created:
|
it was created:
|
||||||
|
|
||||||
```csharp
|
```csharp
|
||||||
[PlaywrightTest]
|
[Test]
|
||||||
public async Task LastCreatedIssueShouldBeOnTheServer()
|
public async Task LastCreatedIssueShouldBeOnTheServer()
|
||||||
{
|
{
|
||||||
await Page.GotoAsync("https://github.com/" + USER + "/" + REPO + "/issues");
|
await Page.GotoAsync("https://github.com/" + USER + "/" + REPO + "/issues");
|
||||||
|
|
|
||||||
|
|
@ -57,7 +57,7 @@ namespace PlaywrightTests;
|
||||||
[TestFixture]
|
[TestFixture]
|
||||||
public class ExampleTests : PageTest
|
public class ExampleTests : PageTest
|
||||||
{
|
{
|
||||||
[PlaywrightTest]
|
[Test]
|
||||||
public async Task StatusBecomesSubmitted()
|
public async Task StatusBecomesSubmitted()
|
||||||
{
|
{
|
||||||
// ..
|
// ..
|
||||||
|
|
|
||||||
|
|
@ -59,7 +59,7 @@ namespace PlaywrightTests;
|
||||||
[TestFixture]
|
[TestFixture]
|
||||||
public class ExampleTests : PageTest
|
public class ExampleTests : PageTest
|
||||||
{
|
{
|
||||||
[PlaywrightTest]
|
[Test]
|
||||||
public async Task NavigatetoLoginPage()
|
public async Task NavigatetoLoginPage()
|
||||||
{
|
{
|
||||||
// ..
|
// ..
|
||||||
|
|
|
||||||
|
|
@ -58,7 +58,7 @@ namespace PlaywrightTests;
|
||||||
[TestFixture]
|
[TestFixture]
|
||||||
public class ExampleTests : PageTest
|
public class ExampleTests : PageTest
|
||||||
{
|
{
|
||||||
[PlaywrightTest]
|
[Test]
|
||||||
public async Task StatusBecomesSubmitted()
|
public async Task StatusBecomesSubmitted()
|
||||||
{
|
{
|
||||||
await Page.Locator("#submit-button").ClickAsync();
|
await Page.Locator("#submit-button").ClickAsync();
|
||||||
|
|
|
||||||
|
|
@ -101,7 +101,7 @@ namespace PlaywrightTests;
|
||||||
[TestFixture]
|
[TestFixture]
|
||||||
public class Tests : PageTest
|
public class Tests : PageTest
|
||||||
{
|
{
|
||||||
[PlaywrightTest]
|
[Test]
|
||||||
public async Task HomepageHasPlaywrightInTitleAndGetStartedLinkLinkingtoTheIntroPage()
|
public async Task HomepageHasPlaywrightInTitleAndGetStartedLinkLinkingtoTheIntroPage()
|
||||||
{
|
{
|
||||||
await Page.GotoAsync("https://playwright.dev");
|
await Page.GotoAsync("https://playwright.dev");
|
||||||
|
|
@ -136,7 +136,7 @@ namespace PlaywrightTests;
|
||||||
[TestClass]
|
[TestClass]
|
||||||
public class UnitTest1 : PageTest
|
public class UnitTest1 : PageTest
|
||||||
{
|
{
|
||||||
[PlaywrightTestMethod]
|
[TestMethod]
|
||||||
public async Task HomepageHasPlaywrightInTitleAndGetStartedLinkLinkingtoTheIntroPage()
|
public async Task HomepageHasPlaywrightInTitleAndGetStartedLinkLinkingtoTheIntroPage()
|
||||||
{
|
{
|
||||||
await Page.GotoAsync("https://playwright.dev");
|
await Page.GotoAsync("https://playwright.dev");
|
||||||
|
|
|
||||||
|
|
@ -295,7 +295,7 @@ namespace PlaywrightTests;
|
||||||
[TestFixture]
|
[TestFixture]
|
||||||
public class ExampleTests : PageTest
|
public class ExampleTests : PageTest
|
||||||
{
|
{
|
||||||
[PlaywrightTest]
|
[Test]
|
||||||
public async Task StatusBecomesSubmitted()
|
public async Task StatusBecomesSubmitted()
|
||||||
{
|
{
|
||||||
await Expect(Page.Locator(".status")).ToHaveTextAsync("Submitted");
|
await Expect(Page.Locator(".status")).ToHaveTextAsync("Submitted");
|
||||||
|
|
|
||||||
|
|
@ -44,14 +44,14 @@ namespace PlaywrightTests;
|
||||||
[TestFixture]
|
[TestFixture]
|
||||||
public class MyTest : PageTest
|
public class MyTest : PageTest
|
||||||
{
|
{
|
||||||
[PlaywrightTest]
|
[Test]
|
||||||
public async Task ShouldHaveTheCorrectSlogan()
|
public async Task ShouldHaveTheCorrectSlogan()
|
||||||
{
|
{
|
||||||
await Page.GotoAsync("https://playwright.dev");
|
await Page.GotoAsync("https://playwright.dev");
|
||||||
await Expect(Page.Locator("text=enables reliable end-to-end testing for modern web apps")).ToBeVisibleAsync();
|
await Expect(Page.Locator("text=enables reliable end-to-end testing for modern web apps")).ToBeVisibleAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
[PlaywrightTest]
|
[Test]
|
||||||
public async Task ShouldHaveTheCorrectTitle()
|
public async Task ShouldHaveTheCorrectTitle()
|
||||||
{
|
{
|
||||||
await Page.GotoAsync("https://playwright.dev");
|
await Page.GotoAsync("https://playwright.dev");
|
||||||
|
|
@ -125,7 +125,7 @@ namespace PlaywrightTests;
|
||||||
[TestFixture]
|
[TestFixture]
|
||||||
public class MyTest : PageTest
|
public class MyTest : PageTest
|
||||||
{
|
{
|
||||||
[PlaywrightTest]
|
[Test]
|
||||||
public async Task TestWithCustomContextOptions()
|
public async Task TestWithCustomContextOptions()
|
||||||
{
|
{
|
||||||
// The following Page (and BrowserContext) instance has the custom colorScheme, viewport and baseURL set:
|
// The following Page (and BrowserContext) instance has the custom colorScheme, viewport and baseURL set:
|
||||||
|
|
@ -217,10 +217,6 @@ There are a few base classes available to you in `Microsoft.Playwright.NUnit` na
|
||||||
|BrowserTest |Each test will get a browser and can create as many contexts as it likes. Each test is responsible for cleaning up all the contexts it created.|
|
|BrowserTest |Each test will get a browser and can create as many contexts as it likes. Each test is responsible for cleaning up all the contexts it created.|
|
||||||
|PlaywrightTest|This gives each test a Playwright object so that the test could start and stop as many browsers as it likes.|
|
|PlaywrightTest|This gives each test a Playwright object so that the test could start and stop as many browsers as it likes.|
|
||||||
|
|
||||||
### 'No test is available'
|
|
||||||
|
|
||||||
You need to add `[TestFixture]` to your test class. NUnit does not discover tests without it, if the `TestAttribute` comes from a different assembly.
|
|
||||||
|
|
||||||
## MSTest
|
## MSTest
|
||||||
|
|
||||||
Playwright provides base classes to write tests with MSTest via the [`Microsoft.Playwright.MSTest`](https://www.nuget.org/packages/Microsoft.Playwright.MSTest) package.
|
Playwright provides base classes to write tests with MSTest via the [`Microsoft.Playwright.MSTest`](https://www.nuget.org/packages/Microsoft.Playwright.MSTest) package.
|
||||||
|
|
@ -250,14 +246,14 @@ namespace PlaywrightTests;
|
||||||
[TestClass]
|
[TestClass]
|
||||||
public class UnitTest1: PageTest
|
public class UnitTest1: PageTest
|
||||||
{
|
{
|
||||||
[PlaywrightTestMethod]
|
[TestMethod]
|
||||||
public async Task ShouldHaveTheCorrectSlogan()
|
public async Task ShouldHaveTheCorrectSlogan()
|
||||||
{
|
{
|
||||||
await Page.GotoAsync("https://playwright.dev");
|
await Page.GotoAsync("https://playwright.dev");
|
||||||
await Expect(Page.Locator("text=enables reliable end-to-end testing for modern web apps")).ToBeVisibleAsync();
|
await Expect(Page.Locator("text=enables reliable end-to-end testing for modern web apps")).ToBeVisibleAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
[PlaywrightTestMethod]
|
[TestMethod]
|
||||||
public async Task ShouldHaveTheCorrectTitle()
|
public async Task ShouldHaveTheCorrectTitle()
|
||||||
{
|
{
|
||||||
await Page.GotoAsync("https://playwright.dev");
|
await Page.GotoAsync("https://playwright.dev");
|
||||||
|
|
@ -335,7 +331,7 @@ namespace PlaywrightTests;
|
||||||
[TestClass]
|
[TestClass]
|
||||||
public class UnitTest1 : PageTest
|
public class UnitTest1 : PageTest
|
||||||
{
|
{
|
||||||
[PlaywrightTestMethod]
|
[TestMethod]
|
||||||
public async Task TestWithCustomContextOptions()
|
public async Task TestWithCustomContextOptions()
|
||||||
{
|
{
|
||||||
// The following Page (and BrowserContext) instance has the custom colorScheme, viewport and baseURL set:
|
// The following Page (and BrowserContext) instance has the custom colorScheme, viewport and baseURL set:
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@ namespace PlaywrightTests;
|
||||||
[TestFixture]
|
[TestFixture]
|
||||||
public class Tests : PageTest
|
public class Tests : PageTest
|
||||||
{
|
{
|
||||||
[PlaywrightTest]
|
[Test]
|
||||||
public async Task HomepageHasPlaywrightInTitleAndGetStartedLinkLinkingtoTheIntroPage()
|
public async Task HomepageHasPlaywrightInTitleAndGetStartedLinkLinkingtoTheIntroPage()
|
||||||
{
|
{
|
||||||
await Page.GotoAsync("https://playwright.dev");
|
await Page.GotoAsync("https://playwright.dev");
|
||||||
|
|
@ -62,7 +62,7 @@ namespace PlaywrightTests;
|
||||||
[TestClass]
|
[TestClass]
|
||||||
public class UnitTest1 : PageTest
|
public class UnitTest1 : PageTest
|
||||||
{
|
{
|
||||||
[PlaywrightTestMethod]
|
[TestMethod]
|
||||||
public async Task HomepageHasPlaywrightInTitleAndGetStartedLinkLinkingtoTheIntroPage()
|
public async Task HomepageHasPlaywrightInTitleAndGetStartedLinkLinkingtoTheIntroPage()
|
||||||
{
|
{
|
||||||
await Page.GotoAsync("https://playwright.dev");
|
await Page.GotoAsync("https://playwright.dev");
|
||||||
|
|
@ -140,7 +140,7 @@ namespace PlaywrightTests;
|
||||||
[TestFixture]
|
[TestFixture]
|
||||||
public class Tests : PageTest
|
public class Tests : PageTest
|
||||||
{
|
{
|
||||||
[PlaywrightTest]
|
[Test]
|
||||||
public async Task BasicTest()
|
public async Task BasicTest()
|
||||||
{
|
{
|
||||||
await Page.GotoAsync("https://playwright.dev");
|
await Page.GotoAsync("https://playwright.dev");
|
||||||
|
|
@ -159,7 +159,7 @@ namespace PlaywrightTests;
|
||||||
[TestClass]
|
[TestClass]
|
||||||
public class UnitTest1 : PageTest
|
public class UnitTest1 : PageTest
|
||||||
{
|
{
|
||||||
[PlaywrightTestMethod]
|
[TestMethod]
|
||||||
public async Task BasicTest()
|
public async Task BasicTest()
|
||||||
{
|
{
|
||||||
await Page.GotoAsync("https://playwright.dev");
|
await Page.GotoAsync("https://playwright.dev");
|
||||||
|
|
@ -195,7 +195,7 @@ namespace PlaywrightTests;
|
||||||
[TestFixture]
|
[TestFixture]
|
||||||
public class Tests : PageTest
|
public class Tests : PageTest
|
||||||
{
|
{
|
||||||
[PlaywrightTest]
|
[Test]
|
||||||
public async Task MainNavigation()
|
public async Task MainNavigation()
|
||||||
{
|
{
|
||||||
// Assertions use the expect API.
|
// Assertions use the expect API.
|
||||||
|
|
@ -221,7 +221,7 @@ namespace PlaywrightTests;
|
||||||
[TestClass]
|
[TestClass]
|
||||||
public class UnitTest1 : PageTest
|
public class UnitTest1 : PageTest
|
||||||
{
|
{
|
||||||
[PlaywrightTestMethod]
|
[TestMethod]
|
||||||
public async Task MainNavigation()
|
public async Task MainNavigation()
|
||||||
{
|
{
|
||||||
// Assertions use the expect API.
|
// Assertions use the expect API.
|
||||||
|
|
|
||||||
|
|
@ -207,7 +207,7 @@ export class CSharpLanguageGenerator implements LanguageGenerator {
|
||||||
}`);
|
}`);
|
||||||
formatter.newLine();
|
formatter.newLine();
|
||||||
}
|
}
|
||||||
formatter.add(` [${this._mode === 'nunit' ? 'PlaywrightTest' : 'PlaywrightTestMethod'}]
|
formatter.add(` [${this._mode === 'nunit' ? 'Test' : 'TestMethod'}]
|
||||||
public async Task MyTest()
|
public async Task MyTest()
|
||||||
{`);
|
{`);
|
||||||
return formatter.format();
|
return formatter.format();
|
||||||
|
|
|
||||||
|
|
@ -232,7 +232,7 @@ public class Tests : PageTest
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
[PlaywrightTestMethod]
|
[TestMethod]
|
||||||
public async Task MyTest()
|
public async Task MyTest()
|
||||||
{
|
{
|
||||||
// Go to ${emptyHTML}
|
// Go to ${emptyHTML}
|
||||||
|
|
@ -261,7 +261,7 @@ public class Tests : PageTest
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
[PlaywrightTest]
|
[Test]
|
||||||
public async Task MyTest()
|
public async Task MyTest()
|
||||||
{
|
{
|
||||||
// Go to ${emptyHTML}
|
// Go to ${emptyHTML}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue