Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .github/workflows/dotnet-examples.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ env:
DISPLAY: :99
GITHUB_TOKEN: ${{ secrets.SELENIUM_CI_TOKEN }}
GH_TOKEN: ${{ secrets.SELENIUM_CI_TOKEN }}
EDGE_PATH: "C:\\Program Files (x86)\\Microsoft\\Edge\\Application\\msedge.exe"

jobs:
test_examples:
Expand Down Expand Up @@ -48,7 +47,7 @@ jobs:
browser: firefox
version: latest
- name: Run tests
uses: nick-invision/retry@v2.7.1
uses: nick-invision/retry@v2.8.2
with:
timeout_minutes: 20
max_attempts: 3
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/java-examples.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ env:
DISPLAY: :99
GITHUB_TOKEN: ${{ secrets.SELENIUM_CI_TOKEN }}
GH_TOKEN: ${{ secrets.SELENIUM_CI_TOKEN }}
EDGE_PATH: "C:\\Program Files (x86)\\Microsoft\\Edge\\Application\\msedge.exe"

jobs:
test_examples:
Expand Down Expand Up @@ -49,7 +48,7 @@ jobs:
browser: firefox
version: latest
- name: Run Tests
uses: nick-invision/retry@v2.7.1
uses: nick-invision/retry@v2.8.2
with:
timeout_minutes: 20
max_attempts: 3
Expand Down
7 changes: 4 additions & 3 deletions .github/workflows/js-examples.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ env:
DISPLAY: :99
GITHUB_TOKEN: ${{ secrets.SELENIUM_CI_TOKEN }}
GH_TOKEN: ${{ secrets.SELENIUM_CI_TOKEN }}
EDGE_PATH: "C:\\Program Files (x86)\\Microsoft\\Edge\\Application\\msedge.exe"

jobs:
test_examples:
Expand All @@ -43,14 +42,16 @@ jobs:
with:
browser: firefox
version: latest
- name: Install Requirements
working-directory: ./examples/javascript
run: npm install
- name: Run tests
uses: nick-invision/retry@v2.7.1
env:
SELENIUM_BROWSER: chrome
uses: nick-invision/retry@v2.8.2
with:
timeout_minutes: 20
max_attempts: 3
command: |
cd examples/javascript
npm install
npm test
3 changes: 1 addition & 2 deletions .github/workflows/kotlin-examples.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ env:
DISPLAY: :99
GITHUB_TOKEN: ${{ secrets.SELENIUM_CI_TOKEN }}
GH_TOKEN: ${{ secrets.SELENIUM_CI_TOKEN }}
EDGE_PATH: "C:\\Program Files (x86)\\Microsoft\\Edge\\Application\\msedge.exe"

jobs:
test_examples:
Expand Down Expand Up @@ -49,7 +48,7 @@ jobs:
browser: firefox
version: latest
- name: Run tests
uses: nick-invision/retry@v2.7.1
uses: nick-invision/retry@v2.8.2
with:
timeout_minutes: 20
max_attempts: 3
Expand Down
13 changes: 10 additions & 3 deletions .github/workflows/python-examples.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ env:
DISPLAY: :99
GITHUB_TOKEN: ${{ secrets.SELENIUM_CI_TOKEN }}
GH_TOKEN: ${{ secrets.SELENIUM_CI_TOKEN }}
EDGE_PATH: "C:\\Program Files (x86)\\Microsoft\\Edge\\Application\\msedge.exe"

jobs:
test_examples:
Expand All @@ -43,12 +42,20 @@ jobs:
with:
browser: firefox
version: latest
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.8
- name: Install dependencies
working-directory: ./examples/python
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Run tests
uses: nick-invision/retry@v2.7.1
uses: nick-invision/retry@v2.8.2
with:
timeout_minutes: 20
max_attempts: 3
command: |
cd examples/python
pip3 install -r requirements.txt
pytest
59 changes: 30 additions & 29 deletions .github/workflows/ruby-examples.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ env:
DISPLAY: :99
GITHUB_TOKEN: ${{ secrets.SELENIUM_CI_TOKEN }}
GH_TOKEN: ${{ secrets.SELENIUM_CI_TOKEN }}
EDGE_PATH: "C:\\Program Files (x86)\\Microsoft\\Edge\\Application\\msedge.exe"

jobs:
test_examples:
Expand All @@ -29,31 +28,33 @@ jobs:
os: [ ubuntu-latest, windows-latest, macos-latest ]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout GitHub repo
uses: actions/checkout@v2
- name: Start Xvfb
if: matrix.os == 'ubuntu-latest'
run: Xvfb :99 &
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: 2.7
bundler-cache: true
- name: Install Chrome
uses: browser-actions/setup-chrome@latest
- name: Install Edge
uses: browser-actions/setup-edge@latest
- name: Install Firefox
uses: abhi1693/setup-browser@v0.3.4
with:
browser: firefox
version: latest
- name: Run tests
uses: nick-invision/retry@v2.7.1
with:
timeout_minutes: 20
max_attempts: 3
command: |
cd examples/ruby
bundle install
bundle exec rspec
- name: Checkout GitHub repo
uses: actions/checkout@v2
- name: Start Xvfb
if: matrix.os == 'ubuntu-latest'
run: Xvfb :99 &
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: 2.7
bundler-cache: true
- name: Install Chrome
uses: browser-actions/setup-chrome@latest
- name: Install Edge
uses: browser-actions/setup-edge@latest
- name: Install Firefox
uses: abhi1693/setup-browser@v0.3.4
with:
browser: firefox
version: latest
- name: Install Gems
working-directory: ./examples/ruby
run: bundle install
- name: Run tests
uses: nick-invision/retry@v2.8.2
with:
timeout_minutes: 20
max_attempts: 3
command: |
cd examples/ruby
bundle exec rspec
2 changes: 1 addition & 1 deletion examples/dotnet/SeleniumDocs/ActionsAPI/ActionsTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
namespace SeleniumDocs.ActionsAPI
{
[TestClass]
public class ActionsTest : BaseTest
public class ActionsTest : BaseChromeTest
{
[TestMethod]
public void Pause()
Expand Down
2 changes: 1 addition & 1 deletion examples/dotnet/SeleniumDocs/ActionsAPI/KeysTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
namespace SeleniumDocs.ActionsAPI
{
[TestClass]
public class KeysTest : BaseTest
public class KeysTest : BaseFirefoxTest
{
[TestMethod]
public void KeyDown()
Expand Down
2 changes: 1 addition & 1 deletion examples/dotnet/SeleniumDocs/ActionsAPI/MouseTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
namespace SeleniumDocs.ActionsAPI
{
[TestClass]
public class MouseTest : BaseTest
public class MouseTest : BaseChromeTest
{
[TestMethod]
public void ClickAndHold()
Expand Down
53 changes: 32 additions & 21 deletions examples/dotnet/SeleniumDocs/ActionsAPI/PenTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
namespace SeleniumDocs.ActionsAPI
{
[TestClass]
public class PenTest : BaseTest
public class PenTest : BaseChromeTest
{
[TestMethod]
public void UsePen()
Expand All @@ -35,25 +35,25 @@ public void UsePen()

Point location = pointerArea.Location;
Size size = pointerArea.Size;
int centerX = (int) Math.Floor((decimal) location.X + size.Width / 2);
int centerY = (int) Math.Floor((decimal) location.Y + size.Height / 2);
decimal centerX = location.X + size.Width / 2;
decimal centerY = location.Y + size.Height / 2;

Assert.AreEqual("-1", moveTo["button"]);
Assert.AreEqual("pen", moveTo["pointerType"]);
Assert.AreEqual((centerX).ToString(), moveTo["pageX"]);
Assert.AreEqual((centerY - 1).ToString(), moveTo["pageY"]);
Assert.IsTrue(VerifyEquivalent(centerX, moveTo["pageX"]));
Assert.IsTrue(VerifyEquivalent(centerY, moveTo["pageY"]));
Assert.AreEqual("0", down["button"]);
Assert.AreEqual("pen", down["pointerType"]);
Assert.AreEqual((centerX).ToString(), down["pageX"]);
Assert.AreEqual((centerY - 1).ToString(), down["pageY"]);
Assert.IsTrue(VerifyEquivalent(centerX, down["pageX"]));
Assert.IsTrue(VerifyEquivalent(centerY, down["pageY"]));
Assert.AreEqual("-1", moveBy["button"]);
Assert.AreEqual("pen", moveBy["pointerType"]);
Assert.AreEqual((centerX + 2).ToString(), moveBy["pageX"]);
Assert.AreEqual((centerY + 1).ToString(), moveBy["pageY"]);
Assert.IsTrue(VerifyEquivalent(centerX + 2, moveBy["pageX"]));
Assert.IsTrue(VerifyEquivalent(centerY + 2, moveBy["pageY"]));
Assert.AreEqual("0", up["button"]);
Assert.AreEqual("pen", up["pointerType"]);
Assert.AreEqual((centerX + 2).ToString(), up["pageX"]);
Assert.AreEqual((centerY + 1).ToString(), up["pageY"]);
Assert.IsTrue(VerifyEquivalent(centerX + 2, up["pageX"]));
Assert.IsTrue(VerifyEquivalent(centerY + 2, up["pageY"]));
}

[TestMethod]
Expand Down Expand Up @@ -84,28 +84,28 @@ public void SetPointerEventProperties()

Point location = pointerArea.Location;
Size size = pointerArea.Size;
int centerX = location.X + size.Width / 2;
int centerY = location.Y + size.Height / 2;
decimal centerX = location.X + size.Width / 2;
decimal centerY = location.Y + size.Height / 2;

Assert.AreEqual("-1", moveTo["button"]);
Assert.AreEqual("pen", moveTo["pointerType"]);
Assert.AreEqual((centerX).ToString(), moveTo["pageX"]);
Assert.AreEqual((centerY - 1).ToString(), moveTo["pageY"]);
Assert.IsTrue(VerifyEquivalent(centerX, moveTo["pageX"]));
Assert.IsTrue(VerifyEquivalent(centerY, moveTo["pageY"]));
Assert.AreEqual("0", down["button"]);
Assert.AreEqual("pen", down["pointerType"]);
Assert.AreEqual((centerX).ToString(), down["pageX"]);
Assert.AreEqual((centerY - 1).ToString(), down["pageY"]);
Assert.IsTrue(VerifyEquivalent(centerX, down["pageX"]));
Assert.IsTrue(VerifyEquivalent(centerY, down["pageY"]));
Assert.AreEqual("-1", moveBy["button"]);
Assert.AreEqual("pen", moveBy["pointerType"]);
Assert.AreEqual((centerX + 2).ToString(), moveBy["pageX"]);
Assert.AreEqual((centerY + 1).ToString(), moveBy["pageY"]);
Assert.IsTrue(VerifyEquivalent(centerX + 2, moveBy["pageX"]));
Assert.IsTrue(VerifyEquivalent(centerY + 2, moveBy["pageY"]));
Assert.AreEqual((-72).ToString(), moveBy["tiltX"]);
Assert.AreEqual((9).ToString(), moveBy["tiltY"]);
Assert.AreEqual((86).ToString(), moveBy["twist"]);
Assert.AreEqual("0", up["button"]);
Assert.AreEqual("pen", up["pointerType"]);
Assert.AreEqual((centerX + 2).ToString(), up["pageX"]);
Assert.AreEqual((centerY + 1).ToString(), up["pageY"]);
Assert.IsTrue(VerifyEquivalent(centerX + 2, up["pageX"]));
Assert.IsTrue(VerifyEquivalent(centerY + 2, up["pageY"]));
}

private Dictionary<string, string> getProperties(IWebElement element)
Expand All @@ -115,5 +115,16 @@ private Dictionary<string, string> getProperties(IWebElement element)
IEnumerable<string[]> keyValue = str.Split(", ").Select(part => part.Split(":"));
return keyValue.ToDictionary(split => split[0].Trim(), split => split[1].Trim());
}

private bool VerifyEquivalent(decimal expected, string actual)
{
var absolute = Math.Abs(expected - decimal.Parse(actual));
if (absolute <= 1)
{
return true;
}

throw new Exception("Expected: " + expected + "; but received: " + actual);
}
}
}
2 changes: 1 addition & 1 deletion examples/dotnet/SeleniumDocs/ActionsAPI/WheelTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
namespace SeleniumDocs.ActionsAPI
{
[TestClass]
public class WheelTest : BaseTest
public class WheelTest : BaseChromeTest
{
[TestMethod]
public void ShouldAllowScrollingToAnElement()
Expand Down
14 changes: 14 additions & 0 deletions examples/dotnet/SeleniumDocs/BaseChromeTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
using OpenQA.Selenium.Chrome;

namespace SeleniumDocs
{
public class BaseChromeTest : BaseTest
{
[TestInitialize]
public void CreateDriver()
{
driver = new ChromeDriver();
}
}
}
14 changes: 14 additions & 0 deletions examples/dotnet/SeleniumDocs/BaseFirefoxTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
using OpenQA.Selenium.Firefox;

namespace SeleniumDocs
{
public class BaseFirefoxTest : BaseTest
{
[TestInitialize]
public void CreateDriver()
{
driver = new FirefoxDriver();
}
}
}
10 changes: 0 additions & 10 deletions examples/dotnet/SeleniumDocs/BaseTest.cs
Original file line number Diff line number Diff line change
@@ -1,22 +1,12 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
using OpenQA.Selenium;
using OpenQA.Selenium.Chrome;
using WebDriverManager;
using WebDriverManager.DriverConfigs.Impl;

namespace SeleniumDocs
{
public class BaseTest
{
protected IWebDriver driver;

[TestInitialize]
public void CreateDriver()
{
new DriverManager().SetUpDriver(new ChromeConfig());
driver = new ChromeDriver();
}

[TestCleanup]
public void QuitDriver()
{
Expand Down
4 changes: 0 additions & 4 deletions examples/dotnet/SeleniumDocs/Browsers/ChromeTest.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
using OpenQA.Selenium.Chrome;
using WebDriverManager;
using WebDriverManager.DriverConfigs.Impl;

namespace SeleniumDocs.Browsers
{
Expand All @@ -11,8 +9,6 @@ public class ChromeTest
[TestMethod]
public void BasicOptions()
{
new DriverManager().SetUpDriver(new ChromeConfig());

var options = new ChromeOptions();
var driver = new ChromeDriver(options);

Expand Down
Loading