Skip to content

Commit

Permalink
Merge branch 'trunk' into csharp-selenium-manager-example
Browse files Browse the repository at this point in the history
  • Loading branch information
shbenzer authored Dec 27, 2024
2 parents 0afd142 + ef7d1c6 commit fc29eff
Show file tree
Hide file tree
Showing 159 changed files with 3,552 additions and 2,843 deletions.
7 changes: 5 additions & 2 deletions .github/workflows/dotnet-examples.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,9 @@ jobs:
if: matrix.release == 'nightly' && matrix.os != 'windows'
run:
|
latest_nightly=$(./scripts/latest-nightly-version.sh nuget Selenium.WebDriver)
pip install -r ./scripts/requirements.txt
latest_nightly=$(python ./scripts/latest-nightly-version.py nuget Selenium.WebDriver)
echo $latest_nightly
dotnet add examples/dotnet/SeleniumDocs/SeleniumDocs.csproj package Selenium.WebDriver --version $latest_nightly
dotnet add examples/dotnet/SeleniumDocs/SeleniumDocs.csproj package Selenium.Support --version $latest_nightly
env:
Expand All @@ -71,7 +73,8 @@ jobs:
shell: pwsh
run:
|
$latest_nightly = ./scripts/latest-nightly-version.ps1 nuget Selenium.WebDriver
pip install -r ./scripts/requirements.txt
$latest_nightly = python ./scripts/latest-nightly-version.py nuget Selenium.WebDriver
dotnet add examples/dotnet/SeleniumDocs/SeleniumDocs.csproj package Selenium.WebDriver --version $latest_nightly
dotnet add examples/dotnet/SeleniumDocs/SeleniumDocs.csproj package Selenium.Support --version $latest_nightly
env:
Expand Down
21 changes: 14 additions & 7 deletions .github/workflows/java-examples.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,43 +45,50 @@ jobs:
if: matrix.os == 'ubuntu'
run: Xvfb :99 &
- name: Set up Java
id: java
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: 11
java-version: 17
- name: Import test cert non-Windows
if: matrix.os != 'windows'
run: sudo keytool -import -noprompt -trustcacerts -alias SeleniumHQ -file examples/java/src/test/resources/tls.crt -keystore ${{ steps.java.outputs.path }}/lib/security/cacerts -storepass changeit
- name: Import test cert Windows
if: matrix.os == 'windows'
run: keytool -import -noprompt -trustcacerts -alias SeleniumHQ -file examples/java/src/test/resources/tls.crt -keystore ${{ steps.java.outputs.path }}/lib/security/cacerts -storepass changeit
- name: Run Tests Stable
if: matrix.release == 'stable'
uses: nick-invision/[email protected]
with:
timeout_minutes: 20
timeout_minutes: 40
max_attempts: 3
command: |
cd examples/java
mvn -B test
mvn -B test -D"jdk.internal.httpclient.disableHostnameVerification=true"
- name: Run Tests Nightly Linux/macOS
if: matrix.release == 'nightly' && matrix.os != 'windows'
uses: nick-invision/[email protected]
with:
timeout_minutes: 20
timeout_minutes: 40
max_attempts: 3
command: |
pip install yq
xml_content=$(curl -sf https://oss.sonatype.org/service/local/repositories/snapshots/content/org/seleniumhq/selenium/selenium-java/)
latest_snapshot=$(echo "$xml_content" | xq '.content.data."content-item"' | jq -r 'sort_by(.lastModified) | last | .text')
echo "Latest Selenium Snapshot: $latest_snapshot"
cd examples/java
mvn -B -U test -Dselenium.version="$latest_snapshot"
mvn -B -U test -D"jdk.internal.httpclient.disableHostnameVerification=true"
- name: Run Tests Nightly Windows
if: matrix.release == 'nightly' && matrix.os == 'windows'
uses: nick-invision/[email protected]
with:
timeout_minutes: 20
timeout_minutes: 40
max_attempts: 3
command: |
pip install yq
$xml_content = Invoke-WebRequest -Uri "https://oss.sonatype.org/service/local/repositories/snapshots/content/org/seleniumhq/selenium/selenium-java/"
$latest_snapshot = $xml_content.Content | xq '.content.data.\"content-item\"' | jq -r 'sort_by(.lastModified) | last | .text'
Write-Output "Latest Selenium Snapshot: $latest_snapshot"
cd examples/java
mvn -B -U test "-Dselenium.version=$latest_snapshot"
mvn -B -U test -D"jdk.internal.httpclient.disableHostnameVerification=true"
7 changes: 5 additions & 2 deletions .github/workflows/js-examples.yml
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,9 @@ jobs:
if: matrix.release == 'nightly' && matrix.os != 'windows'
run:
|
latest_nightly=$(./scripts/latest-nightly-version.sh npm selenium-webdriver)
pip install -r ./scripts/requirements.txt
latest_nightly=$(python ./scripts/latest-nightly-version.py npm selenium-webdriver)
echo $latest_nightly
npm install --prefix ./examples/javascript --save selenium-webdriver@npm:@seleniumhq/selenium-webdriver@$latest_nightly
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand All @@ -102,7 +104,8 @@ jobs:
if: matrix.release == 'nightly' && matrix.os == 'windows'
run:
|
$latest_nightly = ./scripts/latest-nightly-version.ps1 npm selenium-webdriver
pip install -r ./scripts/requirements.txt
$latest_nightly = python ./scripts/latest-nightly-version.py npm selenium-webdriver
npm install --prefix ./examples/javascript --save selenium-webdriver@npm:@seleniumhq/selenium-webdriver@$latest_nightly
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand Down
46 changes: 37 additions & 9 deletions .github/workflows/python-examples.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,25 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [ ubuntu, windows, macos ]
release: [ stable, nightly ]
include:
- os: ubuntu
release: stable
python: '3.8'
- os: ubuntu
release: nightly
python: '3.11'
- os: windows
release: stable
python: '3.9'
- os: windows
release: nightly
python: '3.12'
- os: macos
release: stable
python: '3.10'
- os: macos
release: nightly
python: '3.13'
runs-on: ${{ format('{0}-latest', matrix.os) }}
steps:
- name: Checkout GitHub repo
Expand All @@ -47,14 +64,25 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: 3.8
- name: Install dependencies nightly
if: matrix.release == 'nightly'
working-directory: ./examples/python
python-version: ${{ matrix.python }}
- name: Install dependencies nightly non-Windows
if: matrix.release == 'nightly' && matrix.os != 'windows'
run: |
pip install -r ./scripts/requirements.txt
latest_nightly_python=$(python ./scripts/latest-python-nightly-version.py)
cd examples/python
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install --index-url https://test.pypi.org/simple/ selenium==$latest_nightly_python --extra-index-url https://pypi.org/simple/ --upgrade --force-reinstall --break-system-packages
- name: Install dependencies nightly Windows
if: matrix.release == 'nightly' && matrix.os == 'windows'
run: |
pip install -r ./scripts/requirements.txt
$latest_nightly_python = python ./scripts/latest-python-nightly-version.py
cd examples/python
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install -i https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple --force-reinstall -v selenium
pip install --index-url https://test.pypi.org/simple/ selenium==$latest_nightly_python --extra-index-url https://pypi.org/simple/ --upgrade --force-reinstall --break-system-packages
- name: Install dependencies stable
if: matrix.release == 'stable'
working-directory: ./examples/python
Expand All @@ -69,8 +97,8 @@ jobs:
- name: Run tests
uses: nick-invision/[email protected]
with:
timeout_minutes: 20
timeout_minutes: 60
max_attempts: 3
command: |
cd examples/python
pytest
pytest --reruns 3
7 changes: 5 additions & 2 deletions .github/workflows/ruby-examples.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,9 @@ jobs:
if: matrix.release == 'nightly' && matrix.os != 'windows'
run:
|
latest_nightly_webdriver=$(./scripts/latest-nightly-version.sh rubygems selenium-webdriver)
pip install -r ./scripts/requirements.txt
latest_nightly_webdriver=$(python ./scripts/latest-nightly-version.py rubygems selenium-webdriver)
echo $latest_nightly_webdriver
cd examples/ruby
bundle install
bundle remove selenium-webdriver
Expand All @@ -64,7 +66,8 @@ jobs:
if: matrix.release == 'nightly' && matrix.os == 'windows'
run:
|
$latest_nightly_webdriver = ./scripts/latest-nightly-version.ps1 rubygems selenium-webdriver
pip install -r ./scripts/requirements.txt
$latest_nightly_webdriver = python ./scripts/latest-nightly-version.py rubygems selenium-webdriver
cd examples/ruby
bundle install
bundle remove selenium-webdriver
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,5 @@ website_and_docs/resources
.settings
.gitignore
.pydevproject
**/*.iml
**/.gradle
2 changes: 1 addition & 1 deletion examples/dotnet/SeleniumDocs/BaseTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public class BaseTest
protected IWebDriver driver;
protected Uri GridUrl;
private Process _webserverProcess;
private const string ServerJarName = "selenium-server-4.26.0.jar";
private const string ServerJarName = "selenium-server-4.27.0.jar";
private static readonly string BaseDirectory = AppContext.BaseDirectory;
private const string RelativePathToGrid = "../../../../../";
private readonly string _examplesDirectory = Path.GetFullPath(Path.Combine(BaseDirectory, RelativePathToGrid));
Expand Down
14 changes: 7 additions & 7 deletions examples/dotnet/SeleniumDocs/BiDi/CDP/NetworkTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
using OpenQA.Selenium;
using OpenQA.Selenium.DevTools;
using System.Linq;
using OpenQA.Selenium.DevTools.V130.Network;
using OpenQA.Selenium.DevTools.V130.Performance;
using OpenQA.Selenium.DevTools.V131.Network;
using OpenQA.Selenium.DevTools.V131.Performance;


namespace SeleniumDocs.BiDi.CDP
Expand All @@ -16,7 +16,7 @@ public class NetworkTest : BaseTest
[TestInitialize]
public void Startup()
{
StartDriver("130");
StartDriver("131");
}

[TestMethod]
Expand Down Expand Up @@ -109,9 +109,9 @@ public async Task PerformanceMetrics()
driver.Url = "https://www.selenium.dev/selenium/web/frameset.html";

var session = ((IDevTools)driver).GetDevToolsSession();
var domains = session.GetVersionSpecificDomains<OpenQA.Selenium.DevTools.V130.DevToolsSessionDomains>();
var domains = session.GetVersionSpecificDomains<OpenQA.Selenium.DevTools.V131.DevToolsSessionDomains>();

await domains.Performance.Enable(new OpenQA.Selenium.DevTools.V13.Performance.EnableCommandSettings());
await domains.Performance.Enable(new OpenQA.Selenium.DevTools.V131.Performance.EnableCommandSettings());
var metricsResponse =
await session.SendCommand<GetMetricsCommandSettings, GetMetricsCommandResponse>(
new GetMetricsCommandSettings()
Expand All @@ -130,8 +130,8 @@ await session.SendCommand<GetMetricsCommandSettings, GetMetricsCommandResponse>(
public async Task SetCookie()
{
var session = ((IDevTools)driver).GetDevToolsSession();
var domains = session.GetVersionSpecificDomains<OpenQA.Selenium.DevTools.V130.DevToolsSessionDomains>();
await domains.Network.Enable(new OpenQA.Selenium.DevTools.V130.Network.EnableCommandSettings());
var domains = session.GetVersionSpecificDomains<OpenQA.Selenium.DevTools.V131.DevToolsSessionDomains>();
await domains.Network.Enable(new OpenQA.Selenium.DevTools.V131.Network.EnableCommandSettings());

var cookieCommandSettings = new SetCookieCommandSettings
{
Expand Down
102 changes: 97 additions & 5 deletions examples/dotnet/SeleniumDocs/Interactions/CookiesTest.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,101 @@
// Licensed to the Software Freedom Conservancy (SFC) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The SFC licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.

using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using OpenQA.Selenium;
using OpenQA.Selenium.Chrome;

namespace SeleniumDocs.Interactions{

[TestClass]
public class CookiesTest{

WebDriver driver = new ChromeDriver();

[TestMethod]
public void addCookie(){
driver.Url="https://www.selenium.dev/selenium/web/blank.html";
// Add cookie into current browser context
driver.Manage().Cookies.AddCookie(new Cookie("key", "value"));
driver.Quit();
}

[TestMethod]
public void getNamedCookie(){
driver.Url = "https://www.selenium.dev/selenium/web/blank.html";
// Add cookie into current browser context
driver.Manage().Cookies.AddCookie(new Cookie("foo", "bar"));
// Get cookie details with named cookie 'foo'
Cookie cookie = driver.Manage().Cookies.GetCookieNamed("foo");
Assert.AreEqual(cookie.Value, "bar");
driver.Quit();
}

[TestMethod]
public void getAllCookies(){
driver.Url = "https://www.selenium.dev/selenium/web/blank.html";
// Add cookies into current browser context
driver.Manage().Cookies.AddCookie(new Cookie("test1", "cookie1"));
driver.Manage().Cookies.AddCookie(new Cookie("test2", "cookie2"));
// Get cookies
var cookies = driver.Manage().Cookies.AllCookies;
foreach (var cookie in cookies){
if (cookie.Name.Equals("test1")){
Assert.AreEqual("cookie1", cookie.Value);
}
if (cookie.Name.Equals("test2")){
Assert.AreEqual("cookie2", cookie.Value);
}
}
driver.Quit();
}

[TestMethod]
public void deleteCookieNamed(){
driver.Url = "https://www.selenium.dev/selenium/web/blank.html";
driver.Manage().Cookies.AddCookie(new Cookie("test1", "cookie1"));
// delete cookie named
driver.Manage().Cookies.DeleteCookieNamed("test1");
driver.Quit();
}

namespace SeleniumDocs.Interactions
{
[TestClass]
public class CookiesTest : BaseTest
{
[TestMethod]
public void deleteCookieObject(){
driver.Url = "https://www.selenium.dev/selenium/web/blank.html";
Cookie cookie = new Cookie("test2", "cookie2");
driver.Manage().Cookies.AddCookie(cookie);
/*
Selenium CSharp bindings also provides a way to delete
cookie by passing cookie object of current browsing context
*/
driver.Manage().Cookies.DeleteCookie(cookie);
driver.Quit();
}

[TestMethod]
public void deleteAllCookies(){
driver.Url = "https://www.selenium.dev/selenium/web/blank.html";
// Add cookies into current browser context
driver.Manage().Cookies.AddCookie(new Cookie("test1", "cookie1"));
driver.Manage().Cookies.AddCookie(new Cookie("test2", "cookie2"));
// Delete All cookies
driver.Manage().Cookies.DeleteAllCookies();
driver.Quit();
}
}
}
11 changes: 10 additions & 1 deletion examples/dotnet/SeleniumDocs/Interactions/PrintOptionsTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,15 @@ public void TestShrinkToFit()
printOptions.ShrinkToFit = true;
bool currentShrinkToFit = printOptions.ShrinkToFit;
}
}

[TestMethod]
public void PrintWithPrintsPageTest()
{
WebDriver driver = new ChromeDriver();
driver.Navigate().GoToUrl("https://www.selenium.dev/");
PrintOptions printOptions = new PrintOptions();
PrintDocument printedPage = driver.Print(printOptions);
Assert.IsTrue(printedPage.AsBase64EncodedString.StartsWith("JVBER"));
}
}
}
4 changes: 2 additions & 2 deletions examples/dotnet/SeleniumDocs/SeleniumDocs.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
<PackageReference Include="Microsoft.IdentityModel.Tokens" Version="7.7.1" />
<PackageReference Include="MSTest.TestAdapter" Version="3.6.0" />
<PackageReference Include="MSTest.TestFramework" Version="3.6.0" />
<PackageReference Include="Selenium.Support" Version="4.25.0" />
<PackageReference Include="Selenium.WebDriver" Version="4.25.0" />
<PackageReference Include="Selenium.Support" Version="4.27.0" />
<PackageReference Include="Selenium.WebDriver" Version="4.27.0" />
</ItemGroup>

<ItemGroup>
Expand Down
4 changes: 2 additions & 2 deletions examples/java/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ repositories {
}

dependencies {
testImplementation 'org.seleniumhq.selenium:selenium-java:4.26.0'
testImplementation 'org.junit.jupiter:junit-jupiter-engine:5.11.3'
testImplementation 'org.seleniumhq.selenium:selenium-java:4.27.0'
testImplementation 'org.junit.jupiter:junit-jupiter-engine:5.11.4'
}

test {
Expand Down
Loading

0 comments on commit fc29eff

Please sign in to comment.