-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'trunk' into csharp-selenium-manager-example
- Loading branch information
Showing
159 changed files
with
3,552 additions
and
2,843 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
|
@@ -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 | ||
|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,3 +11,5 @@ website_and_docs/resources | |
.settings | ||
.gitignore | ||
.pydevproject | ||
**/*.iml | ||
**/.gradle |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
102 changes: 97 additions & 5 deletions
102
examples/dotnet/SeleniumDocs/Interactions/CookiesTest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.