Skip to content

Commit

Permalink
Merge pull request #116 from MADE-Apps/feature/basetestclass
Browse files Browse the repository at this point in the history
Introduced LegerityTestClass & platform WaitUntil conditions
  • Loading branch information
jamesmcroft authored Mar 19, 2022
2 parents 4ec6358 + 1a72189 commit 05c21ee
Show file tree
Hide file tree
Showing 27 changed files with 658 additions and 104 deletions.
2 changes: 1 addition & 1 deletion samples/AndroidCoreSamples/BaseTestClass.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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"
});
}
Expand Down
21 changes: 10 additions & 11 deletions samples/W3SchoolsWebTests/BaseTestClass.cs
Original file line number Diff line number Diff line change
@@ -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; }
/// <summary>
/// Initializes a new instance of the <see cref="BaseTestClass"/> class with application launch option.
/// </summary>
/// <param name="options">The application launch options.</param>
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
{
Expand All @@ -37,7 +36,7 @@ public virtual void Initialize()
[TearDown]
public virtual void Cleanup()
{
AppManager.StopApp();
base.StopApp();
}
}
}
28 changes: 26 additions & 2 deletions samples/W3SchoolsWebTests/Tests/ButtonTests.cs
Original file line number Diff line number Diff line change
@@ -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<AppManagerOptions> TestPlatformOptions => new List<AppManagerOptions>
{
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()
Expand Down
28 changes: 26 additions & 2 deletions samples/W3SchoolsWebTests/Tests/CheckBoxTests.cs
Original file line number Diff line number Diff line change
@@ -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<AppManagerOptions> TestPlatformOptions => new List<AppManagerOptions>
{
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")]
Expand Down
26 changes: 24 additions & 2 deletions samples/W3SchoolsWebTests/Tests/FileInputTests.cs
Original file line number Diff line number Diff line change
@@ -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<AppManagerOptions> TestPlatformOptions => new List<AppManagerOptions>
{
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()
Expand Down
28 changes: 26 additions & 2 deletions samples/W3SchoolsWebTests/Tests/ImageTests.cs
Original file line number Diff line number Diff line change
@@ -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<AppManagerOptions> TestPlatformOptions => new List<AppManagerOptions>
{
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()
Expand Down
28 changes: 26 additions & 2 deletions samples/W3SchoolsWebTests/Tests/NumberInputTests.cs
Original file line number Diff line number Diff line change
@@ -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<AppManagerOptions> TestPlatformOptions => new List<AppManagerOptions>
{
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()
Expand Down
27 changes: 25 additions & 2 deletions samples/W3SchoolsWebTests/Tests/OrderedListTests.cs
Original file line number Diff line number Diff line change
@@ -1,20 +1,43 @@
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;
using Shouldly;
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<AppManagerOptions> TestPlatformOptions => new List<AppManagerOptions>
{
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()
Expand Down
28 changes: 26 additions & 2 deletions samples/W3SchoolsWebTests/Tests/RadioButtonTests.cs
Original file line number Diff line number Diff line change
@@ -1,19 +1,43 @@
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;
using OpenQA.Selenium.Remote;
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<AppManagerOptions> TestPlatformOptions => new List<AppManagerOptions>
{
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")]
Expand Down
Loading

0 comments on commit 05c21ee

Please sign in to comment.