Skip to content

Commit fc29eff

Browse files
authored
Merge branch 'trunk' into csharp-selenium-manager-example
2 parents 0afd142 + ef7d1c6 commit fc29eff

File tree

159 files changed

+3552
-2843
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

159 files changed

+3552
-2843
lines changed

Diff for: .github/workflows/dotnet-examples.yml

+5-2
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,9 @@ jobs:
6161
if: matrix.release == 'nightly' && matrix.os != 'windows'
6262
run:
6363
|
64-
latest_nightly=$(./scripts/latest-nightly-version.sh nuget Selenium.WebDriver)
64+
pip install -r ./scripts/requirements.txt
65+
latest_nightly=$(python ./scripts/latest-nightly-version.py nuget Selenium.WebDriver)
66+
echo $latest_nightly
6567
dotnet add examples/dotnet/SeleniumDocs/SeleniumDocs.csproj package Selenium.WebDriver --version $latest_nightly
6668
dotnet add examples/dotnet/SeleniumDocs/SeleniumDocs.csproj package Selenium.Support --version $latest_nightly
6769
env:
@@ -71,7 +73,8 @@ jobs:
7173
shell: pwsh
7274
run:
7375
|
74-
$latest_nightly = ./scripts/latest-nightly-version.ps1 nuget Selenium.WebDriver
76+
pip install -r ./scripts/requirements.txt
77+
$latest_nightly = python ./scripts/latest-nightly-version.py nuget Selenium.WebDriver
7578
dotnet add examples/dotnet/SeleniumDocs/SeleniumDocs.csproj package Selenium.WebDriver --version $latest_nightly
7679
dotnet add examples/dotnet/SeleniumDocs/SeleniumDocs.csproj package Selenium.Support --version $latest_nightly
7780
env:

Diff for: .github/workflows/java-examples.yml

+14-7
Original file line numberDiff line numberDiff line change
@@ -45,43 +45,50 @@ jobs:
4545
if: matrix.os == 'ubuntu'
4646
run: Xvfb :99 &
4747
- name: Set up Java
48+
id: java
4849
uses: actions/setup-java@v4
4950
with:
5051
distribution: 'temurin'
51-
java-version: 11
52+
java-version: 17
53+
- name: Import test cert non-Windows
54+
if: matrix.os != 'windows'
55+
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
56+
- name: Import test cert Windows
57+
if: matrix.os == 'windows'
58+
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
5259
- name: Run Tests Stable
5360
if: matrix.release == 'stable'
5461
uses: nick-invision/[email protected]
5562
with:
56-
timeout_minutes: 20
63+
timeout_minutes: 40
5764
max_attempts: 3
5865
command: |
5966
cd examples/java
60-
mvn -B test
67+
mvn -B test -D"jdk.internal.httpclient.disableHostnameVerification=true"
6168
- name: Run Tests Nightly Linux/macOS
6269
if: matrix.release == 'nightly' && matrix.os != 'windows'
6370
uses: nick-invision/[email protected]
6471
with:
65-
timeout_minutes: 20
72+
timeout_minutes: 40
6673
max_attempts: 3
6774
command: |
6875
pip install yq
6976
xml_content=$(curl -sf https://oss.sonatype.org/service/local/repositories/snapshots/content/org/seleniumhq/selenium/selenium-java/)
7077
latest_snapshot=$(echo "$xml_content" | xq '.content.data."content-item"' | jq -r 'sort_by(.lastModified) | last | .text')
7178
echo "Latest Selenium Snapshot: $latest_snapshot"
7279
cd examples/java
73-
mvn -B -U test -Dselenium.version="$latest_snapshot"
80+
mvn -B -U test -D"jdk.internal.httpclient.disableHostnameVerification=true"
7481
7582
- name: Run Tests Nightly Windows
7683
if: matrix.release == 'nightly' && matrix.os == 'windows'
7784
uses: nick-invision/[email protected]
7885
with:
79-
timeout_minutes: 20
86+
timeout_minutes: 40
8087
max_attempts: 3
8188
command: |
8289
pip install yq
8390
$xml_content = Invoke-WebRequest -Uri "https://oss.sonatype.org/service/local/repositories/snapshots/content/org/seleniumhq/selenium/selenium-java/"
8491
$latest_snapshot = $xml_content.Content | xq '.content.data.\"content-item\"' | jq -r 'sort_by(.lastModified) | last | .text'
8592
Write-Output "Latest Selenium Snapshot: $latest_snapshot"
8693
cd examples/java
87-
mvn -B -U test "-Dselenium.version=$latest_snapshot"
94+
mvn -B -U test -D"jdk.internal.httpclient.disableHostnameVerification=true"

Diff for: .github/workflows/js-examples.yml

+5-2
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,9 @@ jobs:
9393
if: matrix.release == 'nightly' && matrix.os != 'windows'
9494
run:
9595
|
96-
latest_nightly=$(./scripts/latest-nightly-version.sh npm selenium-webdriver)
96+
pip install -r ./scripts/requirements.txt
97+
latest_nightly=$(python ./scripts/latest-nightly-version.py npm selenium-webdriver)
98+
echo $latest_nightly
9799
npm install --prefix ./examples/javascript --save selenium-webdriver@npm:@seleniumhq/selenium-webdriver@$latest_nightly
98100
env:
99101
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
@@ -102,7 +104,8 @@ jobs:
102104
if: matrix.release == 'nightly' && matrix.os == 'windows'
103105
run:
104106
|
105-
$latest_nightly = ./scripts/latest-nightly-version.ps1 npm selenium-webdriver
107+
pip install -r ./scripts/requirements.txt
108+
$latest_nightly = python ./scripts/latest-nightly-version.py npm selenium-webdriver
106109
npm install --prefix ./examples/javascript --save selenium-webdriver@npm:@seleniumhq/selenium-webdriver@$latest_nightly
107110
env:
108111
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Diff for: .github/workflows/python-examples.yml

+37-9
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,25 @@ jobs:
2525
strategy:
2626
fail-fast: false
2727
matrix:
28-
os: [ ubuntu, windows, macos ]
29-
release: [ stable, nightly ]
28+
include:
29+
- os: ubuntu
30+
release: stable
31+
python: '3.8'
32+
- os: ubuntu
33+
release: nightly
34+
python: '3.11'
35+
- os: windows
36+
release: stable
37+
python: '3.9'
38+
- os: windows
39+
release: nightly
40+
python: '3.12'
41+
- os: macos
42+
release: stable
43+
python: '3.10'
44+
- os: macos
45+
release: nightly
46+
python: '3.13'
3047
runs-on: ${{ format('{0}-latest', matrix.os) }}
3148
steps:
3249
- name: Checkout GitHub repo
@@ -47,14 +64,25 @@ jobs:
4764
- name: Set up Python
4865
uses: actions/setup-python@v5
4966
with:
50-
python-version: 3.8
51-
- name: Install dependencies nightly
52-
if: matrix.release == 'nightly'
53-
working-directory: ./examples/python
67+
python-version: ${{ matrix.python }}
68+
- name: Install dependencies nightly non-Windows
69+
if: matrix.release == 'nightly' && matrix.os != 'windows'
70+
run: |
71+
pip install -r ./scripts/requirements.txt
72+
latest_nightly_python=$(python ./scripts/latest-python-nightly-version.py)
73+
cd examples/python
74+
python -m pip install --upgrade pip
75+
pip install -r requirements.txt
76+
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
77+
- name: Install dependencies nightly Windows
78+
if: matrix.release == 'nightly' && matrix.os == 'windows'
5479
run: |
80+
pip install -r ./scripts/requirements.txt
81+
$latest_nightly_python = python ./scripts/latest-python-nightly-version.py
82+
cd examples/python
5583
python -m pip install --upgrade pip
5684
pip install -r requirements.txt
57-
pip install -i https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple --force-reinstall -v selenium
85+
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
5886
- name: Install dependencies stable
5987
if: matrix.release == 'stable'
6088
working-directory: ./examples/python
@@ -69,8 +97,8 @@ jobs:
6997
- name: Run tests
7098
uses: nick-invision/[email protected]
7199
with:
72-
timeout_minutes: 20
100+
timeout_minutes: 60
73101
max_attempts: 3
74102
command: |
75103
cd examples/python
76-
pytest
104+
pytest --reruns 3

Diff for: .github/workflows/ruby-examples.yml

+5-2
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,9 @@ jobs:
5353
if: matrix.release == 'nightly' && matrix.os != 'windows'
5454
run:
5555
|
56-
latest_nightly_webdriver=$(./scripts/latest-nightly-version.sh rubygems selenium-webdriver)
56+
pip install -r ./scripts/requirements.txt
57+
latest_nightly_webdriver=$(python ./scripts/latest-nightly-version.py rubygems selenium-webdriver)
58+
echo $latest_nightly_webdriver
5759
cd examples/ruby
5860
bundle install
5961
bundle remove selenium-webdriver
@@ -64,7 +66,8 @@ jobs:
6466
if: matrix.release == 'nightly' && matrix.os == 'windows'
6567
run:
6668
|
67-
$latest_nightly_webdriver = ./scripts/latest-nightly-version.ps1 rubygems selenium-webdriver
69+
pip install -r ./scripts/requirements.txt
70+
$latest_nightly_webdriver = python ./scripts/latest-nightly-version.py rubygems selenium-webdriver
6871
cd examples/ruby
6972
bundle install
7073
bundle remove selenium-webdriver

Diff for: .gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,5 @@ website_and_docs/resources
1111
.settings
1212
.gitignore
1313
.pydevproject
14+
**/*.iml
15+
**/.gradle

Diff for: examples/dotnet/SeleniumDocs/BaseTest.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public class BaseTest
1717
protected IWebDriver driver;
1818
protected Uri GridUrl;
1919
private Process _webserverProcess;
20-
private const string ServerJarName = "selenium-server-4.26.0.jar";
20+
private const string ServerJarName = "selenium-server-4.27.0.jar";
2121
private static readonly string BaseDirectory = AppContext.BaseDirectory;
2222
private const string RelativePathToGrid = "../../../../../";
2323
private readonly string _examplesDirectory = Path.GetFullPath(Path.Combine(BaseDirectory, RelativePathToGrid));

Diff for: examples/dotnet/SeleniumDocs/BiDi/CDP/NetworkTest.cs

+7-7
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
using OpenQA.Selenium;
55
using OpenQA.Selenium.DevTools;
66
using System.Linq;
7-
using OpenQA.Selenium.DevTools.V130.Network;
8-
using OpenQA.Selenium.DevTools.V130.Performance;
7+
using OpenQA.Selenium.DevTools.V131.Network;
8+
using OpenQA.Selenium.DevTools.V131.Performance;
99

1010

1111
namespace SeleniumDocs.BiDi.CDP
@@ -16,7 +16,7 @@ public class NetworkTest : BaseTest
1616
[TestInitialize]
1717
public void Startup()
1818
{
19-
StartDriver("130");
19+
StartDriver("131");
2020
}
2121

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

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

114-
await domains.Performance.Enable(new OpenQA.Selenium.DevTools.V13.Performance.EnableCommandSettings());
114+
await domains.Performance.Enable(new OpenQA.Selenium.DevTools.V131.Performance.EnableCommandSettings());
115115
var metricsResponse =
116116
await session.SendCommand<GetMetricsCommandSettings, GetMetricsCommandResponse>(
117117
new GetMetricsCommandSettings()
@@ -130,8 +130,8 @@ await session.SendCommand<GetMetricsCommandSettings, GetMetricsCommandResponse>(
130130
public async Task SetCookie()
131131
{
132132
var session = ((IDevTools)driver).GetDevToolsSession();
133-
var domains = session.GetVersionSpecificDomains<OpenQA.Selenium.DevTools.V130.DevToolsSessionDomains>();
134-
await domains.Network.Enable(new OpenQA.Selenium.DevTools.V130.Network.EnableCommandSettings());
133+
var domains = session.GetVersionSpecificDomains<OpenQA.Selenium.DevTools.V131.DevToolsSessionDomains>();
134+
await domains.Network.Enable(new OpenQA.Selenium.DevTools.V131.Network.EnableCommandSettings());
135135

136136
var cookieCommandSettings = new SetCookieCommandSettings
137137
{
+97-5
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,101 @@
1+
// Licensed to the Software Freedom Conservancy (SFC) under one
2+
// or more contributor license agreements. See the NOTICE file
3+
// distributed with this work for additional information
4+
// regarding copyright ownership. The SFC licenses this file
5+
// to you under the Apache License, Version 2.0 (the
6+
// "License"); you may not use this file except in compliance
7+
// with the License. You may obtain a copy of the License at
8+
//
9+
// http://www.apache.org/licenses/LICENSE-2.0
10+
//
11+
// Unless required by applicable law or agreed to in writing,
12+
// software distributed under the License is distributed on an
13+
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
// KIND, either express or implied. See the License for the
15+
// specific language governing permissions and limitations
16+
// under the License.
17+
18+
using System;
119
using Microsoft.VisualStudio.TestTools.UnitTesting;
20+
using OpenQA.Selenium;
21+
using OpenQA.Selenium.Chrome;
22+
23+
namespace SeleniumDocs.Interactions{
24+
25+
[TestClass]
26+
public class CookiesTest{
27+
28+
WebDriver driver = new ChromeDriver();
29+
30+
[TestMethod]
31+
public void addCookie(){
32+
driver.Url="https://www.selenium.dev/selenium/web/blank.html";
33+
// Add cookie into current browser context
34+
driver.Manage().Cookies.AddCookie(new Cookie("key", "value"));
35+
driver.Quit();
36+
}
37+
38+
[TestMethod]
39+
public void getNamedCookie(){
40+
driver.Url = "https://www.selenium.dev/selenium/web/blank.html";
41+
// Add cookie into current browser context
42+
driver.Manage().Cookies.AddCookie(new Cookie("foo", "bar"));
43+
// Get cookie details with named cookie 'foo'
44+
Cookie cookie = driver.Manage().Cookies.GetCookieNamed("foo");
45+
Assert.AreEqual(cookie.Value, "bar");
46+
driver.Quit();
47+
}
48+
49+
[TestMethod]
50+
public void getAllCookies(){
51+
driver.Url = "https://www.selenium.dev/selenium/web/blank.html";
52+
// Add cookies into current browser context
53+
driver.Manage().Cookies.AddCookie(new Cookie("test1", "cookie1"));
54+
driver.Manage().Cookies.AddCookie(new Cookie("test2", "cookie2"));
55+
// Get cookies
56+
var cookies = driver.Manage().Cookies.AllCookies;
57+
foreach (var cookie in cookies){
58+
if (cookie.Name.Equals("test1")){
59+
Assert.AreEqual("cookie1", cookie.Value);
60+
}
61+
if (cookie.Name.Equals("test2")){
62+
Assert.AreEqual("cookie2", cookie.Value);
63+
}
64+
}
65+
driver.Quit();
66+
}
67+
68+
[TestMethod]
69+
public void deleteCookieNamed(){
70+
driver.Url = "https://www.selenium.dev/selenium/web/blank.html";
71+
driver.Manage().Cookies.AddCookie(new Cookie("test1", "cookie1"));
72+
// delete cookie named
73+
driver.Manage().Cookies.DeleteCookieNamed("test1");
74+
driver.Quit();
75+
}
276

3-
namespace SeleniumDocs.Interactions
4-
{
5-
[TestClass]
6-
public class CookiesTest : BaseTest
7-
{
77+
[TestMethod]
78+
public void deleteCookieObject(){
79+
driver.Url = "https://www.selenium.dev/selenium/web/blank.html";
80+
Cookie cookie = new Cookie("test2", "cookie2");
81+
driver.Manage().Cookies.AddCookie(cookie);
82+
/*
83+
Selenium CSharp bindings also provides a way to delete
84+
cookie by passing cookie object of current browsing context
85+
*/
86+
driver.Manage().Cookies.DeleteCookie(cookie);
87+
driver.Quit();
88+
}
89+
90+
[TestMethod]
91+
public void deleteAllCookies(){
92+
driver.Url = "https://www.selenium.dev/selenium/web/blank.html";
93+
// Add cookies into current browser context
94+
driver.Manage().Cookies.AddCookie(new Cookie("test1", "cookie1"));
95+
driver.Manage().Cookies.AddCookie(new Cookie("test2", "cookie2"));
96+
// Delete All cookies
97+
driver.Manage().Cookies.DeleteAllCookies();
98+
driver.Quit();
99+
}
8100
}
9101
}

Diff for: examples/dotnet/SeleniumDocs/Interactions/PrintOptionsTest.cs

+10-1
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,15 @@ public void TestShrinkToFit()
7676
printOptions.ShrinkToFit = true;
7777
bool currentShrinkToFit = printOptions.ShrinkToFit;
7878
}
79-
}
8079

80+
[TestMethod]
81+
public void PrintWithPrintsPageTest()
82+
{
83+
WebDriver driver = new ChromeDriver();
84+
driver.Navigate().GoToUrl("https://www.selenium.dev/");
85+
PrintOptions printOptions = new PrintOptions();
86+
PrintDocument printedPage = driver.Print(printOptions);
87+
Assert.IsTrue(printedPage.AsBase64EncodedString.StartsWith("JVBER"));
88+
}
89+
}
8190
}

Diff for: examples/dotnet/SeleniumDocs/SeleniumDocs.csproj

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
<PackageReference Include="Microsoft.IdentityModel.Tokens" Version="7.7.1" />
1111
<PackageReference Include="MSTest.TestAdapter" Version="3.6.0" />
1212
<PackageReference Include="MSTest.TestFramework" Version="3.6.0" />
13-
<PackageReference Include="Selenium.Support" Version="4.25.0" />
14-
<PackageReference Include="Selenium.WebDriver" Version="4.25.0" />
13+
<PackageReference Include="Selenium.Support" Version="4.27.0" />
14+
<PackageReference Include="Selenium.WebDriver" Version="4.27.0" />
1515
</ItemGroup>
1616

1717
<ItemGroup>

Diff for: examples/java/build.gradle

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ repositories {
1010
}
1111

1212
dependencies {
13-
testImplementation 'org.seleniumhq.selenium:selenium-java:4.26.0'
14-
testImplementation 'org.junit.jupiter:junit-jupiter-engine:5.11.3'
13+
testImplementation 'org.seleniumhq.selenium:selenium-java:4.27.0'
14+
testImplementation 'org.junit.jupiter:junit-jupiter-engine:5.11.4'
1515
}
1616

1717
test {

0 commit comments

Comments
 (0)