File tree 10 files changed +121
-8
lines changed
10 files changed +121
-8
lines changed Original file line number Diff line number Diff line change
1
+ name : Run .NET Tests
2
+
3
+ on :
4
+ push :
5
+ pull_request :
6
+
7
+ jobs :
8
+ build-and-test :
9
+ runs-on : ubuntu-latest
10
+
11
+ steps :
12
+ - name : Checkout code
13
+ uses : actions/checkout@v3
14
+
15
+ - name : Setup .NET
16
+ uses : actions/setup-dotnet@v3
17
+ with :
18
+ dotnet-version : 8.0.x
19
+
20
+ - name : Restore dependencies
21
+ run : dotnet restore
22
+
23
+ - name : Build project
24
+ run : dotnet build --no-restore
25
+
26
+ - name : Run tests
27
+ run : dotnet test --no-build --verbosity normal
Original file line number Diff line number Diff line change 59
59
.idea
60
60
.vscode
61
61
.git
62
+
63
+ * .user
Original file line number Diff line number Diff line change
1
+ namespace lib . config ;
2
+
3
+ public static class Config
4
+ {
5
+ public static string BaseUrl => "https://demoqa.com" ;
6
+ public static string ApiUrl => "https://demoqa.com" ;
7
+ }
Original file line number Diff line number Diff line change
1
+ using lib . config ;
2
+
3
+ namespace SeleniumTests . lib . helpers ;
4
+
5
+ public class ApiClient
6
+ {
7
+ private readonly HttpClient _client = new ( ) ;
8
+
9
+ public ApiClient ( )
10
+ {
11
+ _client . BaseAddress = new Uri ( Config . ApiUrl ) ;
12
+ }
13
+
14
+ public async Task < string > GetBooks ( )
15
+ {
16
+ var response = await _client . GetAsync ( $ "/BookStore/v1/Books") ;
17
+ var book = await response . Content . ReadAsStringAsync ( ) ;
18
+ return book ;
19
+ }
20
+ }
Original file line number Diff line number Diff line change
1
+ using System . Text . Json ;
2
+
3
+ namespace SeleniumTests . lib . helpers ;
4
+
5
+ public static class JsonHelper
6
+ {
7
+ public static T Deserialize < T > ( string json ) =>
8
+ JsonSerializer . Deserialize < T > ( json ) ! ;
9
+
10
+ public static string Serialize < T > ( T obj ) =>
11
+ JsonSerializer . Serialize ( obj ) ;
12
+ }
Original file line number Diff line number Diff line change
1
+ namespace SeleniumTests . lib . models ;
2
+
3
+ public class BookDto
4
+ {
5
+ public string isbn { get ; set ; }
6
+ public string title { get ; set ; }
7
+ public string subTitle { get ; set ; }
8
+ public string author { get ; set ; }
9
+ public string publish_date { get ; set ; }
10
+ public string publisher { get ; set ; }
11
+ public int pages { get ; set ; }
12
+ public string description { get ; set ; }
13
+ public string website { get ; set ; }
14
+ }
Original file line number Diff line number Diff line change
1
+ using OpenQA . Selenium ;
2
+ using SeleniumTests . lib . selectors ;
3
+
4
+ namespace SeleniumTests . lib . pages ;
5
+
6
+ public class HomePage ( IWebDriver driver )
7
+ {
8
+ public IWebElement Logo => driver . FindElement ( By . CssSelector ( HomePageSelectors . Logo ) ) ;
9
+ }
Original file line number Diff line number Diff line change
1
+ namespace SeleniumTests . lib . selectors ;
2
+
3
+ public static class HomePageSelectors
4
+ {
5
+ public const string Logo = "#app > header > a > img" ;
6
+ }
Original file line number Diff line number Diff line change
1
+ using SeleniumTests . lib . helpers ;
2
+
3
+ namespace SeleniumTests . tests ;
4
+
5
+ public class ApiBookStoreTests
6
+ {
7
+ [ Test ]
8
+ public async Task GetBooks_ShouldReturnBooksJson ( )
9
+ {
10
+ var api = new ApiClient ( ) ;
11
+ var books = await api . GetBooks ( ) ;
12
+
13
+ Assert . That ( books , Is . Not . Null ) ;
14
+ }
15
+ }
Original file line number Diff line number Diff line change 1
- using OpenQA . Selenium ;
1
+ using lib . config ;
2
2
using OpenQA . Selenium . Chrome ;
3
+ using SeleniumTests . lib . pages ;
3
4
4
- namespace SeleniumTests ;
5
+ namespace SeleniumTests . tests ;
5
6
6
- public class HeaderLogoTest
7
+ public class UiHomePageTests
7
8
{
8
9
private ChromeDriver ? _driver ;
9
10
@@ -15,12 +16,12 @@ public void Setup()
15
16
}
16
17
17
18
[ Test ]
18
- public void Header_ShouldContain_Logo ( )
19
+ public void HomePage_ShouldDisplay_Logo ( )
19
20
{
20
- _driver ! . Navigate ( ) . GoToUrl ( "https://demoqa.com" ) ;
21
- var logo = _driver . FindElement ( By . XPath ( "//header/a/img" ) ) ;
21
+ _driver ! . Navigate ( ) . GoToUrl ( Config . BaseUrl ) ;
22
+ var homePage = new HomePage ( _driver ) ;
22
23
23
- Assert . That ( logo . Displayed , Is . True ) ;
24
+ Assert . That ( homePage . Logo . Displayed , Is . True ) ;
24
25
}
25
26
26
27
[ TearDown ]
@@ -29,4 +30,4 @@ public void Teardown()
29
30
_driver ? . Quit ( ) ;
30
31
_driver ? . Dispose ( ) ;
31
32
}
32
- }
33
+ }
You can’t perform that action at this time.
0 commit comments