Skip to content

Commit 8aa86d0

Browse files
authored
#63 #50 Add tests for custom browser factory (#64)
* #63 #50 Add tests for custom browser factory * #50 Move logger tests to usecases * #50 Add tests for overriden configuration * #63 Fix comments * #50 Change tests structure * #50 Update tests structure * #50 Update tests structure and add test for custom element * #50 Update tests structure and fix some issues
1 parent 81735f8 commit 8aa86d0

28 files changed

+304
-63
lines changed

Aquality.Selenium/src/Aquality.Selenium/Utilities/JsonFile.cs

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,15 @@ public T GetValue<T>(string jsonPath)
6868
if (envValue != null)
6969
{
7070
Logger.Instance.Debug($"***** Using variable passed from environment {jsonPath.Substring(1)}={envValue}");
71-
return (T) TypeDescriptor.GetConverter(typeof(T)).ConvertFrom(envValue);
71+
try
72+
{
73+
return (T)TypeDescriptor.GetConverter(typeof(T)).ConvertFrom(envValue);
74+
}
75+
catch (ArgumentException ex)
76+
{
77+
var message = $"Value of '{jsonPath}' environment variable has incorrect format: {ex.Message}";
78+
throw new ArgumentException(message);
79+
}
7280
}
7381

7482
var node = GetJsonNode(jsonPath);
@@ -94,7 +102,15 @@ public IList<T> GetValueList<T>(string jsonPath)
94102
if (envValue != null)
95103
{
96104
Logger.Instance.Debug($"***** Using variable passed from environment {jsonPath.Substring(1)}={envValue}");
97-
return envValue.Split(',').Select(value => (T) TypeDescriptor.GetConverter(typeof(T)).ConvertFrom(value.Trim())).ToList();
105+
try
106+
{
107+
return envValue.Split(',').Select(value => (T)TypeDescriptor.GetConverter(typeof(T)).ConvertFrom(value.Trim())).ToList();
108+
}
109+
catch (ArgumentException ex)
110+
{
111+
var message = $"Value of '{jsonPath}' environment variable has incorrect format: {ex.Message}";
112+
throw new ArgumentException(message);
113+
}
98114
}
99115

100116
var node = GetJsonNode(jsonPath);
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
using Aquality.Selenium.Tests.UITests.Forms.TheInternet;
1+
using Aquality.Selenium.Tests.Integration.TestApp.TheInternet.Forms;
22
using NUnit.Framework;
33

4-
namespace Aquality.Selenium.Tests.UITests.Integration.Actions
4+
namespace Aquality.Selenium.Tests.Integration.Actions
55
{
6-
public class CheckBoxJsActionsTests : UITest
6+
internal class CheckBoxJsActionsTests : UITest
77
{
88
[Test]
99
public void Should_BeAbleGetCheckboxState_WithJsActions()
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
using Aquality.Selenium.Tests.UITests.Forms.TheInternet;
1+
using Aquality.Selenium.Tests.Integration.TestApp.TheInternet.Forms;
22
using NUnit.Framework;
33

4-
namespace Aquality.Selenium.Tests.UITests.Integration.Actions
4+
namespace Aquality.Selenium.Tests.Integration.Actions
55
{
6-
public class ComboBoxJsActionsTests : UITest
6+
internal class ComboBoxJsActionsTests : UITest
77
{
88
[Test]
99
public void Should_BeAbleGetValues_WithJsActions()
Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
using Aquality.Selenium.Browsers;
22
using Aquality.Selenium.Elements;
3-
using Aquality.Selenium.Tests.Constants;
4-
using Aquality.Selenium.Tests.UITests.Forms.AutomationPractice;
5-
using Aquality.Selenium.Tests.UITests.Forms.TheInternet;
3+
using Aquality.Selenium.Tests.Integration.TestApp;
4+
using Aquality.Selenium.Tests.Integration.TestApp.AutomationPractice.Forms;
5+
using Aquality.Selenium.Tests.Integration.TestApp.TheInternet.Forms;
66
using Aquality.Selenium.Waitings;
77
using NUnit.Framework;
88
using OpenQA.Selenium;
99

10-
namespace Aquality.Selenium.Tests.UITests.Integration.Actions
10+
namespace Aquality.Selenium.Tests.Integration.Actions
1111
{
12-
public class JsActionsTests : UITest
12+
internal class JsActionsTests : UITest
1313
{
1414
[Test]
1515
public void Should_BeAbleClick_WithJsActions()
@@ -40,7 +40,7 @@ public void Should_BeAbleHighlight_WithJsActions()
4040
[Test]
4141
public void Should_BeAbleHover_WithJsActions()
4242
{
43-
BrowserManager.Browser.Navigate().GoToUrl(TestConstants.UrlAutomationPractice);
43+
BrowserManager.Browser.Navigate().GoToUrl(Constants.UrlAutomationPractice);
4444
var productList = new ProductListForm();
4545
productList.NavigateToLastProduct();
4646

@@ -53,7 +53,7 @@ public void Should_BeAbleHover_WithJsActions()
5353
[Test]
5454
public void Should_BeAbleSetFocus_WithJsActions()
5555
{
56-
BrowserManager.Browser.Navigate().GoToUrl(TestConstants.UrlAutomationPractice);
56+
BrowserManager.Browser.Navigate().GoToUrl(Constants.UrlAutomationPractice);
5757
var productList = new ProductListForm();
5858
productList.NavigateToLastProduct();
5959

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
using Aquality.Selenium.Browsers;
2-
using Aquality.Selenium.Tests.Constants;
3-
using Aquality.Selenium.Tests.UITests.Forms.AutomationPractice;
4-
using Aquality.Selenium.Tests.UITests.Forms.TheInternet;
2+
using Aquality.Selenium.Tests.Integration.TestApp;
3+
using Aquality.Selenium.Tests.Integration.TestApp.AutomationPractice.Forms;
4+
using Aquality.Selenium.Tests.Integration.TestApp.TheInternet.Forms;
55
using NUnit.Framework;
66

7-
namespace Aquality.Selenium.Tests.UITests.Integration.Actions
7+
namespace Aquality.Selenium.Tests.Integration.Actions
88
{
9-
public class MouseActionsTests : UITest
9+
internal class MouseActionsTests : UITest
1010
{
1111
[Test]
1212
public void Should_BeAbleClick_WithMouseActions()
@@ -42,7 +42,7 @@ public void Should_BeAbleRightClick_WithMouseActions()
4242
[Test]
4343
public void Should_BeAbleMoveMouse_WithMouseActions()
4444
{
45-
BrowserManager.Browser.Navigate().GoToUrl(TestConstants.UrlAutomationPractice);
45+
BrowserManager.Browser.Navigate().GoToUrl(Constants.UrlAutomationPractice);
4646
var productList = new ProductListForm();
4747
productList.NavigateToLastProduct();
4848

Aquality.Selenium/tests/Aquality.Selenium.Tests/UITests/Forms/AutomationPractice/ProductForm.cs renamed to Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/TestApp/AutomationPractice/Forms/ProductForm.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
using Aquality.Selenium.Forms;
55
using OpenQA.Selenium;
66

7-
namespace Aquality.Selenium.Tests.UITests.Forms.AutomationPractice
7+
namespace Aquality.Selenium.Tests.Integration.TestApp.AutomationPractice.Forms
88
{
9-
public class ProductForm : Form
9+
internal class ProductForm : Form
1010
{
1111
private static readonly By ProductsLocator = By.Id("product");
1212
public IList<ILabel> LblsProductView => ElementFactory.FindElements(By.XPath("//li[contains(@id,'thumbnail_')]//a"), ElementFactory.GetLabel);

Aquality.Selenium/tests/Aquality.Selenium.Tests/UITests/Forms/AutomationPractice/ProductListForm.cs renamed to Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/TestApp/AutomationPractice/Forms/ProductListForm.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
using Aquality.Selenium.Forms;
66
using OpenQA.Selenium;
77

8-
namespace Aquality.Selenium.Tests.UITests.Forms.AutomationPractice
8+
namespace Aquality.Selenium.Tests.Integration.TestApp.AutomationPractice.Forms
99
{
10-
public class ProductListForm : Form
10+
internal class ProductListForm : Form
1111
{
1212
private static readonly By ProductsLocator = By.XPath("//ul[@id='homefeatured']");
1313
private IEnumerable<ILink> LnksProduct => ElementFactory.FindElements(By.XPath("//ul[@id='homefeatured']//a[@class='product_img_link']"), ElementFactory.GetLink);
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
namespace Aquality.Selenium.Tests.Constants
1+
namespace Aquality.Selenium.Tests.Integration.TestApp
22
{
3-
public static class TestConstants
3+
internal static class Constants
44
{
5-
public const string UrlTheInternet = "http://the-internet.herokuapp.com";
5+
public const string UrlTheInternet = "http://the-internet.herokuapp.com/";
66
public const string UrlAutomationPractice = "http://automationpractice.com";
77
}
88
}

Aquality.Selenium/tests/Aquality.Selenium.Tests/UITests/Forms/TheInternet/AddRemoveElementsForm.cs renamed to Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/TestApp/TheInternet/Forms/AddRemoveElementsForm.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
using Aquality.Selenium.Forms;
44
using OpenQA.Selenium;
55

6-
namespace Aquality.Selenium.Tests.UITests.Forms.TheInternet
6+
namespace Aquality.Selenium.Tests.Integration.TestApp.TheInternet.Forms
77
{
8-
public class AddRemoveElementsForm : Form
8+
internal class AddRemoveElementsForm : Form
99
{
1010
private static readonly By FormLocator = By.XPath("//h3[contains(.,'Add/Remove Elements')]");
1111
public IButton BtnAdd => ElementFactory.GetButton(By.XPath("//button[contains(@onclick,'addElement')]"), "Add element");
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
using Aquality.Selenium.Elements.Interfaces;
2+
using Aquality.Selenium.Forms;
3+
using OpenQA.Selenium;
4+
5+
namespace Aquality.Selenium.Tests.Integration.TestApp.TheInternet.Forms
6+
{
7+
internal class AuthenticationForm : Form
8+
{
9+
public AuthenticationForm() : base(By.Id("login"), "login")
10+
{
11+
}
12+
13+
public ITextBox UserNameTxb => ElementFactory.GetTextBox(By.Id("username"), "username");
14+
}
15+
}

0 commit comments

Comments
 (0)