Skip to content

Commit

Permalink
Updating WebDriverWrapper: deleting GetDriver() and adding GetUrl() m…
Browse files Browse the repository at this point in the history
…ethod; updating HomeTests
  • Loading branch information
ValiantsinaKhramava committed Jul 12, 2024
1 parent f4f0995 commit bab3fea
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,6 @@ public void NavigateTo(string url)
_driver.Navigate().GoToUrl(url);
}

public IWebDriver GetDriver()
{
return _driver;
}

public void WindowMaximise()
{
_driver.Manage().Window.Maximize();
Expand All @@ -47,5 +42,10 @@ public string GetTitle()
{
return _driver.Title;
}

public string GetUrl()
{
return _driver.Url;
}
}
}
10 changes: 4 additions & 6 deletions TestProject/TestProject/Tests/HomeTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ public override void SetUp()
_homePage = new HomePage(WebDriverWrapper);
}

[Test]
[TestCase("Automation", "search?q=Automation")]
public void SearchOnIndexPageTest_Updated(
string textToFind,
Expand All @@ -29,12 +28,11 @@ public void SearchOnIndexPageTest_Updated(
_homePage.ClickSearchIcon()
.EnterSearchTextUsingActions(textToFind)
.ClickFindButton();
var currentUrl = WebDriverWrapper.GetDriver().Url;
var currentUrl = WebDriverWrapper.GetUrl();
currentUrl.Should().Contain(searchUrl);
Logger.Information("Ending the test 'SearchOnIndexPageTest_Updated'.");
}

[Test]
[TestCaseSource(nameof(SearchModelData))]
public void SearchOnIndexPageTest_Updated_WithJsonData(
SearchModel searchModelItem)
Expand All @@ -43,7 +41,7 @@ public void SearchOnIndexPageTest_Updated_WithJsonData(
_homePage.ClickSearchIcon()
.EnterSearchTextUsingActions(searchModelItem.TextToSearch)
.ClickFindButton();
var currentUrl = WebDriverWrapper.GetDriver().Url;
var currentUrl = WebDriverWrapper.GetUrl();
currentUrl.Should().Contain(searchModelItem.SearchUrl);
Logger.Information("Ending the test 'SearchOnIndexPageTest_Updated'.");
}
Expand All @@ -53,8 +51,8 @@ private static List<SearchModel> SearchModelData
get
{
var jsonData = File.ReadAllText(Configuration.TestDataPath);
var SearchModelItems = JsonConvert.DeserializeObject<List<SearchModel>>(jsonData);
return SearchModelItems;
var searchModelItems = JsonConvert.DeserializeObject<List<SearchModel>>(jsonData);
return searchModelItems;

Check warning on line 55 in TestProject/TestProject/Tests/HomeTests.cs

View workflow job for this annotation

GitHub Actions / Build and tests

Possible null reference return.

Check warning on line 55 in TestProject/TestProject/Tests/HomeTests.cs

View workflow job for this annotation

GitHub Actions / Build and tests

Possible null reference return.
}
}
}
Expand Down

0 comments on commit bab3fea

Please sign in to comment.