diff --git a/samples/AndroidCoreSamples/BaseTestClass.cs b/samples/AndroidCoreSamples/BaseTestClass.cs
index b478c363..29d724aa 100644
--- a/samples/AndroidCoreSamples/BaseTestClass.cs
+++ b/samples/AndroidCoreSamples/BaseTestClass.cs
@@ -14,7 +14,7 @@ public virtual void Initialize()
AppManager.StartApp(
new AndroidAppManagerOptions(Path.Combine(Environment.CurrentDirectory, "Tools\\com.companyname.app2.apk"))
{
- LaunchAppiumServer = true,
+ LaunchAppiumServer = false,
DriverUri = "http://localhost:4723/wd/hub"
});
}
diff --git a/samples/W3SchoolsWebTests/BaseTestClass.cs b/samples/W3SchoolsWebTests/BaseTestClass.cs
index a09c5a47..f415b3c6 100644
--- a/samples/W3SchoolsWebTests/BaseTestClass.cs
+++ b/samples/W3SchoolsWebTests/BaseTestClass.cs
@@ -1,25 +1,24 @@
namespace W3SchoolsWebTests
{
using System;
- using System.IO;
using Legerity;
- using Legerity.Web;
using NUnit.Framework;
using OpenQA.Selenium;
- public abstract class BaseTestClass
+ public abstract class BaseTestClass : LegerityTestClass
{
- public abstract string Url { get; }
+ ///
+ /// Initializes a new instance of the class with application launch option.
+ ///
+ /// The application launch options.
+ protected BaseTestClass(AppManagerOptions options) : base(options)
+ {
+ }
[SetUp]
public virtual void Initialize()
{
- AppManager.StartApp(
- new WebAppManagerOptions(WebAppDriverType.EdgeChromium, Environment.CurrentDirectory)
- {
- Maximize = true,
- Url = this.Url
- });
+ base.StartApp();
try
{
@@ -37,7 +36,7 @@ public virtual void Initialize()
[TearDown]
public virtual void Cleanup()
{
- AppManager.StopApp();
+ base.StopApp();
}
}
}
\ No newline at end of file
diff --git a/samples/W3SchoolsWebTests/Tests/ButtonTests.cs b/samples/W3SchoolsWebTests/Tests/ButtonTests.cs
index 0b23ebe6..53ce97b3 100644
--- a/samples/W3SchoolsWebTests/Tests/ButtonTests.cs
+++ b/samples/W3SchoolsWebTests/Tests/ButtonTests.cs
@@ -1,15 +1,39 @@
namespace W3SchoolsWebTests.Tests
{
+ using System;
+ using System.Collections.Generic;
+ using System.IO;
using Legerity;
+ using Legerity.Web;
using Legerity.Web.Elements.Core;
using NUnit.Framework;
using OpenQA.Selenium.Remote;
using W3SchoolsWebTests;
- [TestFixture]
+ [TestFixtureSource(nameof(TestPlatformOptions))]
public class ButtonTests : BaseTestClass
{
- public override string Url => "https://www.w3schools.com/tags/tryit.asp?filename=tryhtml_button_test";
+ private const string Url = "https://www.w3schools.com/tags/tryit.asp?filename=tryhtml_button_test";
+
+ public ButtonTests(AppManagerOptions options) : base(options)
+ {
+ }
+
+ static IEnumerable TestPlatformOptions => new List
+ {
+ new WebAppManagerOptions(
+ WebAppDriverType.EdgeChromium,
+ Path.Combine(Environment.CurrentDirectory))
+ {
+ Maximize = true, Url = Url, ImplicitWait = TimeSpan.FromSeconds(10)
+ },
+ new WebAppManagerOptions(
+ WebAppDriverType.Chrome,
+ Path.Combine(Environment.CurrentDirectory))
+ {
+ Maximize = true, Url = Url, ImplicitWait = TimeSpan.FromSeconds(10)
+ }
+ };
[Test]
public void ShouldClickButton()
diff --git a/samples/W3SchoolsWebTests/Tests/CheckBoxTests.cs b/samples/W3SchoolsWebTests/Tests/CheckBoxTests.cs
index 88866b8d..232ffc26 100644
--- a/samples/W3SchoolsWebTests/Tests/CheckBoxTests.cs
+++ b/samples/W3SchoolsWebTests/Tests/CheckBoxTests.cs
@@ -1,16 +1,40 @@
namespace W3SchoolsWebTests.Tests
{
+ using System;
+ using System.Collections.Generic;
+ using System.IO;
using Legerity;
+ using Legerity.Web;
using Legerity.Web.Elements.Core;
using NUnit.Framework;
using OpenQA.Selenium.Remote;
using Shouldly;
using W3SchoolsWebTests;
- [TestFixture]
+ [TestFixtureSource(nameof(TestPlatformOptions))]
public class CheckBoxTests : BaseTestClass
{
- public override string Url => "https://www.w3schools.com/tags/tryit.asp?filename=tryhtml5_input_type_checkbox";
+ private const string Url = "https://www.w3schools.com/tags/tryit.asp?filename=tryhtml5_input_type_checkbox";
+
+ public CheckBoxTests(AppManagerOptions options) : base(options)
+ {
+ }
+
+ static IEnumerable TestPlatformOptions => new List
+ {
+ new WebAppManagerOptions(
+ WebAppDriverType.EdgeChromium,
+ Path.Combine(Environment.CurrentDirectory))
+ {
+ Maximize = true, Url = Url, ImplicitWait = TimeSpan.FromSeconds(10)
+ },
+ new WebAppManagerOptions(
+ WebAppDriverType.Chrome,
+ Path.Combine(Environment.CurrentDirectory))
+ {
+ Maximize = true, Url = Url, ImplicitWait = TimeSpan.FromSeconds(10)
+ }
+ };
[TestCase("vehicle1")]
[TestCase("vehicle2")]
diff --git a/samples/W3SchoolsWebTests/Tests/FileInputTests.cs b/samples/W3SchoolsWebTests/Tests/FileInputTests.cs
index 300c0d7d..36c47fb4 100644
--- a/samples/W3SchoolsWebTests/Tests/FileInputTests.cs
+++ b/samples/W3SchoolsWebTests/Tests/FileInputTests.cs
@@ -1,18 +1,40 @@
namespace W3SchoolsWebTests.Tests
{
using System;
+ using System.Collections.Generic;
using System.IO;
using Legerity;
+ using Legerity.Web;
using Legerity.Web.Elements.Core;
using NUnit.Framework;
using OpenQA.Selenium.Remote;
using Shouldly;
using W3SchoolsWebTests;
- [TestFixture]
+ [TestFixtureSource(nameof(TestPlatformOptions))]
public class FileInputTests : BaseTestClass
{
- public override string Url => "https://www.w3schools.com/tags/tryit.asp?filename=tryhtml5_input_type_file";
+ private const string Url = "https://www.w3schools.com/tags/tryit.asp?filename=tryhtml5_input_type_file";
+
+ public FileInputTests(AppManagerOptions options) : base(options)
+ {
+ }
+
+ static IEnumerable TestPlatformOptions => new List
+ {
+ new WebAppManagerOptions(
+ WebAppDriverType.EdgeChromium,
+ Path.Combine(Environment.CurrentDirectory))
+ {
+ Maximize = true, Url = Url, ImplicitWait = TimeSpan.FromSeconds(10)
+ },
+ new WebAppManagerOptions(
+ WebAppDriverType.Chrome,
+ Path.Combine(Environment.CurrentDirectory))
+ {
+ Maximize = true, Url = Url, ImplicitWait = TimeSpan.FromSeconds(10)
+ }
+ };
[Test]
public void ShouldSetAbsoluteFilePath()
diff --git a/samples/W3SchoolsWebTests/Tests/ImageTests.cs b/samples/W3SchoolsWebTests/Tests/ImageTests.cs
index 7ad73625..d3c176bb 100644
--- a/samples/W3SchoolsWebTests/Tests/ImageTests.cs
+++ b/samples/W3SchoolsWebTests/Tests/ImageTests.cs
@@ -1,16 +1,40 @@
namespace W3SchoolsWebTests.Tests
{
+ using System;
+ using System.Collections.Generic;
+ using System.IO;
using Legerity;
+ using Legerity.Web;
using Legerity.Web.Elements.Core;
using NUnit.Framework;
using OpenQA.Selenium.Remote;
using Shouldly;
using W3SchoolsWebTests;
- [TestFixture]
+ [TestFixtureSource(nameof(TestPlatformOptions))]
public class ImageTests : BaseTestClass
{
- public override string Url => "https://www.w3schools.com/tags/tryit.asp?filename=tryhtml_image_test";
+ private const string Url = "https://www.w3schools.com/tags/tryit.asp?filename=tryhtml_image_test";
+
+ public ImageTests(AppManagerOptions options) : base(options)
+ {
+ }
+
+ static IEnumerable TestPlatformOptions => new List
+ {
+ new WebAppManagerOptions(
+ WebAppDriverType.EdgeChromium,
+ Path.Combine(Environment.CurrentDirectory))
+ {
+ Maximize = true, Url = Url, ImplicitWait = TimeSpan.FromSeconds(10)
+ },
+ new WebAppManagerOptions(
+ WebAppDriverType.Chrome,
+ Path.Combine(Environment.CurrentDirectory))
+ {
+ Maximize = true, Url = Url, ImplicitWait = TimeSpan.FromSeconds(10)
+ }
+ };
[Test]
public void ShouldGetImageSource()
diff --git a/samples/W3SchoolsWebTests/Tests/NumberInputTests.cs b/samples/W3SchoolsWebTests/Tests/NumberInputTests.cs
index 1ba18ed6..f397445d 100644
--- a/samples/W3SchoolsWebTests/Tests/NumberInputTests.cs
+++ b/samples/W3SchoolsWebTests/Tests/NumberInputTests.cs
@@ -1,16 +1,40 @@
namespace W3SchoolsWebTests.Tests
{
+ using System;
+ using System.Collections.Generic;
+ using System.IO;
using Legerity;
+ using Legerity.Web;
using Legerity.Web.Elements.Core;
using NUnit.Framework;
using OpenQA.Selenium.Remote;
using Shouldly;
using W3SchoolsWebTests;
- [TestFixture]
+ [TestFixtureSource(nameof(TestPlatformOptions))]
public class NumberInputTests : BaseTestClass
{
- public override string Url => "https://www.w3schools.com/html/tryit.asp?filename=tryhtml_input_number";
+ private const string Url = "https://www.w3schools.com/html/tryit.asp?filename=tryhtml_input_number";
+
+ public NumberInputTests(AppManagerOptions options) : base(options)
+ {
+ }
+
+ static IEnumerable TestPlatformOptions => new List
+ {
+ new WebAppManagerOptions(
+ WebAppDriverType.EdgeChromium,
+ Path.Combine(Environment.CurrentDirectory))
+ {
+ Maximize = true, Url = Url, ImplicitWait = TimeSpan.FromSeconds(10)
+ },
+ new WebAppManagerOptions(
+ WebAppDriverType.Chrome,
+ Path.Combine(Environment.CurrentDirectory))
+ {
+ Maximize = true, Url = Url, ImplicitWait = TimeSpan.FromSeconds(10)
+ }
+ };
[Test]
public void ShouldGetValueRange()
diff --git a/samples/W3SchoolsWebTests/Tests/OrderedListTests.cs b/samples/W3SchoolsWebTests/Tests/OrderedListTests.cs
index d485ebe6..e6936957 100644
--- a/samples/W3SchoolsWebTests/Tests/OrderedListTests.cs
+++ b/samples/W3SchoolsWebTests/Tests/OrderedListTests.cs
@@ -1,9 +1,12 @@
namespace W3SchoolsWebTests.Tests
{
+ using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
+ using System.IO;
using System.Linq;
using Legerity;
+ using Legerity.Web;
using NUnit.Framework;
using OpenQA.Selenium;
using OpenQA.Selenium.Remote;
@@ -11,10 +14,30 @@ namespace W3SchoolsWebTests.Tests
using W3SchoolsWebTests;
using List = Legerity.Web.Elements.Core.List;
- [TestFixture]
+ [TestFixtureSource(nameof(TestPlatformOptions))]
public class OrderedListTests : BaseTestClass
{
- public override string Url => "https://www.w3schools.com/tags/tryit.asp?filename=tryhtml_lists";
+ private const string Url = "https://www.w3schools.com/tags/tryit.asp?filename=tryhtml_lists";
+
+ public OrderedListTests(AppManagerOptions options) : base(options)
+ {
+ }
+
+ static IEnumerable TestPlatformOptions => new List
+ {
+ new WebAppManagerOptions(
+ WebAppDriverType.EdgeChromium,
+ Path.Combine(Environment.CurrentDirectory))
+ {
+ Maximize = true, Url = Url, ImplicitWait = TimeSpan.FromSeconds(10)
+ },
+ new WebAppManagerOptions(
+ WebAppDriverType.Chrome,
+ Path.Combine(Environment.CurrentDirectory))
+ {
+ Maximize = true, Url = Url, ImplicitWait = TimeSpan.FromSeconds(10)
+ }
+ };
[Test]
public void ShouldContainItems()
diff --git a/samples/W3SchoolsWebTests/Tests/RadioButtonTests.cs b/samples/W3SchoolsWebTests/Tests/RadioButtonTests.cs
index 3e5c7bdf..0ef54d3e 100644
--- a/samples/W3SchoolsWebTests/Tests/RadioButtonTests.cs
+++ b/samples/W3SchoolsWebTests/Tests/RadioButtonTests.cs
@@ -1,8 +1,12 @@
namespace W3SchoolsWebTests.Tests
{
+ using System;
+ using System.Collections.Generic;
using System.Collections.ObjectModel;
+ using System.IO;
using System.Linq;
using Legerity;
+ using Legerity.Web;
using Legerity.Web.Elements.Core;
using NUnit.Framework;
using OpenQA.Selenium;
@@ -10,10 +14,30 @@ namespace W3SchoolsWebTests.Tests
using Shouldly;
using W3SchoolsWebTests;
- [TestFixture]
+ [TestFixtureSource(nameof(TestPlatformOptions))]
public class RadioButtonTests : BaseTestClass
{
- public override string Url => "https://www.w3schools.com/tags/tryit.asp?filename=tryhtml5_input_type_radio";
+ private const string Url = "https://www.w3schools.com/tags/tryit.asp?filename=tryhtml5_input_type_radio";
+
+ public RadioButtonTests(AppManagerOptions options) : base(options)
+ {
+ }
+
+ static IEnumerable TestPlatformOptions => new List
+ {
+ new WebAppManagerOptions(
+ WebAppDriverType.EdgeChromium,
+ Path.Combine(Environment.CurrentDirectory))
+ {
+ Maximize = true, Url = Url, ImplicitWait = TimeSpan.FromSeconds(10)
+ },
+ new WebAppManagerOptions(
+ WebAppDriverType.Chrome,
+ Path.Combine(Environment.CurrentDirectory))
+ {
+ Maximize = true, Url = Url, ImplicitWait = TimeSpan.FromSeconds(10)
+ }
+ };
[TestCase("html")]
[TestCase("css")]
diff --git a/samples/W3SchoolsWebTests/Tests/RangeInputTests.cs b/samples/W3SchoolsWebTests/Tests/RangeInputTests.cs
index d909860c..e527d480 100644
--- a/samples/W3SchoolsWebTests/Tests/RangeInputTests.cs
+++ b/samples/W3SchoolsWebTests/Tests/RangeInputTests.cs
@@ -1,16 +1,40 @@
namespace W3SchoolsWebTests.Tests
{
+ using System;
+ using System.Collections.Generic;
+ using System.IO;
using Legerity;
+ using Legerity.Web;
using Legerity.Web.Elements.Core;
using NUnit.Framework;
using OpenQA.Selenium.Remote;
using Shouldly;
using W3SchoolsWebTests;
- [TestFixture]
+ [TestFixtureSource(nameof(TestPlatformOptions))]
public class RangeInputTests : BaseTestClass
{
- public override string Url => "https://www.w3schools.com/tags/tryit.asp?filename=tryhtml5_input_type_range";
+ private const string Url = "https://www.w3schools.com/tags/tryit.asp?filename=tryhtml5_input_type_range";
+
+ public RangeInputTests(AppManagerOptions options) : base(options)
+ {
+ }
+
+ static IEnumerable TestPlatformOptions => new List
+ {
+ new WebAppManagerOptions(
+ WebAppDriverType.EdgeChromium,
+ Path.Combine(Environment.CurrentDirectory))
+ {
+ Maximize = true, Url = Url, ImplicitWait = TimeSpan.FromSeconds(10)
+ },
+ new WebAppManagerOptions(
+ WebAppDriverType.Chrome,
+ Path.Combine(Environment.CurrentDirectory))
+ {
+ Maximize = true, Url = Url, ImplicitWait = TimeSpan.FromSeconds(10)
+ }
+ };
[Test]
public void ShouldGetValueRange()
diff --git a/samples/W3SchoolsWebTests/Tests/SelectTests.cs b/samples/W3SchoolsWebTests/Tests/SelectTests.cs
index 06da223c..143e0d03 100644
--- a/samples/W3SchoolsWebTests/Tests/SelectTests.cs
+++ b/samples/W3SchoolsWebTests/Tests/SelectTests.cs
@@ -1,17 +1,41 @@
namespace W3SchoolsWebTests.Tests
{
+ using System;
+ using System.Collections.Generic;
+ using System.IO;
using System.Linq;
using Legerity;
+ using Legerity.Web;
using Legerity.Web.Elements.Core;
using NUnit.Framework;
using OpenQA.Selenium.Remote;
using Shouldly;
using W3SchoolsWebTests;
- [TestFixture]
+ [TestFixtureSource(nameof(TestPlatformOptions))]
public class SelectTests : BaseTestClass
{
- public override string Url => "https://www.w3schools.com/tags/tryit.asp?filename=tryhtml_select";
+ private const string Url = "https://www.w3schools.com/tags/tryit.asp?filename=tryhtml_select";
+
+ public SelectTests(AppManagerOptions options) : base(options)
+ {
+ }
+
+ static IEnumerable TestPlatformOptions => new List
+ {
+ new WebAppManagerOptions(
+ WebAppDriverType.EdgeChromium,
+ Path.Combine(Environment.CurrentDirectory))
+ {
+ Maximize = true, Url = Url, ImplicitWait = TimeSpan.FromSeconds(10)
+ },
+ new WebAppManagerOptions(
+ WebAppDriverType.Chrome,
+ Path.Combine(Environment.CurrentDirectory))
+ {
+ Maximize = true, Url = Url, ImplicitWait = TimeSpan.FromSeconds(10)
+ }
+ };
[Test]
public void ShouldGetItems()
diff --git a/samples/W3SchoolsWebTests/Tests/TableTests.cs b/samples/W3SchoolsWebTests/Tests/TableTests.cs
index 351e9365..961fc07b 100644
--- a/samples/W3SchoolsWebTests/Tests/TableTests.cs
+++ b/samples/W3SchoolsWebTests/Tests/TableTests.cs
@@ -1,18 +1,41 @@
namespace W3SchoolsWebTests.Tests
{
+ using System;
using System.Collections.Generic;
+ using System.IO;
using System.Linq;
using Legerity;
using Legerity.Extensions;
+ using Legerity.Web;
using Legerity.Web.Elements.Core;
using NUnit.Framework;
using OpenQA.Selenium;
using Shouldly;
- [TestFixture]
+ [TestFixtureSource(nameof(TestPlatformOptions))]
public class TableTests : BaseTestClass
{
- public override string Url => "https://www.w3schools.com/html/tryit.asp?filename=tryhtml_table_intro";
+ private const string Url = "https://www.w3schools.com/html/tryit.asp?filename=tryhtml_table_intro";
+
+ public TableTests(AppManagerOptions options) : base(options)
+ {
+ }
+
+ static IEnumerable TestPlatformOptions => new List
+ {
+ new WebAppManagerOptions(
+ WebAppDriverType.EdgeChromium,
+ Path.Combine(Environment.CurrentDirectory))
+ {
+ Maximize = true, Url = Url, ImplicitWait = TimeSpan.FromSeconds(10)
+ },
+ new WebAppManagerOptions(
+ WebAppDriverType.Chrome,
+ Path.Combine(Environment.CurrentDirectory))
+ {
+ Maximize = true, Url = Url, ImplicitWait = TimeSpan.FromSeconds(10)
+ }
+ };
[Test]
public void ShouldGetHeaders()
diff --git a/samples/W3SchoolsWebTests/Tests/TextAreaTests.cs b/samples/W3SchoolsWebTests/Tests/TextAreaTests.cs
index db3dbbfa..4883b8b7 100644
--- a/samples/W3SchoolsWebTests/Tests/TextAreaTests.cs
+++ b/samples/W3SchoolsWebTests/Tests/TextAreaTests.cs
@@ -1,16 +1,40 @@
namespace W3SchoolsWebTests.Tests
{
+ using System;
+ using System.Collections.Generic;
+ using System.IO;
using Legerity;
+ using Legerity.Web;
using Legerity.Web.Elements.Core;
using NUnit.Framework;
using OpenQA.Selenium.Remote;
using Shouldly;
using W3SchoolsWebTests;
- [TestFixture]
+ [TestFixtureSource(nameof(TestPlatformOptions))]
public class TextAreaTests : BaseTestClass
{
- public override string Url => "https://www.w3schools.com/tags/tryit.asp?filename=tryhtml_textarea";
+ private const string Url = "https://www.w3schools.com/tags/tryit.asp?filename=tryhtml_textarea";
+
+ public TextAreaTests(AppManagerOptions options) : base(options)
+ {
+ }
+
+ static IEnumerable TestPlatformOptions => new List
+ {
+ new WebAppManagerOptions(
+ WebAppDriverType.EdgeChromium,
+ Path.Combine(Environment.CurrentDirectory))
+ {
+ Maximize = true, Url = Url, ImplicitWait = TimeSpan.FromSeconds(10)
+ },
+ new WebAppManagerOptions(
+ WebAppDriverType.Chrome,
+ Path.Combine(Environment.CurrentDirectory))
+ {
+ Maximize = true, Url = Url, ImplicitWait = TimeSpan.FromSeconds(10)
+ }
+ };
[Test]
public void ShouldSetText()
diff --git a/samples/W3SchoolsWebTests/Tests/TextInputTests.cs b/samples/W3SchoolsWebTests/Tests/TextInputTests.cs
index 4f463736..0982b506 100644
--- a/samples/W3SchoolsWebTests/Tests/TextInputTests.cs
+++ b/samples/W3SchoolsWebTests/Tests/TextInputTests.cs
@@ -1,16 +1,40 @@
namespace W3SchoolsWebTests.Tests
{
+ using System;
+ using System.Collections.Generic;
+ using System.IO;
using Legerity;
+ using Legerity.Web;
using Legerity.Web.Elements.Core;
using NUnit.Framework;
using OpenQA.Selenium.Remote;
using Shouldly;
using W3SchoolsWebTests;
- [TestFixture]
+ [TestFixtureSource(nameof(TestPlatformOptions))]
public class TextInputTests : BaseTestClass
{
- public override string Url => "https://www.w3schools.com/html/tryit.asp?filename=tryhtml_input_text";
+ private const string Url = "https://www.w3schools.com/html/tryit.asp?filename=tryhtml_input_text";
+
+ public TextInputTests(AppManagerOptions options) : base(options)
+ {
+ }
+
+ static IEnumerable TestPlatformOptions => new List
+ {
+ new WebAppManagerOptions(
+ WebAppDriverType.EdgeChromium,
+ Path.Combine(Environment.CurrentDirectory))
+ {
+ Maximize = true, Url = Url, ImplicitWait = TimeSpan.FromSeconds(10)
+ },
+ new WebAppManagerOptions(
+ WebAppDriverType.Chrome,
+ Path.Combine(Environment.CurrentDirectory))
+ {
+ Maximize = true, Url = Url, ImplicitWait = TimeSpan.FromSeconds(10)
+ }
+ };
[Test]
public void ShouldSetText()
diff --git a/samples/W3SchoolsWebTests/Tests/UnorderedListTests.cs b/samples/W3SchoolsWebTests/Tests/UnorderedListTests.cs
index 78cfaded..e81a9d49 100644
--- a/samples/W3SchoolsWebTests/Tests/UnorderedListTests.cs
+++ b/samples/W3SchoolsWebTests/Tests/UnorderedListTests.cs
@@ -1,9 +1,12 @@
namespace W3SchoolsWebTests.Tests
{
+ using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
+ using System.IO;
using System.Linq;
using Legerity;
+ using Legerity.Web;
using NUnit.Framework;
using OpenQA.Selenium;
using OpenQA.Selenium.Remote;
@@ -11,10 +14,30 @@ namespace W3SchoolsWebTests.Tests
using W3SchoolsWebTests;
using List = Legerity.Web.Elements.Core.List;
- [TestFixture]
+ [TestFixtureSource(nameof(TestPlatformOptions))]
public class UnorderedListTests : BaseTestClass
{
- public override string Url => "https://www.w3schools.com/tags/tryit.asp?filename=tryhtml_lists4";
+ private const string Url = "https://www.w3schools.com/tags/tryit.asp?filename=tryhtml_lists4";
+
+ public UnorderedListTests(AppManagerOptions options) : base(options)
+ {
+ }
+
+ static IEnumerable TestPlatformOptions => new List
+ {
+ new WebAppManagerOptions(
+ WebAppDriverType.EdgeChromium,
+ Path.Combine(Environment.CurrentDirectory))
+ {
+ Maximize = true, Url = Url, ImplicitWait = TimeSpan.FromSeconds(10)
+ },
+ new WebAppManagerOptions(
+ WebAppDriverType.Chrome,
+ Path.Combine(Environment.CurrentDirectory))
+ {
+ Maximize = true, Url = Url, ImplicitWait = TimeSpan.FromSeconds(10)
+ }
+ };
[Test]
public void ShouldContainItems()
diff --git a/samples/W3SchoolsWebTests/W3SchoolsWebTests.csproj b/samples/W3SchoolsWebTests/W3SchoolsWebTests.csproj
index deb68303..c6c29b7f 100644
--- a/samples/W3SchoolsWebTests/W3SchoolsWebTests.csproj
+++ b/samples/W3SchoolsWebTests/W3SchoolsWebTests.csproj
@@ -11,6 +11,7 @@
+
diff --git a/samples/WindowsAlarmsAndClock/Pages/AlarmPage.cs b/samples/WindowsAlarmsAndClock/Pages/AlarmPage.cs
index d3325418..b77e94a5 100644
--- a/samples/WindowsAlarmsAndClock/Pages/AlarmPage.cs
+++ b/samples/WindowsAlarmsAndClock/Pages/AlarmPage.cs
@@ -5,14 +5,12 @@ namespace WindowsAlarmsAndClock.Pages
using System.Linq;
using Elements;
using Legerity.Extensions;
- using Legerity.Pages;
using Legerity.Windows.Extensions;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using OpenQA.Selenium;
using OpenQA.Selenium.Appium;
- using OpenQA.Selenium.Remote;
///
/// Defines the alarm page of the Windows Alarms & Clock application.
diff --git a/src/Legerity.Android/Extensions/AndroidElementWrapperExtensions.cs b/src/Legerity.Android/Extensions/AndroidElementWrapperExtensions.cs
new file mode 100644
index 00000000..06451eb9
--- /dev/null
+++ b/src/Legerity.Android/Extensions/AndroidElementWrapperExtensions.cs
@@ -0,0 +1,36 @@
+namespace Legerity.Android.Extensions
+{
+ using System;
+ using Legerity.Android.Elements;
+ using OpenQA.Selenium;
+ using OpenQA.Selenium.Support.UI;
+
+ ///
+ /// Defines a collection of extensions for objects.
+ ///
+ public static class AndroidElementWrapperExtensions
+ {
+ ///
+ /// Waits until a specified element condition is met, with an optional timeout.
+ ///
+ /// The element to wait on.
+ /// The condition of the element to wait on.
+ /// The optional timeout wait on the condition being true.
+ /// The type of .
+ public static void WaitUntil(this TElementWrapper element, Func condition, TimeSpan? timeout = default)
+ where TElementWrapper : AndroidElementWrapper
+ {
+ new WebDriverWait(AppManager.App, timeout ?? TimeSpan.Zero).Until(driver =>
+ {
+ try
+ {
+ return condition(element);
+ }
+ catch (StaleElementReferenceException)
+ {
+ return false;
+ }
+ });
+ }
+ }
+}
diff --git a/src/Legerity.Core/Android/AndroidAppManagerOptions.cs b/src/Legerity.Core/Android/AndroidAppManagerOptions.cs
index 5051415b..b1740f89 100644
--- a/src/Legerity.Core/Android/AndroidAppManagerOptions.cs
+++ b/src/Legerity.Core/Android/AndroidAppManagerOptions.cs
@@ -174,7 +174,7 @@ public AndroidAppManagerOptions(
this.OSVersion = osVersion;
this.DeviceName = deviceName;
this.DeviceId = deviceId;
- this.Configure(additionalOptions);
+ this.AdditionalOptions = additionalOptions;
}
///
@@ -213,59 +213,55 @@ public AndroidAppManagerOptions(
public bool LaunchAppiumServer { get; set; }
///
- /// Configures the with the specified additional options.
- ///
- /// By default, the will be added to the options as capability 'app'.
- ///
+ /// Configures the with the specified additional options.
///
- ///
- /// The additional options to apply to the .
- ///
- public void Configure((string, object)[] additionalOptions)
+ public override void Configure()
{
- var options = new AppiumOptions();
+ base.Configure();
- options.AddAdditionalCapability(MobileCapabilityType.PlatformName, "Android");
+ this.AppiumOptions.AddAdditionalCapability(MobileCapabilityType.PlatformName, "Android");
if (!string.IsNullOrWhiteSpace(this.OSVersion))
{
- options.AddAdditionalCapability(MobileCapabilityType.PlatformVersion, this.OSVersion);
+ this.AppiumOptions.AddAdditionalCapability(MobileCapabilityType.PlatformVersion, this.OSVersion);
}
if (!string.IsNullOrWhiteSpace(this.DeviceName))
{
- options.AddAdditionalCapability(MobileCapabilityType.DeviceName, this.DeviceName);
+ this.AppiumOptions.AddAdditionalCapability(MobileCapabilityType.DeviceName, this.DeviceName);
}
if (!string.IsNullOrWhiteSpace(this.DeviceId))
{
- options.AddAdditionalCapability(MobileCapabilityType.Udid, this.DeviceId);
+ this.AppiumOptions.AddAdditionalCapability(MobileCapabilityType.Udid, this.DeviceId);
}
if (!string.IsNullOrWhiteSpace(this.AppId))
{
- options.AddAdditionalCapability("appPackage", this.AppId);
+ this.AppiumOptions.AddAdditionalCapability("appPackage", this.AppId);
}
if (!string.IsNullOrWhiteSpace(this.AppActivity))
{
- options.AddAdditionalCapability("appActivity", this.AppActivity);
+ this.AppiumOptions.AddAdditionalCapability("appActivity", this.AppActivity);
}
if (!string.IsNullOrWhiteSpace(this.AppPath))
{
- options.AddAdditionalCapability("app", this.AppPath);
- }
-
- if (additionalOptions != null)
- {
- foreach ((string capabilityName, object capabilityValue) in additionalOptions)
- {
- options.AddAdditionalCapability(capabilityName, capabilityValue);
- }
+ this.AppiumOptions.AddAdditionalCapability("app", this.AppPath);
}
+ }
- this.AppiumOptions = options;
+ ///
+ /// Configures the with the specified additional options.
+ ///
+ ///
+ /// The additional options to apply to the .
+ ///
+ public void Configure((string, object)[] additionalOptions)
+ {
+ this.AdditionalOptions = additionalOptions;
+ this.Configure();
}
/// Returns a string that represents the current object.
@@ -299,6 +295,14 @@ private string GetOptionDetails()
options.Add($"Device Name [{this.DeviceName}]");
}
+ if (this.AdditionalOptions != null)
+ {
+ foreach ((string name, object value) in this.AdditionalOptions)
+ {
+ options.Add($"{name} [{value}]");
+ }
+ }
+
return string.Join(", ", options);
}
}
diff --git a/src/Legerity.Core/AppManager.cs b/src/Legerity.Core/AppManager.cs
index e8d29781..2dc9ec34 100644
--- a/src/Legerity.Core/AppManager.cs
+++ b/src/Legerity.Core/AppManager.cs
@@ -80,6 +80,11 @@ public static void StartApp(AppManagerOptions opts, Func waitU
{
StopApp();
+ if (opts is AppiumManagerOptions appiumOpts)
+ {
+ appiumOpts.Configure();
+ }
+
switch (opts)
{
case WebAppManagerOptions webOpts:
diff --git a/src/Legerity.Core/AppiumManagerOptions.cs b/src/Legerity.Core/AppiumManagerOptions.cs
index d40c2091..cddf82b4 100644
--- a/src/Legerity.Core/AppiumManagerOptions.cs
+++ b/src/Legerity.Core/AppiumManagerOptions.cs
@@ -7,13 +7,40 @@ namespace Legerity
///
public abstract class AppiumManagerOptions : AppManagerOptions
{
+ ///
+ /// Gets or sets the additional options to apply to the .
+ ///
+ public (string, object)[] AdditionalOptions { get; set; }
+
///
/// Gets or sets the options to configure the Appium driver.
+ ///
+ /// This property is null until the method is called.
+ /// is called automatically when calling the method.
+ ///
///
public AppiumOptions AppiumOptions
{
get => this.DriverOptions as AppiumOptions;
set => this.DriverOptions = value;
}
+
+ ///
+ /// Configures the with the specified additional options.
+ ///
+ public virtual void Configure()
+ {
+ this.AppiumOptions = new AppiumOptions();
+
+ if (this.AdditionalOptions == null)
+ {
+ return;
+ }
+
+ foreach ((string capabilityName, object capabilityValue) in this.AdditionalOptions)
+ {
+ this.AppiumOptions.AddAdditionalCapability(capabilityName, capabilityValue);
+ }
+ }
}
-}
+}
\ No newline at end of file
diff --git a/src/Legerity.Core/IOS/IOSAppManagerOptions.cs b/src/Legerity.Core/IOS/IOSAppManagerOptions.cs
index bf732ce7..80733b52 100644
--- a/src/Legerity.Core/IOS/IOSAppManagerOptions.cs
+++ b/src/Legerity.Core/IOS/IOSAppManagerOptions.cs
@@ -58,7 +58,7 @@ public IOSAppManagerOptions(
this.OSVersion = osVersion;
this.DeviceName = deviceName;
this.DeviceId = deviceId;
- this.Configure(additionalOptions);
+ this.AdditionalOptions = additionalOptions;
}
///
@@ -86,34 +86,30 @@ public IOSAppManagerOptions(
///
public bool LaunchAppiumServer { get; set; }
+ ///
+ /// Configures the with the specified additional options.
+ ///
+ public override void Configure()
+ {
+ base.Configure();
+
+ this.AppiumOptions.AddAdditionalCapability(MobileCapabilityType.PlatformName, "iOS");
+ this.AppiumOptions.AddAdditionalCapability(MobileCapabilityType.PlatformVersion, this.OSVersion);
+ this.AppiumOptions.AddAdditionalCapability(MobileCapabilityType.DeviceName, this.DeviceName);
+ this.AppiumOptions.AddAdditionalCapability(MobileCapabilityType.Udid, this.DeviceId);
+ this.AppiumOptions.AddAdditionalCapability(MobileCapabilityType.App, this.AppId);
+ }
+
///
/// Configures the with the specified additional options.
- ///
- /// By default, the will be added to the options as capability 'app'.
- ///
///
///
/// The additional options to apply to the .
///
public void Configure((string, object)[] additionalOptions)
{
- var options = new AppiumOptions();
-
- options.AddAdditionalCapability(MobileCapabilityType.PlatformName, "iOS");
- options.AddAdditionalCapability(MobileCapabilityType.PlatformVersion, this.OSVersion);
- options.AddAdditionalCapability(MobileCapabilityType.DeviceName, this.DeviceName);
- options.AddAdditionalCapability(MobileCapabilityType.Udid, this.DeviceId);
- options.AddAdditionalCapability(MobileCapabilityType.App, this.AppId);
-
- if (additionalOptions != null)
- {
- foreach ((string capabilityName, object capabilityValue) in additionalOptions)
- {
- options.AddAdditionalCapability(capabilityName, capabilityValue);
- }
- }
-
- this.AppiumOptions = options;
+ this.AdditionalOptions = additionalOptions;
+ this.Configure();
}
/// Returns a string that represents the current object.
@@ -142,6 +138,14 @@ private string GetOptionDetails()
options.Add($"Device Name [{this.DeviceName}]");
}
+ if (this.AdditionalOptions != null)
+ {
+ foreach ((string name, object value) in this.AdditionalOptions)
+ {
+ options.Add($"{name} [{value}]");
+ }
+ }
+
return string.Join(", ", options);
}
}
diff --git a/src/Legerity.Core/LegerityTestClass.cs b/src/Legerity.Core/LegerityTestClass.cs
new file mode 100644
index 00000000..d859b99d
--- /dev/null
+++ b/src/Legerity.Core/LegerityTestClass.cs
@@ -0,0 +1,61 @@
+namespace Legerity
+{
+ using OpenQA.Selenium.Appium.Android;
+ using OpenQA.Selenium.Appium.iOS;
+ using OpenQA.Selenium.Appium.Windows;
+ using OpenQA.Selenium.Remote;
+
+ ///
+ /// Defines a base class for running tests with the Legerity framework.
+ ///
+ public abstract class LegerityTestClass
+ {
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// The will need to be set before calling .
+ ///
+ ///
+ protected LegerityTestClass()
+ {
+ }
+
+ ///
+ /// Initializes a new instance of the class with application launch option.
+ ///
+ /// The application launch options.
+ protected LegerityTestClass(AppManagerOptions options)
+ {
+ this.Options = options;
+ }
+
+ ///
+ /// Gets the instance of the started application.
+ ///
+ /// This could be a , , , or web driver.
+ ///
+ ///
+ protected static RemoteWebDriver App => AppManager.App;
+
+ ///
+ /// Gets or sets the model that represents the configuration options for the .
+ ///
+ protected AppManagerOptions Options { get; set; }
+
+ ///
+ /// Starts the application ready for testing.
+ ///
+ public virtual void StartApp()
+ {
+ AppManager.StartApp(this.Options);
+ }
+
+ ///
+ /// Stops the application.
+ ///
+ public virtual void StopApp()
+ {
+ AppManager.StopApp();
+ }
+ }
+}
diff --git a/src/Legerity.Core/Windows/WindowsAppManagerOptions.cs b/src/Legerity.Core/Windows/WindowsAppManagerOptions.cs
index 446d6d02..cf1c2c1b 100644
--- a/src/Legerity.Core/Windows/WindowsAppManagerOptions.cs
+++ b/src/Legerity.Core/Windows/WindowsAppManagerOptions.cs
@@ -32,7 +32,7 @@ public WindowsAppManagerOptions(string appId)
public WindowsAppManagerOptions(string appId, params (string, object)[] additionalOptions)
{
this.AppId = appId;
- this.Configure(additionalOptions);
+ this.AdditionalOptions = additionalOptions;
}
///
@@ -58,29 +58,25 @@ public WindowsAppManagerOptions(string appId, params (string, object)[] addition
///
public string WinAppDriverPath { get; set; } = WinAppDriverHelper.DefaultInstallLocation;
+ ///
+ /// Configures the with the specified additional options.
+ ///
+ public override void Configure()
+ {
+ base.Configure();
+ this.AppiumOptions.AddAdditionalCapability("app", this.AppId);
+ }
+
///
/// Configures the with the specified additional options.
- ///
- /// By default, the will be added to the options as capability 'app'.
- ///
///
///
/// The additional options to apply to the .
///
public void Configure((string, object)[] additionalOptions)
{
- var options = new AppiumOptions();
- options.AddAdditionalCapability("app", this.AppId);
-
- if (additionalOptions != null)
- {
- foreach ((string capabilityName, object capabilityValue) in additionalOptions)
- {
- options.AddAdditionalCapability(capabilityName, capabilityValue);
- }
- }
-
- this.AppiumOptions = options;
+ this.AdditionalOptions = additionalOptions;
+ this.Configure();
}
/// Returns a string that represents the current object.
@@ -99,6 +95,14 @@ private string GetOptionDetails()
options.Add($"App ID [{this.AppId}]");
}
+ if (this.AdditionalOptions != null)
+ {
+ foreach ((string name, object value) in this.AdditionalOptions)
+ {
+ options.Add($"{name} [{value}]");
+ }
+ }
+
return string.Join(", ", options);
}
}
diff --git a/src/Legerity.IOS/Extensions/IOSElementWrapperExtensions.cs b/src/Legerity.IOS/Extensions/IOSElementWrapperExtensions.cs
new file mode 100644
index 00000000..8049741a
--- /dev/null
+++ b/src/Legerity.IOS/Extensions/IOSElementWrapperExtensions.cs
@@ -0,0 +1,36 @@
+namespace Legerity.IOS.Extensions
+{
+ using System;
+ using Legerity.IOS.Elements;
+ using OpenQA.Selenium;
+ using OpenQA.Selenium.Support.UI;
+
+ ///
+ /// Defines a collection of extensions for objects.
+ ///
+ public static class IOSElementWrapperExtensions
+ {
+ ///
+ /// Waits until a specified element condition is met, with an optional timeout.
+ ///
+ /// The element to wait on.
+ /// The condition of the element to wait on.
+ /// The optional timeout wait on the condition being true.
+ /// The type of .
+ public static void WaitUntil(this TElementWrapper element, Func condition, TimeSpan? timeout = default)
+ where TElementWrapper : IOSElementWrapper
+ {
+ new WebDriverWait(AppManager.App, timeout ?? TimeSpan.Zero).Until(driver =>
+ {
+ try
+ {
+ return condition(element);
+ }
+ catch (StaleElementReferenceException)
+ {
+ return false;
+ }
+ });
+ }
+ }
+}
diff --git a/src/Legerity.Web/Extensions/WebElementWrapperExtensions.cs b/src/Legerity.Web/Extensions/WebElementWrapperExtensions.cs
new file mode 100644
index 00000000..fa169ad6
--- /dev/null
+++ b/src/Legerity.Web/Extensions/WebElementWrapperExtensions.cs
@@ -0,0 +1,36 @@
+namespace Legerity.Web.Extensions
+{
+ using System;
+ using Legerity.Web.Elements;
+ using OpenQA.Selenium;
+ using OpenQA.Selenium.Support.UI;
+
+ ///
+ /// Defines a collection of extensions for objects.
+ ///
+ public static class WebElementWrapperExtensions
+ {
+ ///
+ /// Waits until a specified element condition is met, with an optional timeout.
+ ///
+ /// The element to wait on.
+ /// The condition of the element to wait on.
+ /// The optional timeout wait on the condition being true.
+ /// The type of .
+ public static void WaitUntil(this TElementWrapper element, Func condition, TimeSpan? timeout = default)
+ where TElementWrapper : WebElementWrapper
+ {
+ new WebDriverWait(AppManager.App, timeout ?? TimeSpan.Zero).Until(driver =>
+ {
+ try
+ {
+ return condition(element);
+ }
+ catch (StaleElementReferenceException)
+ {
+ return false;
+ }
+ });
+ }
+ }
+}
diff --git a/src/Legerity.Windows/Extensions/WindowsElementWrapperExtensions.cs b/src/Legerity.Windows/Extensions/WindowsElementWrapperExtensions.cs
new file mode 100644
index 00000000..d4259625
--- /dev/null
+++ b/src/Legerity.Windows/Extensions/WindowsElementWrapperExtensions.cs
@@ -0,0 +1,36 @@
+namespace Legerity.Windows.Extensions
+{
+ using System;
+ using Legerity.Windows.Elements;
+ using OpenQA.Selenium;
+ using OpenQA.Selenium.Support.UI;
+
+ ///
+ /// Defines a collection of extensions for objects.
+ ///
+ public static class WindowsElementWrapperExtensions
+ {
+ ///
+ /// Waits until a specified element condition is met, with an optional timeout.
+ ///
+ /// The element to wait on.
+ /// The condition of the element to wait on.
+ /// The optional timeout wait on the condition being true.
+ /// The type of .
+ public static void WaitUntil(this TElementWrapper element, Func condition, TimeSpan? timeout = default)
+ where TElementWrapper : WindowsElementWrapper
+ {
+ new WebDriverWait(AppManager.App, timeout ?? TimeSpan.Zero).Until(driver =>
+ {
+ try
+ {
+ return condition(element);
+ }
+ catch (StaleElementReferenceException)
+ {
+ return false;
+ }
+ });
+ }
+ }
+}