Skip to content

Commit

Permalink
Merge pull request #231 from zzzrst/development
Browse files Browse the repository at this point in the history
Update Testing Driver versioning to Working Version
  • Loading branch information
victor-zheng-codes authored Dec 20, 2023
2 parents b0796eb + b27e41c commit af65286
Show file tree
Hide file tree
Showing 33 changed files with 2,651 additions and 863 deletions.
22 changes: 11 additions & 11 deletions .github/workflows/buildAndTest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,32 +11,32 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Setup .NET Core
uses: actions/setup-dotnet@v1
uses: actions/setup-dotnet@v3
with:
dotnet-version: 3.1.100
dotnet-version: '6.0.x'
- name: Build with dotnet
run: dotnet build --configuration Release

test:
needs: build

runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

steps:
- uses: actions/checkout@v3
- name: Setup .NET Core
uses: actions/setup-dotnet@v1
uses: actions/setup-dotnet@v3
with:
dotnet-version: 3.1.100
dotnet-version: '6.0.x'
- name: Run Unit Tests
run: |
docker run -d -p 4444:4444 -v /dev/shm:/dev/shm selenium/standalone-chrome
dotnet test --verbosity normal --configuration Release
automerge:
needs: [build,test]
needs: [build, test]

runs-on: ubuntu-latest
steps:
Expand Down
20 changes: 10 additions & 10 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Setup .NET Core
uses: actions/setup-dotnet@v1
uses: actions/setup-dotnet@v3
with:
dotnet-version: 3.1.100
dotnet-version: '6.0.x'
- name: Build with dotnet
run: dotnet build --configuration Release

Expand All @@ -28,11 +28,11 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Setup .NET Core
uses: actions/setup-dotnet@v1
uses: actions/setup-dotnet@v3
with:
dotnet-version: 3.1.100
dotnet-version: '6.0.x'
- name: Run Unit Tests
run: |
docker run -d -p 4444:4444 -v /dev/shm:/dev/shm selenium/standalone-chrome
Expand All @@ -43,11 +43,11 @@ jobs:

runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Setup .NET Core
uses: actions/setup-dotnet@v1
with:
dotnet-version: 3.1.100
uses: actions/setup-dotnet@v3
with:
dotnet-version: '6.0.x'
- name: Build with dotnet
run: dotnet build --configuration Release
- name: Publish nuget
Expand Down
12 changes: 6 additions & 6 deletions NUnitTestingDriver/NUnitTestingDriver.csproj
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<TargetFramework>net6.0</TargetFramework>

<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="nunit" Version="3.13.2" />
<PackageReference Include="NUnit3TestAdapter" Version="3.17.0">
<PackageReference Include="nunit" Version="4.0.1" />
<PackageReference Include="NUnit3TestAdapter" Version="4.5.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.9.4" />
<PackageReference Include="Selenium.WebDriver" Version="3.141.0" />
<PackageReference Include="Selenium.WebDriver.ChromeDriver" Version="90.0.4430.2400" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
<PackageReference Include="Selenium.WebDriver" Version="4.16.2" />
<PackageReference Include="Selenium.WebDriver.ChromeDriver" Version="119.0.6045.10500" />

</ItemGroup>

Expand Down
67 changes: 38 additions & 29 deletions NUnitTestingDriver/UnitTest.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
using NUnit.Framework;
using System;
using System.Collections.Generic;
using System.IO;
using System.Reflection;
using System.Threading;
using TestingDriver;
namespace NUnitTestingDriver
Expand All @@ -12,12 +14,16 @@ public class Tests
[SetUp]
public void Setup()
{

#if DEBUG
driver = new SeleniumDriver(browser: "Chrome", timeOut: 5);
driver = new SeleniumDriver(
browser: "Chrome",
timeOut: 30,
headless:false);
#else
driver = new SeleniumDriver(browser:"remoteChrome", remoteHost:"http://localhost:4444/wd/hub");
driver = new SeleniumDriver(browser: "remoteChrome", timeOut: 30, remoteHost: "http://localhost:4444/wd/hub");
#endif
driver.NavigateToURL("http://the-internet.herokuapp.com/");
driver.NavigateToURL("https://the-internet.herokuapp.com/");
}

[Test]
Expand All @@ -35,13 +41,15 @@ public void TestLogIn()
{
driver.ClickElement("//a[contains(text(),'Form Authentication')]");

Assert.AreEqual("http://the-internet.herokuapp.com/login", driver.CurrentURL, "URL is incorrect");
Console.WriteLine("Current url " + driver.CurrentURL);

Assert.That("https://the-internet.herokuapp.com/login".Equals(driver.CurrentURL), "URL is incorrect");

driver.PopulateElement("//input[@id='username']", "tomsmith");
driver.PopulateElement("//input[@id='password']", "SuperSecretPassword!");
driver.ClickElement("//button[@class='radius']");

Assert.AreEqual("http://the-internet.herokuapp.com/secure", driver.CurrentURL, "URL is incorrect");
Assert.That("https://the-internet.herokuapp.com/secure".Equals(driver.CurrentURL), "URL is incorrect");
}

[Test]
Expand Down Expand Up @@ -69,54 +77,54 @@ public void TestWaitForElement()
public void TestCheckElementState()
{
driver.ClickElement("//a[contains(text(),'Dynamic Controls')]");
Assert.IsTrue(driver.CheckForElementState("//div[@id='checkbox']//input", ITestingDriver.ElementState.Clickable),"Element should be clickable");
Assert.IsTrue(driver.CheckForElementState("//div[@id='checkbox']//input", ITestingDriver.ElementState.Visible), "Element should be visible");
Assert.IsFalse(driver.CheckForElementState("//div[@id='checkbox']//input", ITestingDriver.ElementState.Invisible), "Element should be clickable");
Assert.IsFalse(driver.CheckForElementState("//div[@id='checkbox']//input", ITestingDriver.ElementState.Disabled), "Element is not be disabled");
Assert.IsTrue(driver.CheckForElementState("//div[@id='plkj']", ITestingDriver.ElementState.Invisible), "Element should be invisible");
Assert.IsFalse(driver.CheckForElementState("//div[@id='plkj']", ITestingDriver.ElementState.Visible), "Element should be invisible");
Assert.IsFalse(driver.CheckForElementState("//div[@id='plkj']", ITestingDriver.ElementState.Clickable), "Element should be invisible");
Assert.IsFalse(driver.CheckForElementState("//div[@id='plkj']", ITestingDriver.ElementState.Disabled), "Element is not be disabled");
Assert.IsTrue(driver.CheckForElementState("//form[@id='input-example']//input", ITestingDriver.ElementState.Disabled), "Element should be Disabled");
Assert.IsFalse(driver.CheckForElementState("//form[@id='input-example']//input", ITestingDriver.ElementState.Clickable), "Element is not Clickable");
Assert.IsTrue(driver.CheckForElementState("//form[@id='input-example']//input", ITestingDriver.ElementState.Visible), "Element is Visible");
Assert.IsFalse(driver.CheckForElementState("//form[@id='input-example']//input", ITestingDriver.ElementState.Invisible), "Element is not Invisible");
Assert.That(driver.CheckForElementState("//div[@id='checkbox']//input", ITestingDriver.ElementState.Clickable),"Element should be clickable");
Assert.That(driver.CheckForElementState("//div[@id='checkbox']//input", ITestingDriver.ElementState.Visible), "Element should be visible");
Assert.That(!driver.CheckForElementState("//div[@id='checkbox']//input", ITestingDriver.ElementState.Invisible), "Element should be clickable");
Assert.That(!driver.CheckForElementState("//div[@id='checkbox']//input", ITestingDriver.ElementState.Disabled), "Element is not be disabled");
Assert.That(driver.CheckForElementState("//div[@id='plkj']", ITestingDriver.ElementState.Invisible), "Element should be invisible");
Assert.That(!driver.CheckForElementState("//div[@id='plkj']", ITestingDriver.ElementState.Visible), "Element should be invisible");
Assert.That(!driver.CheckForElementState("//div[@id='plkj']", ITestingDriver.ElementState.Clickable), "Element should be invisible");
Assert.That(!driver.CheckForElementState("//div[@id='plkj']", ITestingDriver.ElementState.Disabled), "Element is not be disabled");
Assert.That(driver.CheckForElementState("//form[@id='input-example']//input", ITestingDriver.ElementState.Disabled), "Element should be Disabled");
Assert.That(!driver.CheckForElementState("//form[@id='input-example']//input", ITestingDriver.ElementState.Clickable), "Element is not Clickable");
Assert.That(driver.CheckForElementState("//form[@id='input-example']//input", ITestingDriver.ElementState.Visible), "Element is Visible");
Assert.That(!driver.CheckForElementState("//form[@id='input-example']//input", ITestingDriver.ElementState.Invisible), "Element is not Invisible");
}

[Test]
public void TestIFrames()
{
driver.ClickElement("//a[contains(text(),'WYSIWYG Editor')]");
driver.SwitchToIFrame("//iframe[@id='mce_0_ifr']");
Assert.IsTrue(driver.CheckForElementState("//body", ITestingDriver.ElementState.Clickable),"element should be clickable");
Assert.IsTrue(driver.VerifyElementText("Your content goes here.", "//body"), "The text should be 'Your content goes here.'");
Assert.That(driver.CheckForElementState("//body", ITestingDriver.ElementState.Clickable),"element should be clickable");
Assert.That(driver.VerifyElementText("Your content goes here.", "//body"), "The text should be 'Your content goes here.'");
driver.PopulateElement("//body", "Hello World");
driver.SwitchToIFrame("root");
driver.SwitchToIFrame("//iframe[@id='mce_0_ifr']");
Assert.IsTrue(driver.VerifyElementText("Hello World", "//body"), "The new text should be 'Hello World'");
Assert.That(driver.VerifyElementText("Hello World", "//body"), "The new text should be 'Hello World'");
}

[Test]
public void TestVerifyAttribute()
{
driver.ClickElement("//a[contains(text(),'Broken Images')]");
Assert.IsTrue(driver.VerifyAttribute("src", "http://the-internet.herokuapp.com/img/avatar-blank.jpg", "//body//img[3]"), "The attribute src should equal http://the-internet.herokuapp.com/img/avatar-blank.jpg");
Assert.IsFalse(driver.VerifyAttribute("src", "img/image.jpg", "//body//img[3]"), "The attribute src should not equal img/image.jpg");
Assert.That(driver.VerifyAttribute("src", "https://the-internet.herokuapp.com/img/avatar-blank.jpg", "//body//img[3]"), "The attribute src should equal https://the-internet.herokuapp.com/img/avatar-blank.jpg");
Assert.That(!driver.VerifyAttribute("src", "img/image.jpg", "//body//img[3]"), "The attribute src should not equal img/image.jpg");
}

[Test]
public void TestVerifyElementText()
{
Assert.IsTrue(driver.VerifyElementText("Available Examples","//h2[contains(text(),'Available Examples')]"),"This should be the text");
Assert.IsFalse(driver.VerifyElementText("Available", "//h2[contains(text(),'Available Examples')]"),"This is the wrong text");
Assert.That(driver.VerifyElementText("Available Examples","//h2[contains(text(),'Available Examples')]"),"This should be the text");
Assert.That(!driver.VerifyElementText("Available", "//h2[contains(text(),'Available Examples')]"),"This is the wrong text");
}

[Test]
public void TestVerifyElementSelected()
{
driver.ClickElement("//a[contains(text(),'Checkboxes')]");
Assert.IsTrue(driver.VerifyElementSelected("//body//input[2]"),"This element is selected");
Assert.IsFalse(driver.VerifyElementSelected("//body//input[1]"),"This element is not selected");
Assert.That(driver.VerifyElementSelected("//body//input[2]"),"This element is selected");
Assert.That(!driver.VerifyElementSelected("//body//input[1]"), "This element is not selected");
}

[Test]
Expand All @@ -138,8 +146,8 @@ public void TestBadXPath()
public void TestVerifyDropDownContent()
{
driver.ClickElement("//a[contains(text(),'Dropdown')]");
Assert.IsTrue(driver.VerifyDropDownContent(new List<string>() {"Option 1","Option 2" }, "//select[@id='dropdown']"));
Assert.IsFalse(driver.VerifyDropDownContent(new List<string>() { "Option 1", "Option 3" }, "//select[@id='dropdown']"));
Assert.That(driver.VerifyDropDownContent(new List<string>() {"Option 1","Option 2" }, "//select[@id='dropdown']"));
Assert.That(!driver.VerifyDropDownContent(new List<string>() { "Option 1", "Option 3" }, "//select[@id='dropdown']"));
}

#if DEBUG
Expand All @@ -148,7 +156,8 @@ public void TestAODA()
{
driver.ClickElement("//a[contains(text(),'Form Authentication')]");
driver.RunAODA("title");
driver.GenerateAODAResults("./Log");
string pathEx = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + "\\Log";
driver.GenerateAODAResults(pathEx);
}
#endif
[TearDown]
Expand Down
16 changes: 16 additions & 0 deletions TestingDriver/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# TestingDriver
This is a .Net 6.0 Library.

Previously, this was a .NET6.0 library.

This directory contains the source code for the package TestingDriver. This package is a package for interacting with testing drivers for Selenium. Currently supported browsers are Chromium, Firefox, and Edge.

## Documentation
Documentation for the source code can be found [here](https://zzzrst.github.io/TestingDrivers/).

## Other Notes
Version number are labed as MAJOR.MINOR.dailyBuild.buildTime

Major changes are when new classes are added, except helper classes, or when a large change is made to the code such as a large functionality change.

Minor changes are when methods are added/removed or a helper class is added.
31 changes: 9 additions & 22 deletions TestingDriver/TestingDriver.csproj
Original file line number Diff line number Diff line change
@@ -1,38 +1,25 @@
<Project Sdk="Microsoft.NET.Sdk">


<PropertyGroup>
<OutputType>Library</OutputType>
<TargetFramework>netstandard2.1</TargetFramework>
<StartupObject></StartupObject>
<ApplicationIcon />
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<Build>$([System.DateTime]::op_Subtraction($([System.DateTime]::get_Now().get_Date()),$([System.DateTime]::new(2000,1,1))).get_TotalDays())</Build>
<Revision>$([MSBuild]::Divide($([System.DateTime]::get_Now().get_TimeOfDay().get_TotalSeconds()), 2).ToString('F0'))</Revision>
<Version>1.4.$(Build).$(Revision)</Version>
<RepositoryType>Git</RepositoryType>
<RepositoryUrl>https://github.com/zzzrst/TestingDrivers</RepositoryUrl>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<DocumentationFile>C:\Users\DuongCh\Projects\TestingDrivers\TestingDriver\TestingDriver.xml</DocumentationFile>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<DocumentationFile>C:\Users\DuongCh\Projects\TestingDrivers\TestingDriver\TestingDriver.xml</DocumentationFile>
<TargetFramework>net6.0</TargetFramework>
<Platforms>AnyCPU;x86</Platforms>
<Version>1.1.0</Version>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="AxeAccessibilityDriver" Version="2.1.7732.10828" />
<PackageReference Include="docfx.console" Version="2.57.2">
<PackageReference Include="docfx.console" Version="2.59.4">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="DotNetSeleniumExtras.WaitHelpers" Version="3.11.0" />
<PackageReference Include="log4net" Version="2.0.12" />
<PackageReference Include="log4net" Version="2.0.15" />
<PackageReference Include="NETStandard.Library" Version="2.0.3" />
<PackageReference Include="Selenium.Support" Version="3.141.0" />
<PackageReference Include="Selenium.WebDriver" Version="3.141.0" />
<PackageReference Include="Selenium.WebDriver.ChromeDriver" Version="90.0.4430.2400" />
<PackageReference Include="Selenium.Support" Version="4.16.2" />
<PackageReference Include="Selenium.WebDriver" Version="4.16.2" />
<PackageReference Include="Selenium.WebDriver.ChromeDriver" Version="119.0.6045.10500" />
<PackageReference Include="Selenium.WebDriver.IEDriver" Version="3.150.1.2" />
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118">
<PrivateAssets>all</PrivateAssets>
Expand Down
Loading

0 comments on commit af65286

Please sign in to comment.