Skip to content

Commit c9974ad

Browse files
committed
Playwright C# Dotnet Framework
1 parent 7b89e55 commit c9974ad

13 files changed

+958
-0
lines changed

Playwright-CSharpDotNet/.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
/.vs
2+
/obj
3+
/bin
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
using Microsoft.Playwright;
2+
using System;
3+
using System.Collections.Generic;
4+
using System.Linq;
5+
using System.Text;
6+
using System.Threading.Tasks;
7+
8+
namespace PlaywrightCSharpDotNet.Pages
9+
{
10+
public class GooglePlaylistPage
11+
{
12+
private readonly IPage _page;
13+
14+
public GooglePlaylistPage(IPage page)
15+
{
16+
_page = page;
17+
}
18+
19+
private ILocator VideoLink => _page.Locator("#container > #thumbnail");
20+
21+
public async Task ClickOnVideo()
22+
{
23+
await VideoLink.Nth(0).ClickAsync();
24+
}
25+
}
26+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
using Microsoft.Playwright;
2+
using System;
3+
using System.Collections.Generic;
4+
using System.Linq;
5+
using System.Text;
6+
using System.Threading.Tasks;
7+
8+
namespace PlaywrightCSharpDotNet.Pages
9+
{
10+
public class GoogleResultPage
11+
{
12+
private readonly IPage _page;
13+
14+
public GoogleResultPage(IPage page)
15+
{
16+
_page = page;
17+
}
18+
19+
private ILocator PlaylistLink => _page.GetByRole(AriaRole.Link, new() { Name = "Playwright by Testers Talk" });
20+
21+
public async Task ClickOnPlaylistLink()
22+
{
23+
await PlaylistLink.Nth(0).ClickAsync();
24+
}
25+
26+
public async Task ClickOnPlaylistLink(string playlist)
27+
{
28+
var playlistLink = _page.GetByRole(AriaRole.Link, new() { Name = playlist });
29+
await playlistLink.Nth(0).ClickAsync();
30+
}
31+
}
32+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
using Microsoft.Playwright;
2+
using System;
3+
using System.Collections.Generic;
4+
using System.Linq;
5+
using System.Text;
6+
using System.Threading.Tasks;
7+
8+
namespace PlaywrightCSharpDotNet.Pages
9+
{
10+
public class GoogleSearchPage
11+
{
12+
private readonly IPage _page;
13+
14+
public GoogleSearchPage(IPage page)
15+
{
16+
_page = page;
17+
}
18+
19+
private ILocator SearchTextbox => _page.Locator("#APjFqb");
20+
21+
public async Task NavigateToURL()
22+
{
23+
await this._page.GotoAsync("https://www.google.com");
24+
}
25+
26+
public async Task Search(string keyword)
27+
{
28+
await SearchTextbox.ClickAsync();
29+
await SearchTextbox.FillAsync(keyword);
30+
await SearchTextbox.PressAsync("Enter");
31+
//await _page.Keyboard.PressAsync("Enter");
32+
}
33+
}
34+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<TargetFramework>net6.0</TargetFramework>
5+
<Nullable>enable</Nullable>
6+
7+
<IsPackable>false</IsPackable>
8+
</PropertyGroup>
9+
10+
<ItemGroup>
11+
<PackageReference Include="ExtentReports" Version="4.1.0" />
12+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.11.0" />
13+
<PackageReference Include="Microsoft.Playwright" Version="1.47.0" />
14+
<PackageReference Include="Microsoft.Playwright.NUnit" Version="1.47.0" />
15+
<PackageReference Include="NUnit" Version="3.13.2" />
16+
<PackageReference Include="NUnit3TestAdapter" Version="4.0.0" />
17+
<PackageReference Include="coverlet.collector" Version="3.1.0" />
18+
</ItemGroup>
19+
20+
<ItemGroup>
21+
<Folder Include="TestData\" />
22+
<Folder Include="TestReport\" />
23+
</ItemGroup>
24+
25+
</Project>
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 17
4+
VisualStudioVersion = 17.0.32126.317
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PlaywrightCSharpDotNet", "PlaywrightCSharpDotNet.csproj", "{3C8C87D5-5C95-48C1-AB39-28C9BBBA00D6}"
7+
EndProject
8+
Global
9+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+
Debug|Any CPU = Debug|Any CPU
11+
Release|Any CPU = Release|Any CPU
12+
EndGlobalSection
13+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
14+
{3C8C87D5-5C95-48C1-AB39-28C9BBBA00D6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{3C8C87D5-5C95-48C1-AB39-28C9BBBA00D6}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{3C8C87D5-5C95-48C1-AB39-28C9BBBA00D6}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{3C8C87D5-5C95-48C1-AB39-28C9BBBA00D6}.Release|Any CPU.Build.0 = Release|Any CPU
18+
EndGlobalSection
19+
GlobalSection(SolutionProperties) = preSolution
20+
HideSolutionNode = FALSE
21+
EndGlobalSection
22+
GlobalSection(ExtensibilityGlobals) = postSolution
23+
SolutionGuid = {5CABBE8F-E6EF-4846-B40C-08767980EA8C}
24+
EndGlobalSection
25+
EndGlobal
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
using NUnit.Framework;
2+
3+
[assembly: Parallelizable(ParallelScope.All)]
4+
[assembly: LevelOfParallelism(1)] // Adjust the number based on your needs

0 commit comments

Comments
 (0)