diff --git a/TestUtilities/TestUtilities.csproj b/TestUtilities/TestUtilities.csproj
index 6abf5a7..07f311c 100644
--- a/TestUtilities/TestUtilities.csproj
+++ b/TestUtilities/TestUtilities.csproj
@@ -11,15 +11,13 @@
-
-
+
-
-
+
+
-
diff --git a/UIAutomationTests/AbstractionLayer/Elements/AlertElement.cs b/UIAutomationTests/AbstractionLayer/Elements/AlertElement.cs
index ee96e10..7d83ce7 100644
--- a/UIAutomationTests/AbstractionLayer/Elements/AlertElement.cs
+++ b/UIAutomationTests/AbstractionLayer/Elements/AlertElement.cs
@@ -1,12 +1,12 @@
using NUnit.Framework;
using OpenQA.Selenium;
using SeleniumExtras.WaitHelpers;
-using TestUtilities.UITesting.Drivers;
-using TestUtilities.UITesting.Helpers;
using TestUtilities.Logs;
+using UIAutomationTests.Drivers;
+using UIAutomationTests.Helpers;
-namespace TestUtilities.UITesting.AbstractionLayer.Elements
+namespace UIAutomationTests.AbstractionLayer.Elements
{
public class AlertElement
{
@@ -18,9 +18,10 @@ public AlertElement(ScenarioContext scenarioContext)
{
_waits = new(scenarioContext);
_logger = new(scenarioContext.ScenarioInfo.Title);
+
try
{
- Alert = Driver.GetDriver(scenarioContext.Get("BrowserName")).SwitchTo().Alert();
+ Alert = Driver.GetDriver(scenarioContext).SwitchTo().Alert();
}
catch (NoAlertPresentException)
{
diff --git a/UIAutomationTests/AbstractionLayer/Elements/ButtonElement.cs b/UIAutomationTests/AbstractionLayer/Elements/ButtonElement.cs
index 96ff613..f3a9700 100644
--- a/UIAutomationTests/AbstractionLayer/Elements/ButtonElement.cs
+++ b/UIAutomationTests/AbstractionLayer/Elements/ButtonElement.cs
@@ -1,8 +1,8 @@
using OpenQA.Selenium;
-using TestUtilities.UITesting.Drivers;
+using UIAutomationTests.Drivers;
-namespace TestUtilities.UITesting.AbstractionLayer.Elements
+namespace UIAutomationTests.AbstractionLayer.Elements
{
public class ButtonElement
{
@@ -11,7 +11,7 @@ public class ButtonElement
public ButtonElement(ScenarioContext scenarioContext, string locator)
{
_scenarioContext = scenarioContext;
- Button = Driver.GetDriver(_scenarioContext.Get("BrowserName")).FindElement(By.CssSelector(locator));
+ Button = Driver.GetDriver(_scenarioContext).FindElement(By.CssSelector(locator));
}
public void Click() => Button.Click();
diff --git a/UIAutomationTests/AbstractionLayer/Elements/CheckboxElement.cs b/UIAutomationTests/AbstractionLayer/Elements/CheckboxElement.cs
index 9a594d0..fc8236e 100644
--- a/UIAutomationTests/AbstractionLayer/Elements/CheckboxElement.cs
+++ b/UIAutomationTests/AbstractionLayer/Elements/CheckboxElement.cs
@@ -1,14 +1,13 @@
-using TestUtilities.UITesting.Drivers;
-using TestUtilities.UITesting.Helpers;
-using TestUtilities.Logs;
-using NUnit.Framework;
+using TestUtilities.Logs;
using OpenQA.Selenium;
+using UIAutomationTests.Drivers;
+using UIAutomationTests.Helpers;
-namespace TestUtilities.UITesting.AbstractionLayer.Elements
+namespace UIAutomationTests.AbstractionLayer.Elements
{
public class CheckboxElement
{
- public readonly IWebElement ?Checkbox;
+ public readonly IWebElement? Checkbox;
private readonly ScenarioContext _scenarioContext;
private readonly string _locator;
private readonly StateChecker _stateChecker;
@@ -22,7 +21,7 @@ public CheckboxElement(ScenarioContext scenarioContext, string locator)
_logger = new(scenarioContext.ScenarioInfo.Title);
try
{
- Checkbox = Driver.GetDriver(_scenarioContext.Get("BrowserName")).FindElement(By.CssSelector(locator));
+ Checkbox = Driver.GetDriver(_scenarioContext).FindElement(By.CssSelector(locator));
}
catch (NoSuchElementException)
{
@@ -30,12 +29,6 @@ public CheckboxElement(ScenarioContext scenarioContext, string locator)
}
}
- public void AssertIfChecked(bool expectedResult)
- {
- bool isChecked = GetCheckedState();
- Assert.That(isChecked, Is.EqualTo(expectedResult));
- }
-
public void CheckAll()
{
int numberOfCheckboxes = _stateChecker.GetNumberOfElements(By.CssSelector(_locator));
@@ -62,8 +55,8 @@ public void UnCheckAll()
}
}
- private void Click() => Checkbox?.Click();
+ public bool GetCheckedState() => StateChecker.GetPropertyState(Checkbox, Properties.Checked);
- private bool GetCheckedState() => StateChecker.GetPropertyState(Checkbox, Properties.Checked);
+ private void Click() => Checkbox?.Click();
}
}
diff --git a/UIAutomationTests/AbstractionLayer/Elements/DropdownElement.cs b/UIAutomationTests/AbstractionLayer/Elements/DropdownElement.cs
index fd2b6a4..334c2cf 100644
--- a/UIAutomationTests/AbstractionLayer/Elements/DropdownElement.cs
+++ b/UIAutomationTests/AbstractionLayer/Elements/DropdownElement.cs
@@ -1,9 +1,9 @@
using OpenQA.Selenium;
using OpenQA.Selenium.Support.UI;
using SeleniumExtras.WaitHelpers;
-using TestUtilities.UITesting.Drivers;
+using UIAutomationTests.Drivers;
-namespace TestUtilities.UITesting.AbstractionLayer.Elements
+namespace UIAutomationTests.AbstractionLayer.Elements
{
public class DropdownElement
{
@@ -14,7 +14,7 @@ public class DropdownElement
public DropdownElement(ScenarioContext scenarioContext, string cssSelector)
{
_scenarioContext = scenarioContext;
- Dropdown = Driver.GetDriver(_scenarioContext.Get("BrowserName")).FindElement(By.CssSelector(cssSelector));
+ Dropdown = Driver.GetDriver(_scenarioContext).FindElement(By.CssSelector(cssSelector));
_dropdown = new SelectElement(Dropdown);
}
@@ -23,9 +23,6 @@ public DropdownElement(ScenarioContext scenarioContext, string cssSelector)
public void SelectElementInDropdown(string value)
{
_dropdown.SelectByValue(value);
- //Assertion will check if the element is selected
- var selectedElement = _dropdown.SelectedOption;
- ExpectedConditions.ElementToBeSelected(selectedElement);
}
public void SelectAllElementsInDropdown()
@@ -34,7 +31,6 @@ public void SelectAllElementsInDropdown()
for (int i = 1; i < numberOfElements; i++)
{
_dropdown.SelectByIndex(i);
- //Assertion will check if the element is selected
_dropdown.SelectedOption.Selected.Should().BeTrue();
}
}
diff --git a/UIAutomationTests/AbstractionLayer/Properties.cs b/UIAutomationTests/AbstractionLayer/Properties.cs
index e94341f..cf33ff5 100644
--- a/UIAutomationTests/AbstractionLayer/Properties.cs
+++ b/UIAutomationTests/AbstractionLayer/Properties.cs
@@ -1,4 +1,4 @@
-namespace TestUtilities.UITesting.AbstractionLayer
+namespace UIAutomationTests.AbstractionLayer
{
public static class Properties
{
diff --git a/UIAutomationTests/Drivers/Driver.cs b/UIAutomationTests/Drivers/Driver.cs
index 96dc55c..aa8d767 100644
--- a/UIAutomationTests/Drivers/Driver.cs
+++ b/UIAutomationTests/Drivers/Driver.cs
@@ -4,14 +4,15 @@
using OpenQA.Selenium.Firefox;
using OpenQA.Selenium.Remote;
-namespace TestUtilities.UITesting.Drivers
+namespace UIAutomationTests.Drivers
{
public class Driver
{
private static readonly ThreadLocal _threadLocalDriver = new();
- public static IWebDriver GetDriver(string browserName)
+ public static IWebDriver GetDriver(ScenarioContext scenarioContext)
{
+ var browserName = scenarioContext.Get("BrowserName");
if (!_threadLocalDriver.IsValueCreated || _threadLocalDriver.Value == null)
{
dynamic options = GetBrowserOptions(browserName);
diff --git a/UIAutomationTests/Helpers/ActionBuilder.cs b/UIAutomationTests/Helpers/ActionBuilder.cs
index a80bcaa..4b9f6bf 100644
--- a/UIAutomationTests/Helpers/ActionBuilder.cs
+++ b/UIAutomationTests/Helpers/ActionBuilder.cs
@@ -1,8 +1,8 @@
-using TestUtilities.UITesting.Drivers;
-using OpenQA.Selenium;
+using OpenQA.Selenium;
using OpenQA.Selenium.Interactions;
+using UIAutomationTests.Drivers;
-namespace TestUtilities.UITesting.Helpers
+namespace UIAutomationTests.Helpers
{
public class ActionsBuilder
{
@@ -11,7 +11,7 @@ public class ActionsBuilder
public IAction RightClickOnContextMenu(IWebElement contextMenu)
{
- Actions actions = new(Driver.GetDriver(_scenarioContext.Get("BrowserName")));
+ Actions actions = new(Driver.GetDriver(_scenarioContext));
return actions.MoveToElement(contextMenu).ContextClick().Build();
}
}
diff --git a/UIAutomationTests/Helpers/FileManager.cs b/UIAutomationTests/Helpers/FileManager.cs
index 5b71678..8eadb41 100644
--- a/UIAutomationTests/Helpers/FileManager.cs
+++ b/UIAutomationTests/Helpers/FileManager.cs
@@ -2,7 +2,7 @@
using OpenQA.Selenium;
using TechTalk.SpecFlow.Tracing;
-namespace TestUtilities.UITesting.Helpers
+namespace UIAutomationTests.Helpers
{
public class FileManager(FeatureContext featureContext, ScenarioContext scenarioContext)
{
diff --git a/UIAutomationTests/Helpers/Locator.cs b/UIAutomationTests/Helpers/Locator.cs
index 9100528..61785b6 100644
--- a/UIAutomationTests/Helpers/Locator.cs
+++ b/UIAutomationTests/Helpers/Locator.cs
@@ -1,4 +1,4 @@
-namespace TestUtilities.UITesting.Helpers
+namespace UIAutomationTests.Helpers
{
public static class Locator
{
diff --git a/UIAutomationTests/Helpers/StateChecker.cs b/UIAutomationTests/Helpers/StateChecker.cs
index 3d19c66..453ab5f 100644
--- a/UIAutomationTests/Helpers/StateChecker.cs
+++ b/UIAutomationTests/Helpers/StateChecker.cs
@@ -1,8 +1,8 @@
-using TestUtilities.UITesting.Drivers;
-using OpenQA.Selenium;
+using OpenQA.Selenium;
using TestUtilities.Logs;
+using UIAutomationTests.Drivers;
-namespace TestUtilities.UITesting.Helpers
+namespace UIAutomationTests.Helpers
{
public class StateChecker
{
@@ -18,61 +18,20 @@ public StateChecker(ScenarioContext scenarioContext)
}
public static bool GetPropertyState(IWebElement element, string property) => Convert.ToBoolean(element.GetDomProperty(property));
- public int GetNumberOfElements(By by) => Driver.GetDriver(_scenarioContext.Get("BrowserName")).FindElements(by).Count;
+ public int GetNumberOfElements(By by) => Driver.GetDriver(_scenarioContext).FindElements(by).Count;
- public bool CheckIfItemIsLoaded(IWebElement clickedButton, IWebElement itemToCheck)
- {
- var wait = _waits.GetWebDriverWait();
- wait.Until(_ => clickedButton.Enabled);
-
- _logger.WriteInfoLog($"Clicked element enable state: {clickedButton.Enabled}");
- return CheckIfItemIsEnabled(itemToCheck);
- }
-
- public bool CheckIfItemIsEnabled(By locator)
+ public bool IsElementDisplayed(Func element)
{
try
{
- IWebElement element = Driver.GetDriver(_scenarioContext.Get("BrowserName")).FindElement(locator);
- var wait = _waits.GetWebDriverWait();
- wait.Until(_ => element.Enabled);
-
- _logger.WriteInfoLog($"Clicked element enable state: {element.Enabled}");
- return element.Enabled;
+ return _waits.WaitUntil(() => element().Displayed);
}
- catch (Exception ex)
+ catch(Exception)
{
- if (ex is NoSuchElementException
- || ex is StaleElementReferenceException
- || ex is WebDriverTimeoutException)
- {
- _logger.WriteInfoLog($"Clicked element enable state: False\nException occurred: {ex.Message}");
- return false;
- }
- throw;
+ _logger.WriteWarningLog("Exception was found during waiting for element");
+ return false;
}
- }
- public bool CheckIfItemIsEnabled(IWebElement element)
- {
- try
- {
- var wait = _waits.GetWebDriverWait();
- wait.Until(_ => element.Enabled);
- _logger.WriteInfoLog($"Clicked element enable state: {element.Enabled}");
- return element.Enabled;
- }
- catch (Exception ex)
- {
- if (ex is NoSuchElementException
- || ex is StaleElementReferenceException
- || ex is WebDriverTimeoutException)
- {
- _logger.WriteInfoLog($"Clicked element enable state: False\nException occurred: {ex.Message}");
- return false;
- }
- throw;
- }
}
}
}
diff --git a/UIAutomationTests/Helpers/Waits.cs b/UIAutomationTests/Helpers/Waits.cs
index e14a3e1..ea35fdd 100644
--- a/UIAutomationTests/Helpers/Waits.cs
+++ b/UIAutomationTests/Helpers/Waits.cs
@@ -1,27 +1,47 @@
-using TestUtilities.UITesting.Drivers;
-using OpenQA.Selenium;
+using OpenQA.Selenium;
using OpenQA.Selenium.Support.UI;
+using UIAutomationTests.Drivers;
-namespace TestUtilities.UITesting.Helpers
+namespace UIAutomationTests.Helpers
{
public class Waits
{
private readonly ScenarioContext _scenarioContext;
- public Waits(ScenarioContext scenarioContext) => _scenarioContext = scenarioContext;
+
+ public Waits(ScenarioContext scenarioContext)
+ {
+ _scenarioContext = scenarioContext;
+ }
+
public DefaultWait GetWebDriverWait(int timeoutInSeconds = 5)
{
- DefaultWait wait = new(Driver.GetDriver(_scenarioContext.Get("BrowserName")));
+ DefaultWait wait = new(Driver.GetDriver(_scenarioContext));
wait.Timeout = TimeSpan.FromSeconds(timeoutInSeconds);
return wait;
}
- public DefaultWait GetFluentWait(int timeoutInSeconds = 3, int pollingIntervalInMilliseconds = 100)
+
+ public bool WaitUntil(Func condition, int timeoutInSeconds = 5)
{
- DefaultWait fluentWait = new(Driver.GetDriver(_scenarioContext.Get("BrowserName")));
- fluentWait.Timeout = TimeSpan.FromSeconds(timeoutInSeconds);
- fluentWait.PollingInterval = TimeSpan.FromMilliseconds(pollingIntervalInMilliseconds);
+ DateTime startTime = DateTime.Now;
+
+ while ((DateTime.Now - startTime).TotalSeconds < timeoutInSeconds)
+ {
+ try
+ {
+ if (condition())
+ {
+ return true;
+ }
+ }
+ catch
+ {
+ }
+
+ Thread.Sleep(500);
+ }
- return fluentWait;
+ return false;
}
}
}
diff --git a/UIAutomationTests/Hooks/AfterHooks.cs b/UIAutomationTests/Hooks/AfterHooks.cs
index 1eafbc6..04560ef 100644
--- a/UIAutomationTests/Hooks/AfterHooks.cs
+++ b/UIAutomationTests/Hooks/AfterHooks.cs
@@ -1,7 +1,7 @@
-using TestUtilities.UITesting.Drivers;
-using System.Reflection;
+using System.Reflection;
using TestUtilities.Logs;
using NUnit.Framework;
+using UIAutomationTests.Drivers;
[assembly: Parallelizable(ParallelScope.Fixtures)]
[assembly: LevelOfParallelism(3)]
diff --git a/UIAutomationTests/Hooks/Reports/ReporterHooks.cs b/UIAutomationTests/Hooks/Reports/ReporterHooks.cs
deleted file mode 100644
index 5d4e376..0000000
--- a/UIAutomationTests/Hooks/Reports/ReporterHooks.cs
+++ /dev/null
@@ -1,71 +0,0 @@
-using System.Reflection;
-using AventStack.ExtentReports;
-using AventStack.ExtentReports.Gherkin;
-using AventStack.ExtentReports.Reporter;
-using AventStack.ExtentReports.Reporter.Config;
-using TestUtilities.UITesting.Helpers;
-namespace AutomationPractice.Drivers.Hooks.Reports.Properties
-{
- [Binding]
- class Reporter : Steps
- {
- private static ExtentTest _featureName;
- private static ExtentTest _scenario;
- private static ExtentReports _extent;
- private readonly FeatureContext _featureContext;
- private readonly ScenarioContext _scenarioContext;
- private readonly FileManager _fileManager;
- public Reporter(FeatureContext featureContext, ScenarioContext scenarioContext)
- {
- _featureContext = featureContext;
- _scenarioContext = scenarioContext;
- _fileManager = new(_featureContext, _scenarioContext);
- var htmlReporter = new ExtentSparkReporter(_fileManager.GetReportFilePath());
- htmlReporter.Config.Theme = Theme.Dark;
- _extent = new ExtentReports();
- _extent.AttachReporter(htmlReporter);
- }
-
- [BeforeFeature]
- public static void BeforeFeature(FeatureContext featureContext)
- {
- _extent = new ExtentReports();
- _featureName = _extent.CreateTest(new GherkinKeyword("Feature"), featureContext.FeatureInfo.Title);
- _scenario = _featureName.CreateNode(new GherkinKeyword("Scenario"), featureContext.FeatureInfo.Title);
- }
-
- [AfterTestRun]
- public static void TearDownReport() => _extent.Flush();
-
- [AfterStep]
- public void InsertReportingSteps(ScenarioContext sc)
- {
- var stepType = _scenarioContext.StepContext.StepInfo.StepDefinitionType.ToString();
- PropertyInfo pInfo = typeof(ScenarioContext).GetProperty("ScenarioExecutionStatus", BindingFlags.Instance | BindingFlags.Public);
- MethodInfo getter = pInfo.GetGetMethod(nonPublic: true);
- object TestResult = getter.Invoke(sc, null);
- if (sc.TestError == null)
- {
- if (stepType == "Given")
- _scenario.CreateNode(new GherkinKeyword("Given"), _scenarioContext.StepContext.StepInfo.Text).Pass("Pass");
- else if (stepType == "When")
- _scenario.CreateNode(new GherkinKeyword("When"), _scenarioContext.StepContext.StepInfo.Text).Pass("Pass");
- else if (stepType == "Then")
- _scenario.CreateNode(new GherkinKeyword("Then"), _scenarioContext.StepContext.StepInfo.Text).Pass("Pass");
- else if (stepType == "And")
- _scenario.CreateNode(new GherkinKeyword("And"), _scenarioContext.StepContext.StepInfo.Text).Pass("Pass");
- }
- if (sc.TestError != null)
- {
- if (stepType == "Given")
- _scenario.CreateNode(new GherkinKeyword("Given"), _scenarioContext.StepContext.StepInfo.Text).Fail(sc.TestError.Message);
- if (stepType == "When")
- _scenario.CreateNode(new GherkinKeyword("When"), _scenarioContext.StepContext.StepInfo.Text).Fail(sc.TestError.Message);
- if (stepType == "Then")
- _scenario.CreateNode(new GherkinKeyword("Then"), _scenarioContext.StepContext.StepInfo.Text).Fail(sc.TestError.Message);
- if (stepType == "And")
- _scenario.CreateNode(new GherkinKeyword("And"), _scenarioContext.StepContext.StepInfo.Text).Fail(sc.TestError.Message);
- }
- }
- }
-}
diff --git a/UIAutomationTests/Hooks/ScreenshotHook.cs b/UIAutomationTests/Hooks/ScreenshotHook.cs
index bd1b7fb..ab89c62 100644
--- a/UIAutomationTests/Hooks/ScreenshotHook.cs
+++ b/UIAutomationTests/Hooks/ScreenshotHook.cs
@@ -1,14 +1,14 @@
-using TestUtilities.UITesting.Helpers;
-using TestUtilities.UITesting.Drivers;
-using OpenQA.Selenium;
+using OpenQA.Selenium;
using TestUtilities.Logs;
+using UIAutomationTests.Helpers;
+using UIAutomationTests.Drivers;
-namespace AutomationPractice.Hooks
+namespace UIAutomationTests.Hooks
{
[Binding]
public class ScreenshotHook
{
- private IWebDriver DriverInstance() => Driver.GetDriver(_scenarioContext.Get("BrowserName"));
+ private IWebDriver DriverInstance() => Driver.GetDriver(_scenarioContext);
private readonly FeatureContext _featureContext;
private readonly ScenarioContext _scenarioContext;
private readonly Logger _logger;
diff --git a/UIAutomationTests/PageObjects/AddRemoveElementsPage.cs b/UIAutomationTests/PageObjects/AddRemoveElementsPage.cs
index 25dee3c..d4eaa05 100644
--- a/UIAutomationTests/PageObjects/AddRemoveElementsPage.cs
+++ b/UIAutomationTests/PageObjects/AddRemoveElementsPage.cs
@@ -1,26 +1,28 @@
using OpenQA.Selenium;
-using TestUtilities.UITesting.AbstractionLayer.Elements;
-using TestUtilities.UITesting.Helpers;
+using UIAutomationTests.AbstractionLayer.Elements;
+using UIAutomationTests.Helpers;
-namespace AutomationPractice.PageObjects
+namespace UIAutomationTests.PageObjects
{
public class AddRemoveElementsPage
{
+ private ButtonElement AddElementButton => new(_scenarioContext, Locator.GetButtonLocator("addElement"));
+
private readonly ScenarioContext _scenarioContext;
private readonly StateChecker _stateChecker;
- private ButtonElement AddElementButton() => new(_scenarioContext, Locator.GetButtonLocator("addElement"));
public AddRemoveElementsPage(ScenarioContext scenarioContext)
{
_scenarioContext = scenarioContext;
_stateChecker = new(_scenarioContext);
}
- public void ClickAddElementButton()=> AddElementButton().Click();
+
+ public void ClickAddElementButton() => AddElementButton.Click();
public void RemoveAllTheElements()
{
int numberOfRemoveButtons = _stateChecker.GetNumberOfElements(By.CssSelector(Locator.GetButtonLocator("deleteElement")));
- for(int i = 0; i < numberOfRemoveButtons; i++)
+ for (int i = 0; i < numberOfRemoveButtons; i++)
{
ButtonElement deleteButton = new(_scenarioContext, Locator.GetButtonLocator("deleteElement"));
deleteButton.Click();
diff --git a/UIAutomationTests/PageObjects/BasicAuthPage.cs b/UIAutomationTests/PageObjects/BasicAuthPage.cs
index 8362cfc..466c16d 100644
--- a/UIAutomationTests/PageObjects/BasicAuthPage.cs
+++ b/UIAutomationTests/PageObjects/BasicAuthPage.cs
@@ -1,12 +1,14 @@
-using TestUtilities.UITesting.Drivers;
-using OpenQA.Selenium;
+using OpenQA.Selenium;
using SeleniumExtras.WaitHelpers;
-using TestUtilities.UITesting.Helpers;
+using UIAutomationTests.Helpers;
+using UIAutomationTests.Drivers;
-namespace AutomationPractice.PageObjects
+namespace UIAutomationTests.PageObjects
{
public class BasicAuthPage
{
+ private IWebElement Message => Driver.GetDriver(_scenarioContext).FindElement(By.ClassName("example"));
+
private readonly ScenarioContext _scenarioContext;
private readonly StateChecker _stateChecker;
private readonly string _basicAuthPageUrlWithCorrectCredentails = "http://admin:admin@the-internet.herokuapp.com/basic_auth";
@@ -20,7 +22,7 @@ public BasicAuthPage(ScenarioContext scenarioContext)
public void GoToAuthPage(string loginName)
{
- var driver = Driver.GetDriver(_scenarioContext.Get("BrowserName"));
+ var driver = Driver.GetDriver(_scenarioContext);
switch (loginName)
{
case "admin":
@@ -38,23 +40,6 @@ public void GoToAuthPage(string loginName)
}
}
- public void AssertThatYouAreloggedIn()
- {
- By _messageLocator = By.ClassName("example");
- bool visibilityOfMessage = _stateChecker.CheckIfItemIsEnabled(_messageLocator);
- if (!visibilityOfMessage )
- {
- throw new Exception("Test is failed, can't find the message after authorization");
- }
- }
- public void AssertThatYouAreNotloggedIn()
- {
- By _messageLocator = By.ClassName("example");
- bool visibilityOfMessage = _stateChecker.CheckIfItemIsEnabled(_messageLocator);
- if (visibilityOfMessage)
- {
- throw new Exception("Test is failed, can't find the message after authorization");
- }
- }
+ public bool IsUserLoggedIn() => _stateChecker.IsElementDisplayed(() => Message);
}
}
diff --git a/UIAutomationTests/PageObjects/CheckboxesPage.cs b/UIAutomationTests/PageObjects/CheckboxesPage.cs
index e563a10..b630092 100644
--- a/UIAutomationTests/PageObjects/CheckboxesPage.cs
+++ b/UIAutomationTests/PageObjects/CheckboxesPage.cs
@@ -1,26 +1,23 @@
-using TestUtilities.UITesting.AbstractionLayer.Elements;
-using TestUtilities.UITesting.Helpers;
+using UIAutomationTests.AbstractionLayer.Elements;
+using UIAutomationTests.Helpers;
-namespace AutomationPractice.PageObjects
+namespace UIAutomationTests.PageObjects
{
public class CheckboxesPage
{
+ private CheckboxElement Checkbox => new (_scenarioContext, Locator.GetCheckboxLocator());
+
private readonly ScenarioContext _scenarioContext;
- private readonly CheckboxElement _checkbox;
+
public CheckboxesPage(ScenarioContext scenarioContext)
{
_scenarioContext = scenarioContext;
- _checkbox = new(_scenarioContext, Locator.GetCheckboxLocator());
}
- public void CheckAllCheckboxes() => _checkbox.CheckAll();
-
- public void UnCheckAllCheckboxes() => _checkbox.UnCheckAll();
-
- private void AssertCheckboxes(bool expectedResult) => _checkbox.AssertIfChecked(expectedResult);
+ public void CheckAllCheckboxes() => Checkbox.CheckAll();
- public void AssertIfAllCheckboxesAreChecked() => AssertCheckboxes(expectedResult : true);
+ public void UnCheckAllCheckboxes() => Checkbox.UnCheckAll();
- public void AssertIfAllCheckboxesAreUnChecked() => AssertCheckboxes(expectedResult : false);
+ public bool IsChecked() => Checkbox.GetCheckedState();
}
}
diff --git a/UIAutomationTests/PageObjects/ContextMenuPage.cs b/UIAutomationTests/PageObjects/ContextMenuPage.cs
index 44adce1..421d894 100644
--- a/UIAutomationTests/PageObjects/ContextMenuPage.cs
+++ b/UIAutomationTests/PageObjects/ContextMenuPage.cs
@@ -1,25 +1,27 @@
using OpenQA.Selenium;
-using TestUtilities.UITesting.AbstractionLayer.Elements;
-using TestUtilities.UITesting.Drivers;
-using TestUtilities.UITesting.Helpers;
+using UIAutomationTests.AbstractionLayer.Elements;
+using UIAutomationTests.Drivers;
+using UIAutomationTests.Helpers;
-namespace AutomationPractice.PageObjects
+namespace UIAutomationTests.PageObjects
{
public class ContextMenuPage
{
+ private AlertElement Alert => new(_scenarioContext);
+ private IWebElement ContextMenu => Driver.GetDriver(_scenarioContext).FindElement(By.Id("hot-spot"));
+
private readonly ScenarioContext _scenarioContext;
+
public ContextMenuPage(ScenarioContext scenarioContext)
{
_scenarioContext = scenarioContext;
}
- AlertElement Alert => new(_scenarioContext);
-
public void RightClickOnContextMenu()
{
ActionsBuilder actionsBuilder = new(_scenarioContext);
- actionsBuilder.RightClickOnContextMenu(Driver.GetDriver(_scenarioContext.Get("BrowserName")).FindElement(By.Id("hot-spot"))).Perform();
+ actionsBuilder.RightClickOnContextMenu(ContextMenu).Perform();
}
public void AcceptTheAllert() => Alert.Accept();
diff --git a/UIAutomationTests/PageObjects/DropdownPage.cs b/UIAutomationTests/PageObjects/DropdownPage.cs
index f82dd94..9b10419 100644
--- a/UIAutomationTests/PageObjects/DropdownPage.cs
+++ b/UIAutomationTests/PageObjects/DropdownPage.cs
@@ -1,20 +1,20 @@
-using TestUtilities.UITesting.AbstractionLayer.Elements;
+using UIAutomationTests.AbstractionLayer.Elements;
-namespace AutomationPractice.PageObjects
+namespace UIAutomationTests.PageObjects
{
public class DropdownPage
{
+ private DropdownElement Dropdown => new(_scenarioContext, "#dropdown");
+
private readonly ScenarioContext _scenarioContext;
- private readonly DropdownElement _dropdown;
+
public DropdownPage(ScenarioContext scenarioContext)
{
_scenarioContext = scenarioContext;
- _dropdown = new(_scenarioContext, "#dropdown");
}
- public void SelectAllElementsInDropdown() => _dropdown.SelectAllElementsInDropdown();
+ public void SelectAllElementsInDropdown() => Dropdown.SelectAllElementsInDropdown();
- public void AssertNumberOfElementsInDropdown(int numberOfOptions) =>
- _dropdown.GetNumberOfElementsInDropdown().Should().Be(numberOfOptions);
+ public int GetNumberOfElementsInDropdown() => Dropdown.GetNumberOfElementsInDropdown();
}
}
diff --git a/UIAutomationTests/PageObjects/DynamicControlsPage.cs b/UIAutomationTests/PageObjects/DynamicControlsPage.cs
index e020a02..304bbd1 100644
--- a/UIAutomationTests/PageObjects/DynamicControlsPage.cs
+++ b/UIAutomationTests/PageObjects/DynamicControlsPage.cs
@@ -1,64 +1,62 @@
-using NUnit.Framework;
-using OpenQA.Selenium;
-using TestUtilities.UITesting.AbstractionLayer.Elements;
-using TestUtilities.UITesting.Drivers;
-using TestUtilities.UITesting.Helpers;
+using OpenQA.Selenium;
+using UIAutomationTests.Drivers;
+using UIAutomationTests.Helpers;
+using UIAutomationTests.AbstractionLayer.Elements;
namespace AutomationPractice.PageObjects
{
public class DynamicControlsPage
{
+ private ButtonElement RemoveOrAddButton => new(_scenarioContext, Locator.GetButtonLocator("swapCheckbox"));
+ private ButtonElement EnableOrDisableButton => new(_scenarioContext, Locator.GetButtonLocator("swapInput"));
+ private CheckboxElement Checkbox => new(_scenarioContext, Locator.GetCheckboxLocator());
+ private IWebElement FormField => Driver.GetDriver(_scenarioContext).FindElement(By.CssSelector("input[type='text']"));
+ private IWebElement EnableMessage => Driver.GetDriver(_scenarioContext).FindElement(By.Id("message"));
+
private readonly ScenarioContext _scenarioContext;
- private readonly StateChecker _stateChecker;
private readonly Waits _waits;
+
public DynamicControlsPage(ScenarioContext scenarioContext)
{
_scenarioContext = scenarioContext;
- _stateChecker = new(_scenarioContext);
_waits = new(_scenarioContext);
}
- private ButtonElement RemoveOrAddButton() => new(_scenarioContext, Locator.GetButtonLocator("swapCheckbox"));
- private ButtonElement EnableOrDisableButton() => new(_scenarioContext, Locator.GetButtonLocator("swapInput"));
- private CheckboxElement Checkbox() => new(_scenarioContext, Locator.GetCheckboxLocator());
- private IWebElement FormField() => Driver.GetDriver(_scenarioContext.Get("BrowserName")).FindElement(By.CssSelector("input[type='text']"));
-
- public void RemoveCheckbox()=> RemoveOrAddButton().Click();
-
- public void AssertIfCheckboxIsPresent(bool expectedResult)
+ public void RemoveCheckbox()=> RemoveOrAddButton.Click();
+ public void WaitUntilChecboxIsVisible() => _waits.WaitUntil(() => !Checkbox.Checkbox.Displayed);
+ public bool IsCheckboxDisplayed()
{
- bool state;
- if (!expectedResult)
+ try
{
- try
- {
- state = _stateChecker.CheckIfItemIsLoaded(RemoveOrAddButton().Button, Checkbox().Checkbox);
- }
- catch (Exception ex)
- {
- if (ex is WebDriverTimeoutException || ex is NullReferenceException)
- state = false;
- else throw new Exception("Unexpected exception occured");
- }
- Assert.That(state, Is.EqualTo(expectedResult));
+ return _waits.WaitUntil(() => Checkbox.Checkbox.Displayed);
+
}
- if(expectedResult)
+ catch (Exception)
{
- var wait = _waits.GetFluentWait(timeoutInSeconds:5);
- wait.Until(driver => Checkbox().Checkbox);
- state = _stateChecker.CheckIfItemIsLoaded(RemoveOrAddButton().Button, Checkbox().Checkbox);
- Assert.That(state, Is.EqualTo(expectedResult));
+ return false;
}
}
- public void AddCheckbox() => RemoveOrAddButton().Click();
+ public void AddCheckbox() => RemoveOrAddButton.Click();
+
+ public void ClickEnable() => EnableOrDisableButton.Click();
- public void ClickEnable() => EnableOrDisableButton().Click();
+ public bool IsFormFieldEnabled()
+ {
+ try
+ {
+ _waits.WaitUntil(() => EnableMessage.Displayed);
+ return EnableMessage.Text.Contains("enabled");
- public void AssertIfFormIsEnable(bool expectedResult) => Assert.That(_stateChecker.CheckIfItemIsLoaded(EnableOrDisableButton().Button, FormField()), Is.EqualTo(expectedResult));
+ }
+ catch (Exception)
+ {
+ return false;
+ }
+ }
- public void FillInFormField(string text) => FormField().SendKeys(text);
+ public void FillInFormField(string text) => FormField.SendKeys(text);
- public void ClickDisable() => EnableOrDisableButton().Click();
+ public void ClickDisable() => EnableOrDisableButton.Click();
}
}
\ No newline at end of file
diff --git a/UIAutomationTests/PageObjects/FormAuthenticationPage.cs b/UIAutomationTests/PageObjects/FormAuthenticationPage.cs
index 3a27f59..a5514b5 100644
--- a/UIAutomationTests/PageObjects/FormAuthenticationPage.cs
+++ b/UIAutomationTests/PageObjects/FormAuthenticationPage.cs
@@ -1,18 +1,19 @@
using OpenQA.Selenium;
-using TestUtilities.UITesting.Drivers;
-using TestUtilities.UITesting.Helpers;
+using UIAutomationTests.Drivers;
+using UIAutomationTests.Helpers;
namespace AutomationPractice.PageObjects
{
public class FormAuthenticationPage
{
+ private IWebElement UsernameField => Driver.GetDriver(_scenarioContext).FindElement(By.CssSelector("input[type='text']#username"));
+ private IWebElement PasswordField => Driver.GetDriver(_scenarioContext).FindElement(By.CssSelector("input[type='password']#password"));
+ private IWebElement LoginButton => Driver.GetDriver(_scenarioContext).FindElement(By.CssSelector(".radius[type='submit']"));
+ private IWebElement MessageWhenLoggedIn => Driver.GetDriver(_scenarioContext).FindElement(By.CssSelector("#flash[class='flash success']"));
+ private IWebElement MessageWhenNotLoggedIn => Driver.GetDriver(_scenarioContext).FindElement(By.CssSelector("#flash[class='flash error']"));
+
private readonly ScenarioContext _scenarioContext;
private readonly StateChecker _stateChecker;
- private IWebElement UsernameField() => Driver.GetDriver(_scenarioContext.Get("BrowserName")).FindElement(By.CssSelector("input[type='text']#username"));
- private IWebElement PasswordField() => Driver.GetDriver(_scenarioContext.Get("BrowserName")).FindElement(By.CssSelector("input[type='password']#password"));
- private IWebElement LoginButton() => Driver.GetDriver(_scenarioContext.Get("BrowserName")).FindElement(By.CssSelector(".radius[type='submit']"));
- private readonly By MessageWhenLoggedInLocator = By.CssSelector("#flash[class='flash success']");
- private readonly By MessageWhenNotLoggedInLocator = By.CssSelector("#flash[class='flash error']");
public FormAuthenticationPage(ScenarioContext scenarioContext)
{
@@ -22,18 +23,18 @@ public FormAuthenticationPage(ScenarioContext scenarioContext)
public void Login(string username, string password)
{
- UsernameField().SendKeys(username);
- PasswordField().SendKeys(password);
+ UsernameField.SendKeys(username);
+ PasswordField.SendKeys(password);
}
- public void ClickLoginButton() => LoginButton().Click();
+ public void ClickLoginButton() => LoginButton.Click();
- public bool CheckIfUserIsLoggedIn()
+ public bool IsUserLoggedIn()
{
- if (_stateChecker.CheckIfItemIsEnabled(MessageWhenLoggedInLocator))
+ if (_stateChecker.IsElementDisplayed(() => MessageWhenLoggedIn))
return true;
- else if (_stateChecker.CheckIfItemIsEnabled(MessageWhenNotLoggedInLocator))
+ else if (_stateChecker.IsElementDisplayed(() => MessageWhenNotLoggedIn))
return false;
throw new Exception("Can't find message!");
diff --git a/UIAutomationTests/PageObjects/HomePage.cs b/UIAutomationTests/PageObjects/HomePage.cs
index 52f6498..ebe1aee 100644
--- a/UIAutomationTests/PageObjects/HomePage.cs
+++ b/UIAutomationTests/PageObjects/HomePage.cs
@@ -1,23 +1,29 @@
using OpenQA.Selenium;
using SeleniumExtras.WaitHelpers;
-using TestUtilities.UITesting.Drivers;
+using UIAutomationTests.Drivers;
namespace AutomationPractice.PageObjects
{
public class HomePage
{
+ private IWebElement Section(string sectionName) => Driver.GetDriver(_scenarioContext).FindElement(By.LinkText(sectionName));
+
private readonly ScenarioContext _scenarioContext;
private readonly string _homePageUrl = "http://the-internet.herokuapp.com/";
- public HomePage(ScenarioContext scenarioContext) => _scenarioContext = scenarioContext;
+ public HomePage(ScenarioContext scenarioContext)
+ {
+ _scenarioContext = scenarioContext;
+ }
+
public void GoToHomePage()
{
- IWebDriver _driver = Driver.GetDriver(_scenarioContext.Get("BrowserName"));
+ IWebDriver _driver = Driver.GetDriver(_scenarioContext);
_driver.Manage().Window.Maximize();
_driver.Navigate().GoToUrl("http://the-internet.herokuapp.com/");
ExpectedConditions.UrlMatches(_homePageUrl);
}
- public void OpenPage(string sectionName) => Driver.GetDriver(_scenarioContext.Get("BrowserName")).FindElement(By.LinkText(sectionName)).Click();
+ public void OpenPage(string sectionName) => Section(sectionName).Click();
}
}
diff --git a/UIAutomationTests/PageObjects/JavaScriptAlertsPage.cs b/UIAutomationTests/PageObjects/JavaScriptAlertsPage.cs
index 7c66eb8..d375f05 100644
--- a/UIAutomationTests/PageObjects/JavaScriptAlertsPage.cs
+++ b/UIAutomationTests/PageObjects/JavaScriptAlertsPage.cs
@@ -1,14 +1,19 @@
-using TestUtilities.UITesting.AbstractionLayer.Elements;
-using TestUtilities.UITesting.Helpers;
+using UIAutomationTests.Helpers;
+using UIAutomationTests.AbstractionLayer.Elements;
namespace AutomationPractice.PageObjects
{
public class JavaScriptAlertsPage
{
- private readonly ScenarioContext _scenarioContext;
private ButtonElement JavaScriptButton(string onClickValue) => new(_scenarioContext, Locator.GetButtonLocator(onClickValue));
private AlertElement Alert => new(_scenarioContext);
- public JavaScriptAlertsPage(ScenarioContext scenarioContext) => _scenarioContext = scenarioContext;
+
+ private readonly ScenarioContext _scenarioContext;
+
+ public JavaScriptAlertsPage(ScenarioContext scenarioContext)
+ {
+ _scenarioContext = scenarioContext;
+ }
public void ClickJavaScriptButton(string onClickValue) => JavaScriptButton(onClickValue).Click();
diff --git a/UIAutomationTests/StepDefinitions/AddAndRemoveElementsStepDefinitions.cs b/UIAutomationTests/StepDefinitions/AddAndRemoveElementsStepDefinitions.cs
index a8ce00f..ca61a29 100644
--- a/UIAutomationTests/StepDefinitions/AddAndRemoveElementsStepDefinitions.cs
+++ b/UIAutomationTests/StepDefinitions/AddAndRemoveElementsStepDefinitions.cs
@@ -1,7 +1,8 @@
using AutomationPractice.PageObjects;
using TechTalk.SpecFlow.Assist;
+using UIAutomationTests.PageObjects;
-namespace AutomationPractice.StepDefinitions
+namespace UIAutomationTests.StepDefinitions
{
[Binding]
public class AddAndRemoveElementsStepDefinitions
@@ -9,6 +10,7 @@ public class AddAndRemoveElementsStepDefinitions
private readonly ScenarioContext _scenarioContext;
private readonly HomePage _homePage;
private readonly AddRemoveElementsPage _addRemoveElementsPage;
+
public AddAndRemoveElementsStepDefinitions(ScenarioContext scenarioContext)
{
_scenarioContext = scenarioContext;
diff --git a/UIAutomationTests/StepDefinitions/BasicAuthStepDefinitions.cs b/UIAutomationTests/StepDefinitions/BasicAuthStepDefinitions.cs
index cdf4538..401fb42 100644
--- a/UIAutomationTests/StepDefinitions/BasicAuthStepDefinitions.cs
+++ b/UIAutomationTests/StepDefinitions/BasicAuthStepDefinitions.cs
@@ -1,11 +1,13 @@
-using AutomationPractice.PageObjects;
+using NUnit.Framework;
+using UIAutomationTests.PageObjects;
-namespace AutomationPractice.StepDefinitions
+namespace UIAutomationTests.StepDefinitions
{
[Binding]
public class BasicAuthStepDefinitions
{
private readonly BasicAuthPage _basicAuthPage;
+
public BasicAuthStepDefinitions(ScenarioContext scenarioContext)
{
_basicAuthPage = new(scenarioContext);
@@ -15,9 +17,9 @@ public BasicAuthStepDefinitions(ScenarioContext scenarioContext)
public void WhenUserLoginAs(string loginName) => _basicAuthPage.GoToAuthPage(loginName);
[Then(@"User will be logged in")]
- public void ThenUserWillBeLoggedIn() => _basicAuthPage.AssertThatYouAreloggedIn();
+ public void ThenUserWillBeLoggedIn() => Assert.That(_basicAuthPage.IsUserLoggedIn(), Is.True, "User is not logged in");
[Then(@"User will not be logged in")]
- public void ThenUserWillNotBeLoggedIn() => _basicAuthPage.AssertThatYouAreNotloggedIn();
+ public void ThenUserWillNotBeLoggedIn() => Assert.That(_basicAuthPage.IsUserLoggedIn(), Is.False, "User is logged in");
}
}
diff --git a/UIAutomationTests/StepDefinitions/CheckboxesStepDefinitions.cs b/UIAutomationTests/StepDefinitions/CheckboxesStepDefinitions.cs
index b7a2103..8deef80 100644
--- a/UIAutomationTests/StepDefinitions/CheckboxesStepDefinitions.cs
+++ b/UIAutomationTests/StepDefinitions/CheckboxesStepDefinitions.cs
@@ -1,11 +1,13 @@
-using AutomationPractice.PageObjects;
+using UIAutomationTests.PageObjects;
+using NUnit.Framework;
-namespace AutomationPractice.StepDefinitions
+namespace UIAutomationTests.StepDefinitions
{
[Binding]
public class CheckboxesStepDefinitions
{
private readonly CheckboxesPage _checkboxesPage;
+
public CheckboxesStepDefinitions(ScenarioContext scenarioContext)
{
_checkboxesPage = new(scenarioContext);
@@ -15,12 +17,11 @@ public CheckboxesStepDefinitions(ScenarioContext scenarioContext)
public void WhenIWillCheckAllCheckboxes() => _checkboxesPage.CheckAllCheckboxes();
[Then(@"All checkboxes are checked")]
- public void ThenAllCheckboxesAreChecked() => _checkboxesPage.AssertIfAllCheckboxesAreChecked();
-
+ public void ThenAllCheckboxesAreChecked() => Assert.That(_checkboxesPage.IsChecked(), Is.True);
[When(@"I will uncheck all checkboxes")]
public void WhenIWillUncheckAllCheckboxes() => _checkboxesPage.UnCheckAllCheckboxes();
[Then(@"All checkboxes are unchecked")]
- public void ThenAllCheckboxesAreUnchecked() => _checkboxesPage.AssertIfAllCheckboxesAreUnChecked();
+ public void ThenAllCheckboxesAreUnchecked() => Assert.That(_checkboxesPage.IsChecked(), Is.False);
}
}
diff --git a/UIAutomationTests/StepDefinitions/ContextMenuStepDefinitions.cs b/UIAutomationTests/StepDefinitions/ContextMenuStepDefinitions.cs
index c532358..bee5ee9 100644
--- a/UIAutomationTests/StepDefinitions/ContextMenuStepDefinitions.cs
+++ b/UIAutomationTests/StepDefinitions/ContextMenuStepDefinitions.cs
@@ -1,11 +1,12 @@
-using AutomationPractice.PageObjects;
+using UIAutomationTests.PageObjects;
-namespace AutomationPractice.StepDefinitions
+namespace UIAutomationTests.StepDefinitions
{
[Binding]
public class ContextMenuStepDefinitions
{
private readonly ContextMenuPage _contextMenuPage;
+
public ContextMenuStepDefinitions(ScenarioContext scenarioContext)
{
_contextMenuPage = new(scenarioContext);
diff --git a/UIAutomationTests/StepDefinitions/DropdownStepDefinitions.cs b/UIAutomationTests/StepDefinitions/DropdownStepDefinitions.cs
index ea3061d..0f3c028 100644
--- a/UIAutomationTests/StepDefinitions/DropdownStepDefinitions.cs
+++ b/UIAutomationTests/StepDefinitions/DropdownStepDefinitions.cs
@@ -1,11 +1,13 @@
-using AutomationPractice.PageObjects;
+using UIAutomationTests.PageObjects;
+using NUnit.Framework;
-namespace AutomationPractice.StepDefinitions
+namespace UIAutomationTests.StepDefinitions
{
[Binding]
public class DropdownStepDefinitions
{
private readonly DropdownPage _dropdownPage;
+
public DropdownStepDefinitions(ScenarioContext scenarioContext)
{
_dropdownPage = new(scenarioContext);
@@ -15,7 +17,7 @@ public DropdownStepDefinitions(ScenarioContext scenarioContext)
public void WhenUserSelectEveryOption() => _dropdownPage.SelectAllElementsInDropdown();
[Then(@"'([^']*)' options should be visible in the dropdown")]
- public void ThenOptionsShouldBeVisibleInTheDropdown(string numberOfOptions) =>
- _dropdownPage.AssertNumberOfElementsInDropdown(Int16.Parse(numberOfOptions));
+ public void ThenOptionsShouldBeVisibleInTheDropdown(int numberOfOptions) =>
+ Assert.That(_dropdownPage.GetNumberOfElementsInDropdown(), Is.EqualTo(numberOfOptions));
}
}
diff --git a/UIAutomationTests/StepDefinitions/DynamicControlsStepDefinitions.cs b/UIAutomationTests/StepDefinitions/DynamicControlsStepDefinitions.cs
index f06fd4d..08f8639 100644
--- a/UIAutomationTests/StepDefinitions/DynamicControlsStepDefinitions.cs
+++ b/UIAutomationTests/StepDefinitions/DynamicControlsStepDefinitions.cs
@@ -1,4 +1,5 @@
using AutomationPractice.PageObjects;
+using NUnit.Framework;
namespace AutomationPractice.StepDefinitions
{
@@ -6,6 +7,7 @@ namespace AutomationPractice.StepDefinitions
public class DynamicControlsStepDefinitions
{
private readonly DynamicControlsPage _dynamicControlsPage;
+
public DynamicControlsStepDefinitions(ScenarioContext scenarioContext)
{
_dynamicControlsPage = new DynamicControlsPage(scenarioContext);
@@ -15,19 +17,23 @@ public DynamicControlsStepDefinitions(ScenarioContext scenarioContext)
public void WhenIWillRemoveCheckbox() => _dynamicControlsPage.RemoveCheckbox();
[Then(@"Checkbox will gone")]
- public void ThenCheckboxWillGone() => _dynamicControlsPage.AssertIfCheckboxIsPresent(false);
+ public void ThenCheckboxWillGone()
+ {
+ _dynamicControlsPage.WaitUntilChecboxIsVisible();
+ Assert.That(_dynamicControlsPage.IsCheckboxDisplayed(), Is.False);
+ }
[When(@"I will add checkbox")]
public void WhenIWillAddCheckbox() => _dynamicControlsPage.AddCheckbox();
[Then(@"Checkbox will appear")]
- public void ThenCheckboxWillAppear() => _dynamicControlsPage.AssertIfCheckboxIsPresent(true);
+ public void ThenCheckboxWillAppear() => Assert.That(_dynamicControlsPage.IsCheckboxDisplayed(), Is.True);
[When(@"I will click enable")]
public void WhenIWillClickEnable() => _dynamicControlsPage.ClickEnable();
[Then(@"form will be enable")]
- public void ThenFormWillBeEnable() => _dynamicControlsPage.AssertIfFormIsEnable(true);
+ public void ThenFormWillBeEnable() => Assert.That(_dynamicControlsPage.IsFormFieldEnabled(), Is.EqualTo(true));
[When(@"I will fill in form")]
public void WhenIWillFillInForm() => _dynamicControlsPage.FillInFormField("Text123");
@@ -36,6 +42,7 @@ public DynamicControlsStepDefinitions(ScenarioContext scenarioContext)
public void WhenIWillClickDisable() => _dynamicControlsPage.ClickDisable();
[Then(@"form will be disable")]
- public void ThenFormWillBeDisable() => _dynamicControlsPage.AssertIfFormIsEnable(false);
+ public void ThenFormWillBeDisable() => Assert.That(_dynamicControlsPage.IsFormFieldEnabled(), Is.EqualTo(false));
+
}
}
diff --git a/UIAutomationTests/StepDefinitions/FormAuthenticationStepDefinitions.cs b/UIAutomationTests/StepDefinitions/FormAuthenticationStepDefinitions.cs
index c3d87a8..16441ea 100644
--- a/UIAutomationTests/StepDefinitions/FormAuthenticationStepDefinitions.cs
+++ b/UIAutomationTests/StepDefinitions/FormAuthenticationStepDefinitions.cs
@@ -7,6 +7,7 @@ namespace AutomationPractice.StepDefinitions
public class FormAuthenticationStepDefinitions
{
private readonly FormAuthenticationPage _loginPage;
+
public FormAuthenticationStepDefinitions(ScenarioContext scenarioContext)
{
_loginPage = new(scenarioContext);
@@ -19,12 +20,12 @@ public FormAuthenticationStepDefinitions(ScenarioContext scenarioContext)
public void WhenLoginButtonIsClicked() => _loginPage.ClickLoginButton();
[Then(@"User is successfully logged in")]
- public void ThenUserIsSuccessfullyLoggedIn() => Assert.That(_loginPage.CheckIfUserIsLoggedIn(), Is.True);
+ public void ThenUserIsSuccessfullyLoggedIn() => Assert.That(_loginPage.IsUserLoggedIn(), Is.True);
[When(@"Wrong credentials are filled in")]
public void WhenWrongCredentialsAreFilledIn() => _loginPage.Login(username: "WrongUser", password: "WrongPassword!");
[Then(@"User is not successfully logged in")]
- public void ThenUserIsNotSuccessfullyLoggedIn() => Assert.That(_loginPage.CheckIfUserIsLoggedIn(), Is.False);
+ public void ThenUserIsNotSuccessfullyLoggedIn() => Assert.That(_loginPage.IsUserLoggedIn(), Is.False);
}
}
diff --git a/UIAutomationTests/StepDefinitions/JavaScriptAlertsStepDefinitions.cs b/UIAutomationTests/StepDefinitions/JavaScriptAlertsStepDefinitions.cs
index 967722c..8ec7b9c 100644
--- a/UIAutomationTests/StepDefinitions/JavaScriptAlertsStepDefinitions.cs
+++ b/UIAutomationTests/StepDefinitions/JavaScriptAlertsStepDefinitions.cs
@@ -1,11 +1,12 @@
using AutomationPractice.PageObjects;
-namespace AutomationPractice.StepDefinitions
+namespace UIAutomationTests.StepDefinitions
{
[Binding]
public class JavaScriptAlertsStepDefinitions
{
private readonly JavaScriptAlertsPage _javaScriptAlertsPage;
+
public JavaScriptAlertsStepDefinitions(ScenarioContext scenarioContext)
{
_javaScriptAlertsPage = new(scenarioContext);
diff --git a/UIAutomationTests/UIAutomationTests.csproj b/UIAutomationTests/UIAutomationTests.csproj
index f7f0d80..d4b56af 100644
--- a/UIAutomationTests/UIAutomationTests.csproj
+++ b/UIAutomationTests/UIAutomationTests.csproj
@@ -19,17 +19,16 @@
-
-
+
-
-
+
+
-
+
-
+