diff --git a/.bazelrc b/.bazelrc
index f0031fc19eab8..e4834f9759d01 100644
--- a/.bazelrc
+++ b/.bazelrc
@@ -30,10 +30,12 @@ build --tool_java_runtime_version=remotejdk_17
build --javacopt="--release 11"
# Require java dependencies to be used and first-order
-
build --experimental_strict_java_deps=strict
build --explicit_java_test_deps
+# Avoid ErrorProne getting annoyed about "impossible null checks"
+build --javacopt="-Xep:ImpossibleNullComparison:OFF"
+
# Allow spaces in runfile paths
build --nobuild_runfile_links
@@ -55,6 +57,11 @@ query --@aspect_rules_ts//ts:default_to_tsc_transpiler
build --incompatible_strict_action_env
+# Required to get `protobuf` compiling, which is required for `rules_closure`
+build --incompatible_enable_cc_toolchain_resolution
+build --cxxopt=-std=c++14
+build --host_cxxopt=-std=c++14
+
# For build stamping
build --enable_platform_specific_config
diff --git a/.github/workflows/bazel.yml b/.github/workflows/bazel.yml
index 7b86e983e85d1..96e845c5c118c 100644
--- a/.github/workflows/bazel.yml
+++ b/.github/workflows/bazel.yml
@@ -82,6 +82,12 @@ jobs:
steps:
- name: Checkout source tree
uses: actions/checkout@v4
+ - name: Pull latest changes from head ref for PRs
+ if: contains(github.head_ref, 'renovate/')
+ run: git pull origin ${{ github.head_ref }}
+ - name: Pull latest changes from ref for branch pushes
+ if: contains(github.ref, 'renovate/')
+ run: git pull origin ${{ github.ref }}
- name: Free space
if: inputs.os != 'windows'
run: ./scripts/github-actions/free-disk-space.sh
diff --git a/.github/workflows/ci-rbe.yml b/.github/workflows/ci-rbe.yml
index 2e15949925580..e5b89ac0b7f59 100644
--- a/.github/workflows/ci-rbe.yml
+++ b/.github/workflows/ci-rbe.yml
@@ -10,7 +10,7 @@ on:
jobs:
format:
name: Format
- if: github.repository_owner == 'seleniumhq'
+ if: github.repository_owner == 'seleniumhq' && startsWith(github.head_ref, 'renovate/') != true
uses: ./.github/workflows/bazel.yml
with:
name: Check format script run
@@ -20,7 +20,7 @@ jobs:
test:
name: Test
- if: github.repository_owner == 'seleniumhq'
+ if: github.repository_owner == 'seleniumhq' && startsWith(github.head_ref, 'renovate/') != true
uses: ./.github/workflows/bazel.yml
with:
name: All RBE tests
diff --git a/.github/workflows/ci-renovate-rbe.yml b/.github/workflows/ci-renovate-rbe.yml
new file mode 100644
index 0000000000000..46d5617758ddb
--- /dev/null
+++ b/.github/workflows/ci-renovate-rbe.yml
@@ -0,0 +1,68 @@
+name: CI - Renovate - RBE
+
+on:
+ push:
+ branches:
+ - renovate/*
+ workflow_dispatch:
+
+jobs:
+ pin:
+ runs-on: ubuntu-latest
+ if: github.repository_owner == 'seleniumhq'
+ steps:
+ - name: Checkout Repository
+ uses: actions/checkout@v4
+ - name: java - repin dependencies
+ if: contains(join(github.event.commits.*.message), '[java]')
+ run: RULES_JVM_EXTERNAL_REPIN=1 bazel run @maven//:pin
+ - name: rust - repin dependencies
+ if: contains(join(github.event.commits.*.message), '[rust]')
+ run: CARGO_BAZEL_REPIN=true bazel sync --only=crates
+ - name: js - repin dependencies
+ if: contains(join(github.event.commits.*.message), '[js]')
+ run: bazel run -- @pnpm//:pnpm install --dir $PWD --lockfile-only
+ - name: dotnet - repin dependencies
+ if: contains(join(github.event.commits.*.message), '[dotnet]')
+ run: ./dotnet/update-deps.sh
+ - name: py - repin dependencies
+ if: contains(join(github.event.commits.*.message), '[py]')
+ run: bazel run //py:requirements.update
+ - name: Commit files
+ run: |
+ export CHANGES=$(git status -s)
+ if [ -n "$CHANGES" ]; then
+ git config --local user.email "selenium-ci@users.noreply.github.com"
+ git config --local user.name "Selenium CI Bot"
+ git add .
+ git commit -m 'Repin dependencies'
+ git push
+ fi
+
+ check-format:
+ needs: pin
+ name: Check format
+ if: github.repository_owner == 'seleniumhq'
+ uses: ./.github/workflows/bazel.yml
+ with:
+ name: Check format script run
+ caching: false
+ ruby-version: jruby-9.4.8.0
+ run: ./scripts/github-actions/check-format.sh
+
+ test:
+ name: Test
+ needs: pin
+ if: github.repository_owner == 'seleniumhq'
+ uses: ./.github/workflows/bazel.yml
+ with:
+ name: All RBE tests
+ caching: false
+ ruby-version: jruby-9.4.8.0
+ run: ./scripts/github-actions/ci-build.sh
+
+ ci-gh:
+ name: CI - GitHub
+ needs: pin
+ if: github.repository_owner == 'seleniumhq'
+ uses: ./.github/workflows/ci.yml
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index db2c0a78857de..e200aa574f880 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -8,10 +8,14 @@ on:
schedule:
- cron: "0 */12 * * *"
workflow_dispatch:
+ workflow_call:
jobs:
check:
name: Check
+ if: >
+ github.repository_owner == 'seleniumhq' &&
+ (startsWith(github.head_ref, 'renovate/') != true || github.event_name == 'workflow_call')
runs-on: ubuntu-latest
outputs:
targets: ${{ steps.check-targets.outputs.bazel-targets }}
@@ -44,6 +48,7 @@ jobs:
if: >
github.event_name == 'schedule' ||
github.event_name == 'workflow_dispatch' ||
+ github.event_name == 'workflow_call' ||
contains(needs.check.outputs.targets, '//dotnet') ||
contains(join(github.event.commits.*.message), '[dotnet]') ||
contains(github.event.pull_request.title, '[dotnet]')
@@ -55,6 +60,7 @@ jobs:
if: >
github.event_name == 'schedule' ||
github.event_name == 'workflow_dispatch' ||
+ github.event_name == 'workflow_call' ||
contains(needs.check.outputs.targets, '//java') ||
contains(join(github.event.commits.*.message), '[java]') ||
contains(github.event.pull_request.title, '[java]')
@@ -66,6 +72,7 @@ jobs:
if: >
github.event_name == 'schedule' ||
github.event_name == 'workflow_dispatch' ||
+ github.event_name == 'workflow_call' ||
contains(needs.check.outputs.targets, '//py') ||
contains(join(github.event.commits.*.message), '[py]') ||
contains(github.event.pull_request.title, '[py]')
@@ -77,6 +84,7 @@ jobs:
if: >
github.event_name == 'schedule' ||
github.event_name == 'workflow_dispatch' ||
+ github.event_name == 'workflow_call' ||
contains(needs.check.outputs.targets, '//rb') ||
contains(join(github.event.commits.*.message), '[rb]') ||
contains(github.event.pull_request.title, '[rb]')
@@ -90,6 +98,7 @@ jobs:
if: >
github.event_name == 'schedule' ||
github.event_name == 'workflow_dispatch' ||
+ github.event_name == 'workflow_call' ||
contains(needs.check.outputs.targets, '//rust') ||
contains(join(github.event.commits.*.message), '[rust]') ||
contains(github.event.pull_request.title, '[rust]')
diff --git a/.skipped-tests b/.skipped-tests
index 3a6807a2cbb1d..2f8b21cfba2c2 100644
--- a/.skipped-tests
+++ b/.skipped-tests
@@ -5,7 +5,6 @@
-//java/test/org/openqa/selenium/edge:EdgeDriverFunctionalTest
-//java/test/org/openqa/selenium/edge:EdgeDriverFunctionalTest-edge
-//java/test/org/openqa/selenium/edge:EdgeDriverFunctionalTest-remote
--//java/test/org/openqa/selenium/federatedcredentialmanagement:FederatedCredentialManagementTest
-//java/test/org/openqa/selenium/firefox:FirefoxDriverBuilderTest
-//java/test/org/openqa/selenium/grid/gridui:OverallGridTest
-//java/test/org/openqa/selenium/grid/router:RemoteWebDriverDownloadTest
diff --git a/MODULE.bazel b/MODULE.bazel
index 9a98a3348bb0d..c1079592bf736 100644
--- a/MODULE.bazel
+++ b/MODULE.bazel
@@ -12,19 +12,19 @@ bazel_dep(name = "contrib_rules_jvm", version = "0.27.0")
bazel_dep(name = "platforms", version = "0.0.10")
# Required for the closure rules
-bazel_dep(name = "protobuf", version = "21.7", dev_dependency = True, repo_name = "com_google_protobuf")
+bazel_dep(name = "protobuf", version = "29.1", dev_dependency = True, repo_name = "com_google_protobuf")
# Required for rules_rust to import the crates properly
bazel_dep(name = "rules_cc", version = "0.0.9", dev_dependency = True)
bazel_dep(name = "rules_dotnet", version = "0.16.1")
bazel_dep(name = "rules_java", version = "7.11.1")
-bazel_dep(name = "rules_jvm_external", version = "6.3")
+bazel_dep(name = "rules_jvm_external", version = "6.6")
bazel_dep(name = "rules_nodejs", version = "6.3.0")
bazel_dep(name = "rules_oci", version = "1.7.6")
bazel_dep(name = "rules_pkg", version = "0.10.1")
bazel_dep(name = "rules_python", version = "0.33.0")
-bazel_dep(name = "rules_proto", version = "6.0.0")
+bazel_dep(name = "rules_proto", version = "6.0.2")
bazel_dep(name = "rules_ruby", version = "0.13.0")
linter = use_extension("@apple_rules_lint//lint:extensions.bzl", "linter")
@@ -169,7 +169,7 @@ maven.install(
name = "maven",
artifacts = [
"com.beust:jcommander:1.82",
- "com.github.javaparser:javaparser-core:3.26.2",
+ "com.github.javaparser:javaparser-core:3.26.3",
"com.github.spotbugs:spotbugs:4.8.6",
"com.github.stephenc.jcip:jcip-annotations:1.0-1",
"com.google.code.gson:gson:2.11.0",
@@ -181,41 +181,41 @@ maven.install(
"com.graphql-java:graphql-java:22.3",
"dev.failsafe:failsafe:3.3.2",
"io.grpc:grpc-context:1.68.1",
- "io.lettuce:lettuce-core:6.5.0.RELEASE",
- "io.netty:netty-buffer:4.1.115.Final",
- "io.netty:netty-codec-http:4.1.115.Final",
- "io.netty:netty-codec-http2:4.1.115.Final",
- "io.netty:netty-common:4.1.115.Final",
- "io.netty:netty-handler:4.1.115.Final",
- "io.netty:netty-handler-proxy:4.1.115.Final",
- "io.netty:netty-transport:4.1.115.Final",
- "io.opentelemetry:opentelemetry-api:1.44.1",
- "io.opentelemetry:opentelemetry-context:1.44.1",
- "io.opentelemetry:opentelemetry-exporter-logging:1.44.1",
- "io.opentelemetry:opentelemetry-sdk:1.44.1",
- "io.opentelemetry:opentelemetry-sdk-common:1.44.1",
- "io.opentelemetry:opentelemetry-sdk-extension-autoconfigure:1.44.1",
- "io.opentelemetry:opentelemetry-sdk-extension-autoconfigure-spi:1.44.1",
- "io.opentelemetry:opentelemetry-sdk-testing:1.44.1",
- "io.opentelemetry:opentelemetry-sdk-trace:1.44.1",
- "io.opentelemetry.semconv:opentelemetry-semconv:1.25.0-alpha",
+ "io.lettuce:lettuce-core:6.5.1.RELEASE",
+ "io.netty:netty-buffer",
+ "io.netty:netty-codec-http",
+ "io.netty:netty-codec-http2",
+ "io.netty:netty-common",
+ "io.netty:netty-handler",
+ "io.netty:netty-handler-proxy",
+ "io.netty:netty-transport",
+ "io.opentelemetry:opentelemetry-api",
+ "io.opentelemetry:opentelemetry-context",
+ "io.opentelemetry:opentelemetry-exporter-logging",
+ "io.opentelemetry:opentelemetry-sdk",
+ "io.opentelemetry:opentelemetry-sdk-common",
+ "io.opentelemetry:opentelemetry-sdk-extension-autoconfigure",
+ "io.opentelemetry:opentelemetry-sdk-extension-autoconfigure-spi",
+ "io.opentelemetry:opentelemetry-sdk-testing",
+ "io.opentelemetry:opentelemetry-sdk-trace",
+ "io.opentelemetry.semconv:opentelemetry-semconv:1.28.0-alpha",
"it.ozimov:embedded-redis:0.7.3",
- "net.bytebuddy:byte-buddy:1.15.10",
+ "net.bytebuddy:byte-buddy:1.15.11",
"org.htmlunit:htmlunit-core-js:4.6.0",
"org.apache.commons:commons-exec:1.4.0",
- "org.apache.logging.log4j:log4j-core:2.24.1",
+ "org.apache.logging.log4j:log4j-core:2.24.3",
"org.assertj:assertj-core:3.26.3",
"org.bouncycastle:bcpkix-jdk18on:1.79",
"org.eclipse.mylyn.github:org.eclipse.egit.github.core:2.1.5",
"org.hsqldb:hsqldb:2.7.4",
"org.jspecify:jspecify:1.0.0",
- "org.junit.jupiter:junit-jupiter-api:5.11.3",
- "org.junit.jupiter:junit-jupiter-engine:5.11.3",
- "org.junit.jupiter:junit-jupiter-params:5.11.3",
- "org.junit.platform:junit-platform-launcher:1.11.3",
- "org.junit.platform:junit-platform-reporting:1.11.3",
- "org.junit.platform:junit-platform-commons:1.11.3",
- "org.junit.platform:junit-platform-engine:1.11.3",
+ "org.junit.jupiter:junit-jupiter-api",
+ "org.junit.jupiter:junit-jupiter-engine",
+ "org.junit.jupiter:junit-jupiter-params",
+ "org.junit.platform:junit-platform-launcher",
+ "org.junit.platform:junit-platform-reporting",
+ "org.junit.platform:junit-platform-commons",
+ "org.junit.platform:junit-platform-engine",
"org.mockito:mockito-core:5.14.2",
"org.redisson:redisson:3.39.0",
"org.slf4j:slf4j-api:2.0.16",
@@ -223,6 +223,11 @@ maven.install(
"org.tomlj:tomlj:1.1.1",
"org.zeromq:jeromq:0.6.0",
],
+ boms = [
+ "io.opentelemetry:opentelemetry-bom:1.44.1",
+ "io.netty:netty-bom:4.1.115.Final",
+ "org.junit:junit-bom:5.11.3",
+ ],
excluded_artifacts = [
"org.hamcrest:hamcrest-all", # Replaced by hamcrest 2
"org.hamcrest:hamcrest-core",
@@ -235,6 +240,7 @@ maven.install(
repositories = [
"https://repo1.maven.org/maven2",
],
+ resolver = "maven",
strict_visibility = True,
)
use_repo(maven, "maven", "unpinned_maven")
diff --git a/README.md b/README.md
index fe7ce42b18ccb..07feb7d568351 100644
--- a/README.md
+++ b/README.md
@@ -1,6 +1,7 @@
# Selenium
[![CI](https://github.com/SeleniumHQ/selenium/actions/workflows/ci.yml/badge.svg?branch=trunk&event=schedule)](https://github.com/SeleniumHQ/selenium/actions/workflows/ci.yml)
+[![CI - RBE](https://github.com/SeleniumHQ/selenium/actions/workflows/ci-rbe.yml/badge.svg?branch=trunk&event=schedule)](https://github.com/SeleniumHQ/selenium/actions/workflows/ci-rbe.yml)
[![Releases downloads](https://img.shields.io/github/downloads/SeleniumHQ/selenium/total.svg)](https://github.com/SeleniumHQ/selenium/releases)
diff --git a/Rakefile b/Rakefile
index 7ee7099acb135..24bb5ace8e78b 100644
--- a/Rakefile
+++ b/Rakefile
@@ -585,8 +585,7 @@ namespace :py do
nightly = ".#{Time.now.strftime('%Y%m%d%H%M')}"
new_version = updated_version(old_version, arguments[:version], nightly)
- ['py/setup.py',
- 'py/pyproject.toml',
+ ['py/pyproject.toml',
'py/BUILD.bazel',
'py/selenium/__init__.py',
'py/selenium/webdriver/__init__.py',
@@ -1048,7 +1047,6 @@ namespace :all do
'py/selenium/webdriver/__init__.py',
'py/selenium/__init__.py',
'py/BUILD.bazel',
- 'py/setup.py',
'rb/lib/selenium/webdriver/version.rb',
'rb/Gemfile.lock'])
@@ -1110,7 +1108,6 @@ namespace :all do
'py/selenium/webdriver/__init__.py',
'py/BUILD.bazel',
'py/CHANGES',
- 'py/setup.py',
'rb/lib/selenium/webdriver/version.rb',
'rb/CHANGES',
'rb/Gemfile.lock',
diff --git a/WORKSPACE b/WORKSPACE
index 98cec87d366b7..b33f16328442d 100644
--- a/WORKSPACE
+++ b/WORKSPACE
@@ -6,17 +6,8 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
http_archive(
name = "io_bazel_rules_closure",
- patch_args = [
- "-p1",
- ],
- patches = [
- "//javascript:rules_closure_shell.patch",
- ],
- sha256 = "d66deed38a0bb20581c15664f0ab62270af5940786855c7adc3087b27168b529",
- strip_prefix = "rules_closure-0.11.0",
- urls = [
- "https://github.com/bazelbuild/rules_closure/archive/0.11.0.tar.gz",
- ],
+ strip_prefix = "rules_closure-0.12.0",
+ url = "https://github.com/bazelbuild/rules_closure/archive/refs/tags/0.12.0.tar.gz",
)
load("@io_bazel_rules_closure//closure:repositories.bzl", "rules_closure_dependencies", "rules_closure_toolchains")
@@ -34,8 +25,8 @@ rules_closure_toolchains()
http_archive(
name = "rules_rust",
- integrity = "sha256-Zx3bP+Xrz53TTQUeynNS+68z+lO/Ye7Qt1pMNIKeVIA=",
- urls = ["https://github.com/bazelbuild/rules_rust/releases/download/0.52.2/rules_rust-v0.52.2.tar.gz"],
+ integrity = "sha256-eEXiHXSGUH6qD1bdI5KXZ/B04m0wIUeoyM7pmujzbbQ=",
+ urls = ["https://github.com/bazelbuild/rules_rust/releases/download/0.55.5/rules_rust-0.55.5.tar.gz"],
)
load("@rules_rust//rust:repositories.bzl", "rules_rust_dependencies", "rust_register_toolchains")
diff --git a/common/repositories.bzl b/common/repositories.bzl
index ba420b18bf293..519f86f933c93 100644
--- a/common/repositories.bzl
+++ b/common/repositories.bzl
@@ -11,8 +11,8 @@ def pin_browsers():
http_archive(
name = "linux_firefox",
- url = "https://ftp.mozilla.org/pub/firefox/releases/132.0.2/linux-x86_64/en-US/firefox-132.0.2.tar.bz2",
- sha256 = "777d47f8b8710ab450582dc0dc0cdf8f43c2291249b3eaf740ee28ee34cda139",
+ url = "https://ftp.mozilla.org/pub/firefox/releases/133.0.3/linux-x86_64/en-US/firefox-133.0.3.tar.bz2",
+ sha256 = "43713e238d0153fdbf1ab46dd76c6b01ab83fae197b5dc3a95087f51907ba44d",
build_file_content = """
load("@aspect_rules_js//js:defs.bzl", "js_library")
package(default_visibility = ["//visibility:public"])
@@ -33,8 +33,8 @@ js_library(
dmg_archive(
name = "mac_firefox",
- url = "https://ftp.mozilla.org/pub/firefox/releases/132.0.2/mac/en-US/Firefox%20132.0.2.dmg",
- sha256 = "233251c46eb4964868d815a9233cab855ac6160736310771a67af93a9b78224d",
+ url = "https://ftp.mozilla.org/pub/firefox/releases/133.0.3/mac/en-US/Firefox%20133.0.3.dmg",
+ sha256 = "9ceb4fa2120228f287e6c654cef7898b4cce0a659270056276b8884581267d3b",
build_file_content = """
load("@aspect_rules_js//js:defs.bzl", "js_library")
package(default_visibility = ["//visibility:public"])
@@ -50,8 +50,8 @@ js_library(
http_archive(
name = "linux_beta_firefox",
- url = "https://ftp.mozilla.org/pub/firefox/releases/133.0b9/linux-x86_64/en-US/firefox-133.0b9.tar.bz2",
- sha256 = "5c9f79912bfbf892d2b676973a26ffc078ee9b8fd9b791bfa856db030e657750",
+ url = "https://ftp.mozilla.org/pub/firefox/releases/134.0b10/linux-x86_64/en-US/firefox-134.0b10.tar.bz2",
+ sha256 = "b933fec8e13c6a1ad42053881f9210aedd22c51d303bd41b1402f0f7db43a1ab",
build_file_content = """
load("@aspect_rules_js//js:defs.bzl", "js_library")
package(default_visibility = ["//visibility:public"])
@@ -72,8 +72,8 @@ js_library(
dmg_archive(
name = "mac_beta_firefox",
- url = "https://ftp.mozilla.org/pub/firefox/releases/133.0b9/mac/en-US/Firefox%20133.0b9.dmg",
- sha256 = "0eb0fabe9216dc80c2ca403dd2eba935d71f2bdc1dea1d1cc37f03666ef094d1",
+ url = "https://ftp.mozilla.org/pub/firefox/releases/134.0b10/mac/en-US/Firefox%20134.0b10.dmg",
+ sha256 = "d6e74c4f89b4a6d2c0cd81f322ffc45c1e8b391d646fbc61533fc618b8f12ead",
build_file_content = """
load("@aspect_rules_js//js:defs.bzl", "js_library")
package(default_visibility = ["//visibility:public"])
@@ -123,10 +123,10 @@ js_library(
pkg_archive(
name = "mac_edge",
- url = "https://msedge.sf.dl.delivery.mp.microsoft.com/filestreamingservice/files/08b226c9-fbe8-43c0-94fe-ed9c3eeb8f59/MicrosoftEdge-131.0.2903.51.pkg",
- sha256 = "5bc1eab86bb315aa9f2cd2b7d9afe072df35280f6e6d1a9ca9c108d95bda8acd",
+ url = "https://msedge.sf.dl.delivery.mp.microsoft.com/filestreamingservice/files/3e7ebcc4-eac0-41fe-b43b-4d1aa1ba237c/MicrosoftEdge-131.0.2903.112.pkg",
+ sha256 = "648233d6654a3b0a9b651f31c33260125b6410e956b698970b8b789ad4fa7d16",
move = {
- "MicrosoftEdge-131.0.2903.51.pkg/Payload/Microsoft Edge.app": "Edge.app",
+ "MicrosoftEdge-131.0.2903.112.pkg/Payload/Microsoft Edge.app": "Edge.app",
},
build_file_content = """
load("@aspect_rules_js//js:defs.bzl", "js_library")
@@ -143,8 +143,8 @@ js_library(
deb_archive(
name = "linux_edge",
- url = "https://packages.microsoft.com/repos/edge/pool/main/m/microsoft-edge-stable/microsoft-edge-stable_131.0.2903.51-1_amd64.deb",
- sha256 = "8aad12c97bcae417ff9cc4251b75211eeda7f1513312dc57b2f744e824e028c0",
+ url = "https://packages.microsoft.com/repos/edge/pool/main/m/microsoft-edge-stable/microsoft-edge-stable_131.0.2903.112-1_amd64.deb",
+ sha256 = "e2a40d728057392e14cfe311e2322d3a072730aa81e89e78d5cbeb6f999dfe87",
build_file_content = """
load("@aspect_rules_js//js:defs.bzl", "js_library")
package(default_visibility = ["//visibility:public"])
@@ -165,8 +165,8 @@ js_library(
http_archive(
name = "linux_edgedriver",
- url = "https://msedgedriver.azureedge.net/131.0.2903.52/edgedriver_linux64.zip",
- sha256 = "ddbeda7cec5ed16b96c3cf0f6759de30e4f3726da9da31bfba1371ccd8fcfd14",
+ url = "https://msedgedriver.azureedge.net/131.0.2903.112/edgedriver_linux64.zip",
+ sha256 = "1a262ac6b21d6c59e94b23dd6674d050e570b239f008d31c4701a009e759333f",
build_file_content = """
load("@aspect_rules_js//js:defs.bzl", "js_library")
package(default_visibility = ["//visibility:public"])
@@ -182,8 +182,8 @@ js_library(
http_archive(
name = "mac_edgedriver",
- url = "https://msedgedriver.azureedge.net/131.0.2903.56/edgedriver_mac64.zip",
- sha256 = "4f4d1d5b45849677f8d8e706f7b5ca9ebb99f40ed3b4ee203c2535a3429e0d5b",
+ url = "https://msedgedriver.azureedge.net/131.0.2903.112/edgedriver_mac64.zip",
+ sha256 = "55c3a1445a72dfad0be7285dae3e36540d8eb22f9fd69f4abfdc35370b1f1440",
build_file_content = """
load("@aspect_rules_js//js:defs.bzl", "js_library")
package(default_visibility = ["//visibility:public"])
@@ -199,8 +199,8 @@ js_library(
http_archive(
name = "linux_chrome",
- url = "https://storage.googleapis.com/chrome-for-testing-public/131.0.6778.85/linux64/chrome-linux64.zip",
- sha256 = "3a6d928b0002ec012a53b6bb65dcaf95add008adc223c961d566d824982a767e",
+ url = "https://storage.googleapis.com/chrome-for-testing-public/131.0.6778.204/linux64/chrome-linux64.zip",
+ sha256 = "fba7d5e87cdcf0dc974c9ac8a0a9dbcf5686c935455d5e6beed337c6ada88bc2",
build_file_content = """
load("@aspect_rules_js//js:defs.bzl", "js_library")
package(default_visibility = ["//visibility:public"])
@@ -221,8 +221,8 @@ js_library(
http_archive(
name = "mac_chrome",
- url = "https://storage.googleapis.com/chrome-for-testing-public/131.0.6778.85/mac-x64/chrome-mac-x64.zip",
- sha256 = "e26a606e2a3da403c6e1e93617a7b51ee010706614eb88de5b16470276e0896b",
+ url = "https://storage.googleapis.com/chrome-for-testing-public/131.0.6778.204/mac-x64/chrome-mac-x64.zip",
+ sha256 = "c964e23fe9793e82bcf98b2e90e92862b6dae823a5819c05ee0d5fa511c60684",
strip_prefix = "chrome-mac-x64",
patch_cmds = [
"mv 'Google Chrome for Testing.app' Chrome.app",
@@ -243,8 +243,8 @@ js_library(
http_archive(
name = "linux_chromedriver",
- url = "https://storage.googleapis.com/chrome-for-testing-public/131.0.6778.85/linux64/chromedriver-linux64.zip",
- sha256 = "33910b16568feabd2b50a26a2c4456d154c760d6e28347427f99c025661a4f3e",
+ url = "https://storage.googleapis.com/chrome-for-testing-public/131.0.6778.204/linux64/chromedriver-linux64.zip",
+ sha256 = "7a444e38b944dee838f6063712382c3dff7ccae395821dbb9dbde28ec5d08468",
strip_prefix = "chromedriver-linux64",
build_file_content = """
load("@aspect_rules_js//js:defs.bzl", "js_library")
@@ -261,8 +261,8 @@ js_library(
http_archive(
name = "mac_chromedriver",
- url = "https://storage.googleapis.com/chrome-for-testing-public/131.0.6778.85/mac-x64/chromedriver-mac-x64.zip",
- sha256 = "ee194eba1d52dea61dfbf08b05a2ce139660e9c7d20d15024c3a0757ac4a5fcb",
+ url = "https://storage.googleapis.com/chrome-for-testing-public/131.0.6778.204/mac-x64/chromedriver-mac-x64.zip",
+ sha256 = "5dcaf1bbc39d06eb7c2b5a8a2c43946d6d785648e1b392267790d11bc5a119d9",
strip_prefix = "chromedriver-mac-x64",
build_file_content = """
load("@aspect_rules_js//js:defs.bzl", "js_library")
diff --git a/common/src/web/fedcm/fedcm.json b/common/src/web/fedcm/config.json
similarity index 50%
rename from common/src/web/fedcm/fedcm.json
rename to common/src/web/fedcm/config.json
index 0bb2ca15f0d1f..45755f6b0f9be 100644
--- a/common/src/web/fedcm/fedcm.json
+++ b/common/src/web/fedcm/config.json
@@ -1,7 +1,7 @@
{
"accounts_endpoint": "accounts.json",
"client_metadata_endpoint": "client_metadata.json",
- "id_assertion_endpoint": "id_assertion",
- "signin_url": "/signin",
- "login_url": "/login"
+ "id_assertion_endpoint": "id_assertion.json",
+ "signin_url": "signin",
+ "login_url": "login"
}
diff --git a/common/src/web/fedcm/fedcm.html b/common/src/web/fedcm/fedcm.html
index bdf10e2fa8f2d..62e9e53a616cd 100644
--- a/common/src/web/fedcm/fedcm.html
+++ b/common/src/web/fedcm/fedcm.html
@@ -1,7 +1,7 @@
+
\ No newline at end of file
diff --git a/common/src/web/fedcm/fedcm_async.html b/common/src/web/fedcm/fedcm_async.html
new file mode 100644
index 0000000000000..2c10510ad9caa
--- /dev/null
+++ b/common/src/web/fedcm/fedcm_async.html
@@ -0,0 +1,37 @@
+
+
+
+ FedCM Example
+
+
+ Trigger FedCM
+
+
+
+
+
\ No newline at end of file
diff --git a/common/src/web/fedcm/login.html b/common/src/web/fedcm/login.html
new file mode 100644
index 0000000000000..10329a440bc66
--- /dev/null
+++ b/common/src/web/fedcm/login.html
@@ -0,0 +1,11 @@
+
+
+
+ Login
+
+
+ Login Page
+ Login successful! This is a placeholder for the login process.
+ Return to Home
+
+
\ No newline at end of file
diff --git a/common/src/web/fedcm/signin.html b/common/src/web/fedcm/signin.html
new file mode 100644
index 0000000000000..90fd68e1a6dc5
--- /dev/null
+++ b/common/src/web/fedcm/signin.html
@@ -0,0 +1,19 @@
+
+
+
+ Sign In
+
+
+ Sign In Page
+ This is a placeholder for the sign-in page.
+
+
+
\ No newline at end of file
diff --git a/common/src/web/locators_tests/locators.html b/common/src/web/locators_tests/locators.html
new file mode 100644
index 0000000000000..881bcba2d95da
--- /dev/null
+++ b/common/src/web/locators_tests/locators.html
@@ -0,0 +1,30 @@
+
+
+
+Contact Selenium
+
+
+
+To know more about Selenium, visit the official page
+Selenium Official Page
+
+
+
+
diff --git a/dotnet/paket.nuget.bzl b/dotnet/paket.nuget.bzl
index abb3561080e65..d2930cfef4b7e 100644
--- a/dotnet/paket.nuget.bzl
+++ b/dotnet/paket.nuget.bzl
@@ -50,7 +50,7 @@ def nuget():
{"name": "System.Security.Principal.Windows", "id": "System.Security.Principal.Windows", "version": "5.0.0", "sha512": "sha512-RKkgqq8ishctQTGbtXqyuOGkUx1fAhkqb1OoHYdRJRlbYLoLWkSkWYHRN/17DzplsSlZtf2Xr8BXjNhO8nRnzQ==", "sources": ["https://api.nuget.org/v3/index.json"], "dependencies": {"net11": [], "net20": [], "net30": [], "net35": [], "net40": [], "net403": [], "net45": [], "net451": [], "net452": [], "net46": [], "net461": [], "net462": [], "net47": [], "net471": [], "net472": [], "net48": [], "net5.0": [], "net6.0": [], "net7.0": [], "net8.0": [], "netcoreapp1.0": ["System.Reflection", "System.Runtime", "System.Runtime.Handles", "System.Runtime.InteropServices", "System.Text.Encoding"], "netcoreapp1.1": ["System.Reflection", "System.Runtime", "System.Runtime.Handles", "System.Runtime.InteropServices", "System.Text.Encoding"], "netcoreapp2.0": ["Microsoft.NETCore.Platforms"], "netcoreapp2.1": ["Microsoft.NETCore.Platforms"], "netcoreapp2.2": ["Microsoft.NETCore.Platforms"], "netcoreapp3.0": [], "netcoreapp3.1": [], "netstandard": [], "netstandard1.0": [], "netstandard1.1": [], "netstandard1.2": [], "netstandard1.3": ["System.Reflection", "System.Runtime", "System.Runtime.Handles", "System.Runtime.InteropServices", "System.Text.Encoding"], "netstandard1.4": ["System.Reflection", "System.Runtime", "System.Runtime.Handles", "System.Runtime.InteropServices", "System.Text.Encoding"], "netstandard1.5": ["System.Reflection", "System.Runtime", "System.Runtime.Handles", "System.Runtime.InteropServices", "System.Text.Encoding"], "netstandard1.6": ["System.Reflection", "System.Runtime", "System.Runtime.Handles", "System.Runtime.InteropServices", "System.Text.Encoding"], "netstandard2.0": [], "netstandard2.1": []}, "targeting_pack_overrides": [], "framework_list": []},
{"name": "System.Text.Encoding", "id": "System.Text.Encoding", "version": "4.3.0", "sha512": "sha512-b/f+7HMTpxIfeV7H03bkuHKMFylCGfr9/U6gePnfFFW0aF8LOWLDgQCY6V1oWUqDksC3mdNuyChM1vy9TP4sZw==", "sources": ["https://api.nuget.org/v3/index.json"], "dependencies": {"net11": [], "net20": [], "net30": [], "net35": [], "net40": [], "net403": [], "net45": [], "net451": [], "net452": [], "net46": [], "net461": [], "net462": [], "net47": [], "net471": [], "net472": [], "net48": [], "net5.0": ["Microsoft.NETCore.Platforms", "Microsoft.NETCore.Targets", "System.Runtime"], "net6.0": ["Microsoft.NETCore.Platforms", "Microsoft.NETCore.Targets", "System.Runtime"], "net7.0": ["Microsoft.NETCore.Platforms", "Microsoft.NETCore.Targets", "System.Runtime"], "net8.0": ["Microsoft.NETCore.Platforms", "Microsoft.NETCore.Targets", "System.Runtime"], "netcoreapp1.0": ["Microsoft.NETCore.Platforms", "Microsoft.NETCore.Targets", "System.Runtime"], "netcoreapp1.1": ["Microsoft.NETCore.Platforms", "Microsoft.NETCore.Targets", "System.Runtime"], "netcoreapp2.0": ["Microsoft.NETCore.Platforms", "Microsoft.NETCore.Targets", "System.Runtime"], "netcoreapp2.1": ["Microsoft.NETCore.Platforms", "Microsoft.NETCore.Targets", "System.Runtime"], "netcoreapp2.2": ["Microsoft.NETCore.Platforms", "Microsoft.NETCore.Targets", "System.Runtime"], "netcoreapp3.0": ["Microsoft.NETCore.Platforms", "Microsoft.NETCore.Targets", "System.Runtime"], "netcoreapp3.1": ["Microsoft.NETCore.Platforms", "Microsoft.NETCore.Targets", "System.Runtime"], "netstandard": [], "netstandard1.0": ["Microsoft.NETCore.Platforms", "Microsoft.NETCore.Targets", "System.Runtime"], "netstandard1.1": ["Microsoft.NETCore.Platforms", "Microsoft.NETCore.Targets", "System.Runtime"], "netstandard1.2": ["Microsoft.NETCore.Platforms", "Microsoft.NETCore.Targets", "System.Runtime"], "netstandard1.3": ["Microsoft.NETCore.Platforms", "Microsoft.NETCore.Targets", "System.Runtime"], "netstandard1.4": ["Microsoft.NETCore.Platforms", "Microsoft.NETCore.Targets", "System.Runtime"], "netstandard1.5": ["Microsoft.NETCore.Platforms", "Microsoft.NETCore.Targets", "System.Runtime"], "netstandard1.6": ["Microsoft.NETCore.Platforms", "Microsoft.NETCore.Targets", "System.Runtime"], "netstandard2.0": ["Microsoft.NETCore.Platforms", "Microsoft.NETCore.Targets", "System.Runtime"], "netstandard2.1": ["Microsoft.NETCore.Platforms", "Microsoft.NETCore.Targets", "System.Runtime"]}, "targeting_pack_overrides": [], "framework_list": []},
{"name": "System.Text.Encodings.Web", "id": "System.Text.Encodings.Web", "version": "8.0.0", "sha512": "sha512-uggiw4w7ZYq6lJVkLSaeiCuCfjvkrS3BQm2Kl9PLxaInfF+AhH0MuTgQeK8BUjMoxJksqgWBRtXY7muKCGCcMg==", "sources": ["https://api.nuget.org/v3/index.json"], "dependencies": {"net11": [], "net20": [], "net30": [], "net35": [], "net40": [], "net403": [], "net45": [], "net451": [], "net452": [], "net46": [], "net461": ["System.Buffers", "System.Memory", "System.Runtime.CompilerServices.Unsafe"], "net462": ["System.Buffers", "System.Memory", "System.Runtime.CompilerServices.Unsafe"], "net47": ["System.Buffers", "System.Memory", "System.Runtime.CompilerServices.Unsafe"], "net471": ["System.Buffers", "System.Memory", "System.Runtime.CompilerServices.Unsafe"], "net472": ["System.Buffers", "System.Memory", "System.Runtime.CompilerServices.Unsafe"], "net48": ["System.Buffers", "System.Memory", "System.Runtime.CompilerServices.Unsafe"], "net5.0": ["System.Buffers", "System.Memory", "System.Runtime.CompilerServices.Unsafe"], "net6.0": ["System.Runtime.CompilerServices.Unsafe"], "net7.0": [], "net8.0": [], "netcoreapp1.0": [], "netcoreapp1.1": [], "netcoreapp2.0": ["System.Buffers", "System.Memory", "System.Runtime.CompilerServices.Unsafe"], "netcoreapp2.1": ["System.Buffers", "System.Memory", "System.Runtime.CompilerServices.Unsafe"], "netcoreapp2.2": ["System.Buffers", "System.Memory", "System.Runtime.CompilerServices.Unsafe"], "netcoreapp3.0": ["System.Buffers", "System.Memory", "System.Runtime.CompilerServices.Unsafe"], "netcoreapp3.1": ["System.Buffers", "System.Memory", "System.Runtime.CompilerServices.Unsafe"], "netstandard": [], "netstandard1.0": [], "netstandard1.1": [], "netstandard1.2": [], "netstandard1.3": [], "netstandard1.4": [], "netstandard1.5": [], "netstandard1.6": [], "netstandard2.0": ["System.Buffers", "System.Memory", "System.Runtime.CompilerServices.Unsafe"], "netstandard2.1": ["System.Buffers", "System.Memory", "System.Runtime.CompilerServices.Unsafe"]}, "targeting_pack_overrides": [], "framework_list": []},
- {"name": "System.Text.Json", "id": "System.Text.Json", "version": "8.0.4", "sha512": "sha512-n4fuKjm6T2AqKz7HWEuKosA6f22x4wP0giTbwTndvzyxAZC+BO/h0VkrC/Wy/Zf22PiP1JKkX3eLhP0+YTrLAA==", "sources": ["https://api.nuget.org/v3/index.json"], "dependencies": {"net11": [], "net20": [], "net30": [], "net35": [], "net40": [], "net403": [], "net45": [], "net451": [], "net452": [], "net46": [], "net461": ["Microsoft.Bcl.AsyncInterfaces", "System.Text.Encodings.Web", "System.Buffers", "System.Memory", "System.Runtime.CompilerServices.Unsafe", "System.Threading.Tasks.Extensions"], "net462": ["Microsoft.Bcl.AsyncInterfaces", "System.Text.Encodings.Web", "System.Buffers", "System.Memory", "System.Runtime.CompilerServices.Unsafe", "System.Threading.Tasks.Extensions"], "net47": ["Microsoft.Bcl.AsyncInterfaces", "System.Text.Encodings.Web", "System.Buffers", "System.Memory", "System.Runtime.CompilerServices.Unsafe", "System.Threading.Tasks.Extensions"], "net471": ["Microsoft.Bcl.AsyncInterfaces", "System.Text.Encodings.Web", "System.Buffers", "System.Memory", "System.Runtime.CompilerServices.Unsafe", "System.Threading.Tasks.Extensions"], "net472": ["Microsoft.Bcl.AsyncInterfaces", "System.Text.Encodings.Web", "System.Buffers", "System.Memory", "System.Runtime.CompilerServices.Unsafe", "System.Threading.Tasks.Extensions"], "net48": ["Microsoft.Bcl.AsyncInterfaces", "System.Text.Encodings.Web", "System.Buffers", "System.Memory", "System.Runtime.CompilerServices.Unsafe", "System.Threading.Tasks.Extensions"], "net5.0": ["Microsoft.Bcl.AsyncInterfaces", "System.Text.Encodings.Web", "System.Buffers", "System.Memory", "System.Runtime.CompilerServices.Unsafe", "System.Threading.Tasks.Extensions"], "net6.0": ["System.Text.Encodings.Web", "System.Runtime.CompilerServices.Unsafe"], "net7.0": ["System.Text.Encodings.Web"], "net8.0": ["System.Text.Encodings.Web"], "netcoreapp1.0": [], "netcoreapp1.1": [], "netcoreapp2.0": ["Microsoft.Bcl.AsyncInterfaces", "System.Text.Encodings.Web", "System.Buffers", "System.Memory", "System.Runtime.CompilerServices.Unsafe", "System.Threading.Tasks.Extensions"], "netcoreapp2.1": ["Microsoft.Bcl.AsyncInterfaces", "System.Text.Encodings.Web", "System.Buffers", "System.Memory", "System.Runtime.CompilerServices.Unsafe", "System.Threading.Tasks.Extensions"], "netcoreapp2.2": ["Microsoft.Bcl.AsyncInterfaces", "System.Text.Encodings.Web", "System.Buffers", "System.Memory", "System.Runtime.CompilerServices.Unsafe", "System.Threading.Tasks.Extensions"], "netcoreapp3.0": ["Microsoft.Bcl.AsyncInterfaces", "System.Text.Encodings.Web", "System.Buffers", "System.Memory", "System.Runtime.CompilerServices.Unsafe", "System.Threading.Tasks.Extensions"], "netcoreapp3.1": ["Microsoft.Bcl.AsyncInterfaces", "System.Text.Encodings.Web", "System.Buffers", "System.Memory", "System.Runtime.CompilerServices.Unsafe", "System.Threading.Tasks.Extensions"], "netstandard": [], "netstandard1.0": [], "netstandard1.1": [], "netstandard1.2": [], "netstandard1.3": [], "netstandard1.4": [], "netstandard1.5": [], "netstandard1.6": [], "netstandard2.0": ["Microsoft.Bcl.AsyncInterfaces", "System.Text.Encodings.Web", "System.Buffers", "System.Memory", "System.Runtime.CompilerServices.Unsafe", "System.Threading.Tasks.Extensions"], "netstandard2.1": ["Microsoft.Bcl.AsyncInterfaces", "System.Text.Encodings.Web", "System.Buffers", "System.Memory", "System.Runtime.CompilerServices.Unsafe", "System.Threading.Tasks.Extensions"]}, "targeting_pack_overrides": [], "framework_list": []},
+ {"name": "System.Text.Json", "id": "System.Text.Json", "version": "8.0.5", "sha512": "sha512-E1iQIa4+gfVMh3q/YTzpMcwkyle/EnrxBjzMHrTcV6bMIjph5kUiB/XQ3ORTtmJ0MOMeQUPHjnHptd1kf2gKvw==", "sources": ["https://api.nuget.org/v3/index.json"], "dependencies": {"net11": [], "net20": [], "net30": [], "net35": [], "net40": [], "net403": [], "net45": [], "net451": [], "net452": [], "net46": [], "net461": ["Microsoft.Bcl.AsyncInterfaces", "System.Text.Encodings.Web", "System.Buffers", "System.Memory", "System.Runtime.CompilerServices.Unsafe", "System.Threading.Tasks.Extensions"], "net462": ["Microsoft.Bcl.AsyncInterfaces", "System.Text.Encodings.Web", "System.Buffers", "System.Memory", "System.Runtime.CompilerServices.Unsafe", "System.Threading.Tasks.Extensions"], "net47": ["Microsoft.Bcl.AsyncInterfaces", "System.Text.Encodings.Web", "System.Buffers", "System.Memory", "System.Runtime.CompilerServices.Unsafe", "System.Threading.Tasks.Extensions"], "net471": ["Microsoft.Bcl.AsyncInterfaces", "System.Text.Encodings.Web", "System.Buffers", "System.Memory", "System.Runtime.CompilerServices.Unsafe", "System.Threading.Tasks.Extensions"], "net472": ["Microsoft.Bcl.AsyncInterfaces", "System.Text.Encodings.Web", "System.Buffers", "System.Memory", "System.Runtime.CompilerServices.Unsafe", "System.Threading.Tasks.Extensions"], "net48": ["Microsoft.Bcl.AsyncInterfaces", "System.Text.Encodings.Web", "System.Buffers", "System.Memory", "System.Runtime.CompilerServices.Unsafe", "System.Threading.Tasks.Extensions"], "net5.0": ["Microsoft.Bcl.AsyncInterfaces", "System.Text.Encodings.Web", "System.Buffers", "System.Memory", "System.Runtime.CompilerServices.Unsafe", "System.Threading.Tasks.Extensions"], "net6.0": ["System.Text.Encodings.Web", "System.Runtime.CompilerServices.Unsafe"], "net7.0": ["System.Text.Encodings.Web"], "net8.0": [], "netcoreapp1.0": [], "netcoreapp1.1": [], "netcoreapp2.0": ["Microsoft.Bcl.AsyncInterfaces", "System.Text.Encodings.Web", "System.Buffers", "System.Memory", "System.Runtime.CompilerServices.Unsafe", "System.Threading.Tasks.Extensions"], "netcoreapp2.1": ["Microsoft.Bcl.AsyncInterfaces", "System.Text.Encodings.Web", "System.Buffers", "System.Memory", "System.Runtime.CompilerServices.Unsafe", "System.Threading.Tasks.Extensions"], "netcoreapp2.2": ["Microsoft.Bcl.AsyncInterfaces", "System.Text.Encodings.Web", "System.Buffers", "System.Memory", "System.Runtime.CompilerServices.Unsafe", "System.Threading.Tasks.Extensions"], "netcoreapp3.0": ["Microsoft.Bcl.AsyncInterfaces", "System.Text.Encodings.Web", "System.Buffers", "System.Memory", "System.Runtime.CompilerServices.Unsafe", "System.Threading.Tasks.Extensions"], "netcoreapp3.1": ["Microsoft.Bcl.AsyncInterfaces", "System.Text.Encodings.Web", "System.Buffers", "System.Memory", "System.Runtime.CompilerServices.Unsafe", "System.Threading.Tasks.Extensions"], "netstandard": [], "netstandard1.0": [], "netstandard1.1": [], "netstandard1.2": [], "netstandard1.3": [], "netstandard1.4": [], "netstandard1.5": [], "netstandard1.6": [], "netstandard2.0": ["Microsoft.Bcl.AsyncInterfaces", "System.Text.Encodings.Web", "System.Buffers", "System.Memory", "System.Runtime.CompilerServices.Unsafe", "System.Threading.Tasks.Extensions"], "netstandard2.1": ["Microsoft.Bcl.AsyncInterfaces", "System.Text.Encodings.Web", "System.Buffers", "System.Memory", "System.Runtime.CompilerServices.Unsafe", "System.Threading.Tasks.Extensions"]}, "targeting_pack_overrides": [], "framework_list": []},
{"name": "System.Threading.Tasks", "id": "System.Threading.Tasks", "version": "4.3.0", "sha512": "sha512-fUiP+CyyCjs872OA8trl6p97qma/da1xGq3h4zAbJZk8zyaU4zyEfqW5vbkP80xG/Nimun1vlWBboMEk7XxdEw==", "sources": ["https://api.nuget.org/v3/index.json"], "dependencies": {"net11": [], "net20": [], "net30": [], "net35": [], "net40": [], "net403": [], "net45": [], "net451": [], "net452": [], "net46": [], "net461": [], "net462": [], "net47": [], "net471": [], "net472": [], "net48": [], "net5.0": ["Microsoft.NETCore.Platforms", "Microsoft.NETCore.Targets", "System.Runtime"], "net6.0": ["Microsoft.NETCore.Platforms", "Microsoft.NETCore.Targets", "System.Runtime"], "net7.0": ["Microsoft.NETCore.Platforms", "Microsoft.NETCore.Targets", "System.Runtime"], "net8.0": ["Microsoft.NETCore.Platforms", "Microsoft.NETCore.Targets", "System.Runtime"], "netcoreapp1.0": ["Microsoft.NETCore.Platforms", "Microsoft.NETCore.Targets", "System.Runtime"], "netcoreapp1.1": ["Microsoft.NETCore.Platforms", "Microsoft.NETCore.Targets", "System.Runtime"], "netcoreapp2.0": ["Microsoft.NETCore.Platforms", "Microsoft.NETCore.Targets", "System.Runtime"], "netcoreapp2.1": ["Microsoft.NETCore.Platforms", "Microsoft.NETCore.Targets", "System.Runtime"], "netcoreapp2.2": ["Microsoft.NETCore.Platforms", "Microsoft.NETCore.Targets", "System.Runtime"], "netcoreapp3.0": ["Microsoft.NETCore.Platforms", "Microsoft.NETCore.Targets", "System.Runtime"], "netcoreapp3.1": ["Microsoft.NETCore.Platforms", "Microsoft.NETCore.Targets", "System.Runtime"], "netstandard": [], "netstandard1.0": ["Microsoft.NETCore.Platforms", "Microsoft.NETCore.Targets", "System.Runtime"], "netstandard1.1": ["Microsoft.NETCore.Platforms", "Microsoft.NETCore.Targets", "System.Runtime"], "netstandard1.2": ["Microsoft.NETCore.Platforms", "Microsoft.NETCore.Targets", "System.Runtime"], "netstandard1.3": ["Microsoft.NETCore.Platforms", "Microsoft.NETCore.Targets", "System.Runtime"], "netstandard1.4": ["Microsoft.NETCore.Platforms", "Microsoft.NETCore.Targets", "System.Runtime"], "netstandard1.5": ["Microsoft.NETCore.Platforms", "Microsoft.NETCore.Targets", "System.Runtime"], "netstandard1.6": ["Microsoft.NETCore.Platforms", "Microsoft.NETCore.Targets", "System.Runtime"], "netstandard2.0": ["Microsoft.NETCore.Platforms", "Microsoft.NETCore.Targets", "System.Runtime"], "netstandard2.1": ["Microsoft.NETCore.Platforms", "Microsoft.NETCore.Targets", "System.Runtime"]}, "targeting_pack_overrides": [], "framework_list": []},
{"name": "System.Threading.Tasks.Extensions", "id": "System.Threading.Tasks.Extensions", "version": "4.5.4", "sha512": "sha512-aAUghud9PHGYc3o9oWPWd0C3xE+TJQw5ZZs78htlR6mr9ky/QEgfXHjyQ2GvOq9H1S0YizcVVKCSin92ZcH8FA==", "sources": ["https://api.nuget.org/v3/index.json"], "dependencies": {"net11": [], "net20": [], "net30": [], "net35": [], "net40": [], "net403": [], "net45": ["System.Runtime.CompilerServices.Unsafe"], "net451": ["System.Runtime.CompilerServices.Unsafe"], "net452": ["System.Runtime.CompilerServices.Unsafe"], "net46": ["System.Runtime.CompilerServices.Unsafe"], "net461": ["System.Runtime.CompilerServices.Unsafe"], "net462": ["System.Runtime.CompilerServices.Unsafe"], "net47": ["System.Runtime.CompilerServices.Unsafe"], "net471": ["System.Runtime.CompilerServices.Unsafe"], "net472": ["System.Runtime.CompilerServices.Unsafe"], "net48": ["System.Runtime.CompilerServices.Unsafe"], "net5.0": [], "net6.0": [], "net7.0": [], "net8.0": [], "netcoreapp1.0": ["System.Runtime", "System.Runtime.CompilerServices.Unsafe", "System.Threading.Tasks"], "netcoreapp1.1": ["System.Runtime", "System.Runtime.CompilerServices.Unsafe", "System.Threading.Tasks"], "netcoreapp2.0": ["System.Runtime.CompilerServices.Unsafe"], "netcoreapp2.1": [], "netcoreapp2.2": [], "netcoreapp3.0": [], "netcoreapp3.1": [], "netstandard": [], "netstandard1.0": ["System.Runtime", "System.Runtime.CompilerServices.Unsafe", "System.Threading.Tasks"], "netstandard1.1": ["System.Runtime", "System.Runtime.CompilerServices.Unsafe", "System.Threading.Tasks"], "netstandard1.2": ["System.Runtime", "System.Runtime.CompilerServices.Unsafe", "System.Threading.Tasks"], "netstandard1.3": ["System.Runtime", "System.Runtime.CompilerServices.Unsafe", "System.Threading.Tasks"], "netstandard1.4": ["System.Runtime", "System.Runtime.CompilerServices.Unsafe", "System.Threading.Tasks"], "netstandard1.5": ["System.Runtime", "System.Runtime.CompilerServices.Unsafe", "System.Threading.Tasks"], "netstandard1.6": ["System.Runtime", "System.Runtime.CompilerServices.Unsafe", "System.Threading.Tasks"], "netstandard2.0": ["System.Runtime.CompilerServices.Unsafe"], "netstandard2.1": ["System.Runtime.CompilerServices.Unsafe"]}, "targeting_pack_overrides": [], "framework_list": []},
],
diff --git a/dotnet/src/support/Events/EventFiringWebDriver.cs b/dotnet/src/support/Events/EventFiringWebDriver.cs
index cfcc7d0cc5154..e68b261e387c3 100644
--- a/dotnet/src/support/Events/EventFiringWebDriver.cs
+++ b/dotnet/src/support/Events/EventFiringWebDriver.cs
@@ -1613,7 +1613,6 @@ public void Click()
///
/// Attribute you wish to get details of
/// The attribute's current value or null if the value is not set.
- [Obsolete("Use GetDomAttribute(string attributeName) or GetDomProperty(string propertyName). GetAttribute(string attributeName) will be removed in Selenium 6.")]
public string GetAttribute(string attributeName)
{
string attribute = string.Empty;
diff --git a/dotnet/src/webdriver/Alert.cs b/dotnet/src/webdriver/Alert.cs
index 11e860af922a7..d7637b7465a6b 100644
--- a/dotnet/src/webdriver/Alert.cs
+++ b/dotnet/src/webdriver/Alert.cs
@@ -20,6 +20,8 @@
using System;
using System.Collections.Generic;
+#nullable enable
+
namespace OpenQA.Selenium
{
///
@@ -27,7 +29,7 @@ namespace OpenQA.Selenium
///
internal class Alert : IAlert
{
- private WebDriver driver;
+ private readonly WebDriver driver;
///
/// Initializes a new instance of the class.
@@ -41,12 +43,12 @@ public Alert(WebDriver driver)
///
/// Gets the text of the alert.
///
- public string Text
+ public string? Text
{
get
{
Response commandResponse = this.driver.InternalExecute(DriverCommand.GetAlertText, null);
- return commandResponse.Value.ToString();
+ return (string?)commandResponse.Value;
}
}
@@ -70,9 +72,10 @@ public void Accept()
/// Sends keys to the alert.
///
/// The keystrokes to send.
+ /// If is .
public void SendKeys(string keysToSend)
{
- if (keysToSend == null)
+ if (keysToSend is null)
{
throw new ArgumentNullException(nameof(keysToSend), "Keys to send must not be null.");
}
diff --git a/dotnet/src/webdriver/BiDi/Modules/BrowsingContext/CaptureScreenshotCommand.cs b/dotnet/src/webdriver/BiDi/Modules/BrowsingContext/CaptureScreenshotCommand.cs
index 140d01e4b9bad..9d666f8427e53 100644
--- a/dotnet/src/webdriver/BiDi/Modules/BrowsingContext/CaptureScreenshotCommand.cs
+++ b/dotnet/src/webdriver/BiDi/Modules/BrowsingContext/CaptureScreenshotCommand.cs
@@ -62,7 +62,7 @@ public abstract record ClipRectangle
{
public record Box(double X, double Y, double Width, double Height) : ClipRectangle;
- public record Element([property: JsonPropertyName("element")] Script.SharedReference SharedReference) : ClipRectangle;
+ public record Element([property: JsonPropertyName("element")] Script.ISharedReference SharedReference) : ClipRectangle;
}
public record CaptureScreenshotResult(string Data)
diff --git a/dotnet/src/webdriver/BiDi/Modules/BrowsingContext/LocateNodesCommand.cs b/dotnet/src/webdriver/BiDi/Modules/BrowsingContext/LocateNodesCommand.cs
index 82ffd4c1fb301..cdf14ecbf1333 100644
--- a/dotnet/src/webdriver/BiDi/Modules/BrowsingContext/LocateNodesCommand.cs
+++ b/dotnet/src/webdriver/BiDi/Modules/BrowsingContext/LocateNodesCommand.cs
@@ -33,7 +33,7 @@ internal record LocateNodesCommandParameters(BrowsingContext Context, Locator Lo
public Script.SerializationOptions? SerializationOptions { get; set; }
- public IEnumerable? StartNodes { get; set; }
+ public IEnumerable? StartNodes { get; set; }
}
public record LocateNodesOptions : CommandOptions
@@ -42,7 +42,7 @@ public record LocateNodesOptions : CommandOptions
public Script.SerializationOptions? SerializationOptions { get; set; }
- public IEnumerable? StartNodes { get; set; }
+ public IEnumerable? StartNodes { get; set; }
}
public record LocateNodesResult : IReadOnlyList
diff --git a/dotnet/src/webdriver/BiDi/Modules/Input/Origin.cs b/dotnet/src/webdriver/BiDi/Modules/Input/Origin.cs
index c4880aa356e4b..ad717c9427133 100644
--- a/dotnet/src/webdriver/BiDi/Modules/Input/Origin.cs
+++ b/dotnet/src/webdriver/BiDi/Modules/Input/Origin.cs
@@ -29,7 +29,7 @@ public record Viewport() : Origin;
public record Pointer() : Origin;
- public record Element([property: JsonPropertyName("element")] Script.SharedReference SharedReference) : Origin
+ public record Element([property: JsonPropertyName("element")] Script.ISharedReference SharedReference) : Origin
{
public string Type { get; } = "element";
}
diff --git a/dotnet/src/webdriver/BiDi/Modules/Script/RemoteReference.cs b/dotnet/src/webdriver/BiDi/Modules/Script/IRemoteReference.cs
similarity index 77%
rename from dotnet/src/webdriver/BiDi/Modules/Script/RemoteReference.cs
rename to dotnet/src/webdriver/BiDi/Modules/Script/IRemoteReference.cs
index 4d6e4e3e12d55..bf48a8534f15b 100644
--- a/dotnet/src/webdriver/BiDi/Modules/Script/RemoteReference.cs
+++ b/dotnet/src/webdriver/BiDi/Modules/Script/IRemoteReference.cs
@@ -1,4 +1,4 @@
-//
+//
// 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
@@ -21,14 +21,18 @@
namespace OpenQA.Selenium.BiDi.Modules.Script;
-public abstract record RemoteReference : LocalValue;
+public interface IRemoteReference;
-public record SharedReference(string SharedId) : RemoteReference
+public interface ISharedReference : IRemoteReference
{
+ public string SharedId { get; }
+
public Handle? Handle { get; set; }
}
-public record RemoteObjectReference(Handle Handle) : RemoteReference
+public interface IRemoteObjectReference : IRemoteReference
{
+ public Handle Handle { get; }
+
public string? SharedId { get; set; }
}
diff --git a/dotnet/src/webdriver/BiDi/Modules/Script/RemoteValue.cs b/dotnet/src/webdriver/BiDi/Modules/Script/RemoteValue.cs
index 9cce784f77517..a99855b78d957 100644
--- a/dotnet/src/webdriver/BiDi/Modules/Script/RemoteValue.cs
+++ b/dotnet/src/webdriver/BiDi/Modules/Script/RemoteValue.cs
@@ -246,7 +246,7 @@ public record HtmlCollection : RemoteValue
public IReadOnlyList? Value { get; set; }
}
- public record Node : RemoteValue
+ public record Node : RemoteValue, ISharedReference
{
[JsonInclude]
public string? SharedId { get; internal set; }
diff --git a/dotnet/src/webdriver/BiDi/Modules/Session/ProxyConfiguration.cs b/dotnet/src/webdriver/BiDi/Modules/Session/ProxyConfiguration.cs
index aecc837d5598b..b2e14e58dc82b 100644
--- a/dotnet/src/webdriver/BiDi/Modules/Session/ProxyConfiguration.cs
+++ b/dotnet/src/webdriver/BiDi/Modules/Session/ProxyConfiguration.cs
@@ -24,14 +24,14 @@
namespace OpenQA.Selenium.BiDi.Modules.Session;
[JsonPolymorphic(TypeDiscriminatorPropertyName = "proxyType")]
-[JsonDerivedType(typeof(Autodetect), "autodetect")]
+[JsonDerivedType(typeof(AutoDetect), "autodetect")]
[JsonDerivedType(typeof(Direct), "direct")]
[JsonDerivedType(typeof(Manual), "manual")]
[JsonDerivedType(typeof(Pac), "pac")]
[JsonDerivedType(typeof(System), "system")]
public abstract record ProxyConfiguration
{
- public record Autodetect : ProxyConfiguration;
+ public record AutoDetect : ProxyConfiguration;
public record Direct : ProxyConfiguration;
@@ -48,7 +48,7 @@ public record Manual : ProxyConfiguration
public long? SocksVersion { get; set; }
}
- public record Pac(string ProxyAutoconfigUrl) : ProxyConfiguration;
+ public record Pac(string ProxyAutoConfigUrl) : ProxyConfiguration;
public record System : ProxyConfiguration;
}
diff --git a/dotnet/src/webdriver/Chromium/ChromiumDriverService.cs b/dotnet/src/webdriver/Chromium/ChromiumDriverService.cs
index 04a4e8994118f..95958e44812f4 100644
--- a/dotnet/src/webdriver/Chromium/ChromiumDriverService.cs
+++ b/dotnet/src/webdriver/Chromium/ChromiumDriverService.cs
@@ -208,7 +208,7 @@ protected static string ChromiumDriverServiceFileName(string fileName = DefaultC
// straightforward as you might hope.
// See: http://mono.wikia.com/wiki/Detecting_the_execution_platform
// and https://msdn.microsoft.com/en-us/library/3a8hyw88(v=vs.110).aspx
- const int PlatformMonoUnixValue = 128;
+ const PlatformID PlatformIDMonoUnix = (PlatformID)128;
switch (Environment.OSVersion.Platform)
{
@@ -221,17 +221,14 @@ protected static string ChromiumDriverServiceFileName(string fileName = DefaultC
case PlatformID.MacOSX:
case PlatformID.Unix:
+ case PlatformIDMonoUnix:
break;
// Don't handle the Xbox case. Let default handle it.
// case PlatformID.Xbox:
// break;
- default:
- if ((int)Environment.OSVersion.Platform == PlatformMonoUnixValue)
- {
- break;
- }
+ default:
throw new WebDriverException("Unsupported platform: " + Environment.OSVersion.Platform);
}
diff --git a/dotnet/src/webdriver/CommandInfoRepository.cs b/dotnet/src/webdriver/CommandInfoRepository.cs
index 1b2d0486e7718..fa184c60bda5c 100644
--- a/dotnet/src/webdriver/CommandInfoRepository.cs
+++ b/dotnet/src/webdriver/CommandInfoRepository.cs
@@ -21,6 +21,8 @@
using System.Collections.Generic;
using System.Globalization;
+#nullable enable
+
namespace OpenQA.Selenium
{
///
@@ -56,6 +58,7 @@ protected CommandInfoRepository()
///
/// The name of the command to check.
/// if the command name is defined
+ /// If is .
public bool IsCommandNameDefined(string commandName)
{
return this.commandDictionary.ContainsKey(commandName);
@@ -66,7 +69,7 @@ public bool IsCommandNameDefined(string commandName)
///
/// The object for which to find the command name.
/// The name of the command defined by the command info, or if the command is not defined.
- public string FindCommandName(CommandInfo commandInfo)
+ public string? FindCommandName(CommandInfo commandInfo)
{
foreach (KeyValuePair pair in this.commandDictionary)
{
@@ -83,13 +86,13 @@ public string FindCommandName(CommandInfo commandInfo)
/// Gets the for a .
///
/// The for which to get the information.
- /// The for the specified command.
- public T GetCommandInfo(string commandName) where T : CommandInfo
+ /// The for the specified command, or if not found or value is not .
+ public T? GetCommandInfo(string commandName) where T : CommandInfo
{
- T toReturn = default(T);
- if (this.commandDictionary.ContainsKey(commandName))
+ T? toReturn = default;
+ if (this.commandDictionary.TryGetValue(commandName, out CommandInfo? info))
{
- toReturn = this.commandDictionary[commandName] as T;
+ toReturn = info as T;
}
return toReturn;
@@ -106,6 +109,12 @@ public T GetCommandInfo(string commandName) where T : CommandInfo
/// This method will not overwrite existing commands for a specific name, and will return
/// in that case.
///
+ ///
+ /// If is or .
+ /// -or-
+ /// If is .
+ ///
+ /// If is not a valid command type for this repository.
public bool TryAddCommand(string commandName, T commandInfo) where T : CommandInfo
{
if (string.IsNullOrEmpty(commandName))
diff --git a/dotnet/src/webdriver/Cookie.cs b/dotnet/src/webdriver/Cookie.cs
index 693012815d699..b15dca6d196fe 100644
--- a/dotnet/src/webdriver/Cookie.cs
+++ b/dotnet/src/webdriver/Cookie.cs
@@ -351,14 +351,12 @@ public override string ToString()
public override bool Equals(object obj)
{
// Two cookies are equal if the name and value match
- Cookie cookie = obj as Cookie;
-
if (this == obj)
{
return true;
}
- if (cookie == null)
+ if (obj is not Cookie cookie)
{
return false;
}
@@ -368,7 +366,7 @@ public override bool Equals(object obj)
return false;
}
- return !(this.cookieValue != null ? !this.cookieValue.Equals(cookie.cookieValue) : cookie.Value != null);
+ return string.Equals(this.cookieValue, cookie.cookieValue);
}
///
diff --git a/dotnet/src/webdriver/CookieJar.cs b/dotnet/src/webdriver/CookieJar.cs
index e4f681e11908a..8ae324fa6961f 100644
--- a/dotnet/src/webdriver/CookieJar.cs
+++ b/dotnet/src/webdriver/CookieJar.cs
@@ -21,64 +21,92 @@
using System.Collections.Generic;
using System.Collections.ObjectModel;
+#nullable enable
+
namespace OpenQA.Selenium
{
- ///
- /// Defines an interface allowing the user to manipulate cookies on the current page.
- ///
- internal class CookieJar : ICookieJar
+ internal sealed class CookieJar(WebDriver driver) : ICookieJar
{
- private WebDriver driver;
-
- ///
- /// Initializes a new instance of the class.
- ///
- /// The driver that is currently in use
- public CookieJar(WebDriver driver)
- {
- this.driver = driver;
- }
-
///
/// Gets all cookies defined for the current page.
///
public ReadOnlyCollection AllCookies
{
- get { return this.GetAllCookies(); }
+ get
+ {
+ Response response = driver.InternalExecute(DriverCommand.GetAllCookies, new Dictionary());
+
+ try
+ {
+ List toReturn = new List();
+ if (response.Value is object?[] cookies)
+ {
+ foreach (object? rawCookie in cookies)
+ {
+ if (rawCookie != null)
+ {
+ Cookie newCookie = Cookie.FromDictionary((Dictionary)rawCookie);
+ toReturn.Add(newCookie);
+ }
+ }
+ }
+
+ return new ReadOnlyCollection(toReturn);
+ }
+ catch (Exception e)
+ {
+ throw new WebDriverException("Unexpected problem getting cookies", e);
+ }
+ }
}
///
/// Method for creating a cookie in the browser
///
/// that represents a cookie in the browser
+ /// If is .
public void AddCookie(Cookie cookie)
{
+ if (cookie is null)
+ {
+ throw new ArgumentNullException(nameof(cookie));
+ }
+
Dictionary parameters = new Dictionary();
parameters.Add("cookie", cookie);
- this.driver.InternalExecute(DriverCommand.AddCookie, parameters);
+ driver.InternalExecute(DriverCommand.AddCookie, parameters);
}
///
/// Delete the cookie by passing in the name of the cookie
///
/// The name of the cookie that is in the browser
+ /// If is .
public void DeleteCookieNamed(string name)
{
+ if (name is null)
+ {
+ throw new ArgumentNullException(nameof(name));
+ }
+
Dictionary parameters = new Dictionary();
parameters.Add("name", name);
- this.driver.InternalExecute(DriverCommand.DeleteCookie, parameters);
+ driver.InternalExecute(DriverCommand.DeleteCookie, parameters);
}
///
/// Delete a cookie in the browser by passing in a copy of a cookie
///
/// An object that represents a copy of the cookie that needs to be deleted
+ /// If is .
public void DeleteCookie(Cookie cookie)
{
- if (cookie != null)
+ if (cookie is null)
{
- this.DeleteCookieNamed(cookie.Name);
+ throw new ArgumentNullException(nameof(cookie));
}
+
+ this.DeleteCookieNamed(cookie.Name);
}
///
@@ -86,63 +114,32 @@ public void DeleteCookie(Cookie cookie)
///
public void DeleteAllCookies()
{
- this.driver.InternalExecute(DriverCommand.DeleteAllCookies, null);
+ driver.InternalExecute(DriverCommand.DeleteAllCookies, null);
}
///
/// Method for returning a getting a cookie by name
///
/// name of the cookie that needs to be returned
- /// A Cookie from the name
- public Cookie GetCookieNamed(string name)
+ /// A Cookie from the name; or if not found.
+ public Cookie? GetCookieNamed(string name)
{
- Cookie cookieToReturn = null;
- if (name != null)
+ if (name is null)
{
- ReadOnlyCollection allCookies = this.AllCookies;
- foreach (Cookie currentCookie in allCookies)
- {
- if (name.Equals(currentCookie.Name))
- {
- cookieToReturn = currentCookie;
- break;
- }
- }
+ throw new ArgumentNullException(nameof(name));
}
- return cookieToReturn;
- }
- ///
- /// Method for getting a Collection of Cookies that are present in the browser
- ///
- /// ReadOnlyCollection of Cookies in the browser
- private ReadOnlyCollection GetAllCookies()
- {
- List toReturn = new List();
- object returned = this.driver.InternalExecute(DriverCommand.GetAllCookies, new Dictionary()).Value;
-
- try
+ foreach (Cookie currentCookie in this.AllCookies)
{
- object[] cookies = returned as object[];
- if (cookies != null)
+ if (name.Equals(currentCookie.Name))
{
- foreach (object rawCookie in cookies)
- {
- Dictionary cookieDictionary = rawCookie as Dictionary;
- if (rawCookie != null)
- {
- toReturn.Add(Cookie.FromDictionary(cookieDictionary));
- }
- }
+ return currentCookie;
}
- return new ReadOnlyCollection(toReturn);
- }
- catch (Exception e)
- {
- throw new WebDriverException("Unexpected problem getting cookies", e);
}
+
+ return null;
}
}
}
diff --git a/dotnet/src/webdriver/DevTools/DevToolsSession.cs b/dotnet/src/webdriver/DevTools/DevToolsSession.cs
index b58de1097888c..4ec62289873db 100644
--- a/dotnet/src/webdriver/DevTools/DevToolsSession.cs
+++ b/dotnet/src/webdriver/DevTools/DevToolsSession.cs
@@ -542,6 +542,11 @@ private void MonitorMessageQueue()
}
catch (Exception ex)
{
+ if (logger.IsEnabled(LogEventLevel.Error))
+ {
+ logger.Error($"Unexpected error occured while processing message: {ex}");
+ }
+
LogError("Unexpected error occured while processing message: {0}", ex);
}
}
@@ -578,6 +583,11 @@ private void ProcessMessage(string message)
}
else
{
+ if (logger.IsEnabled(LogEventLevel.Error))
+ {
+ logger.Error($"Recieved Unknown Response {commandId}: {message}");
+ }
+
LogError("Recieved Unknown Response {0}: {1}", commandId, message);
}
diff --git a/dotnet/src/webdriver/Firefox/FirefoxDriverService.cs b/dotnet/src/webdriver/Firefox/FirefoxDriverService.cs
index 6c58457461a22..3d35057e69e64 100644
--- a/dotnet/src/webdriver/Firefox/FirefoxDriverService.cs
+++ b/dotnet/src/webdriver/Firefox/FirefoxDriverService.cs
@@ -263,7 +263,7 @@ private static string FirefoxDriverServiceFileName()
// straightforward as you might hope.
// See: http://mono.wikia.com/wiki/Detecting_the_execution_platform
// and https://msdn.microsoft.com/en-us/library/3a8hyw88(v=vs.110).aspx
- const int PlatformMonoUnixValue = 128;
+ const PlatformID PlatformIDMonoUnix = (PlatformID)128;
switch (Environment.OSVersion.Platform)
{
@@ -276,17 +276,13 @@ private static string FirefoxDriverServiceFileName()
case PlatformID.MacOSX:
case PlatformID.Unix:
+ case PlatformIDMonoUnix:
break;
// Don't handle the Xbox case. Let default handle it.
// case PlatformID.Xbox:
// break;
default:
- if ((int)Environment.OSVersion.Platform == PlatformMonoUnixValue)
- {
- break;
- }
-
throw new WebDriverException("Unsupported platform: " + Environment.OSVersion.Platform);
}
diff --git a/dotnet/src/webdriver/Firefox/Internal/IniFileReader.cs b/dotnet/src/webdriver/Firefox/Internal/IniFileReader.cs
index 656604a4f8635..847af73d567e1 100644
--- a/dotnet/src/webdriver/Firefox/Internal/IniFileReader.cs
+++ b/dotnet/src/webdriver/Firefox/Internal/IniFileReader.cs
@@ -22,19 +22,23 @@
using System.Collections.ObjectModel;
using System.IO;
+#nullable enable
+
namespace OpenQA.Selenium.Firefox.Internal
{
///
/// Parses and reads an INI file.
///
- internal class IniFileReader
+ internal sealed class IniFileReader
{
- private Dictionary> iniFileStore = new Dictionary>();
+ private readonly Dictionary> iniFileStore = new Dictionary>();
///
/// Initializes a new instance of the class.
///
/// The full path to the .INI file to be read.
+ /// If is or .
+ /// If no file exists at file path .
public IniFileReader(string fileName)
{
if (string.IsNullOrEmpty(fileName))
@@ -53,7 +57,7 @@ public IniFileReader(string fileName)
string[] iniFileContent = File.ReadAllLines(fileName);
foreach (string iniFileLine in iniFileContent)
{
- if (!string.IsNullOrEmpty(iniFileLine.Trim()) && !iniFileLine.StartsWith(";", StringComparison.OrdinalIgnoreCase))
+ if (!string.IsNullOrWhiteSpace(iniFileLine) && !iniFileLine.StartsWith(";", StringComparison.OrdinalIgnoreCase))
{
if (iniFileLine.StartsWith("[", StringComparison.OrdinalIgnoreCase) && iniFileLine.EndsWith("]", StringComparison.OrdinalIgnoreCase))
{
@@ -86,14 +90,7 @@ public IniFileReader(string fileName)
///
/// Gets a containing the names of the sections in the .INI file.
///
- public ReadOnlyCollection SectionNames
- {
- get
- {
- List keyList = new List(this.iniFileStore.Keys);
- return new ReadOnlyCollection(keyList);
- }
- }
+ public ReadOnlyCollection SectionNames => new ReadOnlyCollection(new List(this.iniFileStore.Keys));
///
/// Gets a value from the .INI file.
@@ -101,6 +98,16 @@ public ReadOnlyCollection SectionNames
/// The section in which to find the key-value pair.
/// The key of the key-value pair.
/// The value associated with the given section and key.
+ ///
+ /// If is or .
+ /// -or-
+ /// If is or .
+ ///
+ ///
+ /// If no section named exists.
+ /// -or-
+ ///If the section does not contain a value named .
+ ///
public string GetValue(string sectionName, string valueName)
{
if (string.IsNullOrEmpty(sectionName))
@@ -117,19 +124,17 @@ public string GetValue(string sectionName, string valueName)
string lowerCaseValueName = valueName.ToUpperInvariant();
- if (!this.iniFileStore.ContainsKey(lowerCaseSectionName))
+ if (!this.iniFileStore.TryGetValue(lowerCaseSectionName, out Dictionary? section))
{
throw new ArgumentException("Section does not exist: " + sectionName, nameof(sectionName));
}
- Dictionary section = this.iniFileStore[lowerCaseSectionName];
-
- if (!section.ContainsKey(lowerCaseValueName))
+ if (!section.TryGetValue(lowerCaseValueName, out string? value))
{
throw new ArgumentException("Value does not exist: " + valueName, nameof(valueName));
}
- return section[lowerCaseValueName];
+ return value;
}
}
}
diff --git a/dotnet/src/webdriver/IAlert.cs b/dotnet/src/webdriver/IAlert.cs
index 6dd0c8db63e99..78c15d992c1b3 100644
--- a/dotnet/src/webdriver/IAlert.cs
+++ b/dotnet/src/webdriver/IAlert.cs
@@ -17,6 +17,10 @@
// under the License.
//
+using System;
+
+#nullable enable
+
namespace OpenQA.Selenium
{
///
@@ -27,7 +31,7 @@ public interface IAlert
///
/// Gets the text of the alert.
///
- string Text { get; }
+ string? Text { get; }
///
/// Dismisses the alert.
@@ -43,6 +47,7 @@ public interface IAlert
/// Sends keys to the alert.
///
/// The keystrokes to send.
+ /// If is .
void SendKeys(string keysToSend);
}
}
diff --git a/dotnet/src/webdriver/ICapabilities.cs b/dotnet/src/webdriver/ICapabilities.cs
index 1a66162ffb098..df0c8a776c77e 100644
--- a/dotnet/src/webdriver/ICapabilities.cs
+++ b/dotnet/src/webdriver/ICapabilities.cs
@@ -19,6 +19,8 @@
using System;
+#nullable enable
+
namespace OpenQA.Selenium
{
///
@@ -49,6 +51,6 @@ public interface ICapabilities
/// The capability to get.
/// An object associated with the capability, or
/// if the capability is not set on the browser.
- object GetCapability(string capability);
+ object? GetCapability(string capability);
}
}
diff --git a/dotnet/src/webdriver/ICookieJar.cs b/dotnet/src/webdriver/ICookieJar.cs
index a27c472a78c41..07594bf8f3173 100644
--- a/dotnet/src/webdriver/ICookieJar.cs
+++ b/dotnet/src/webdriver/ICookieJar.cs
@@ -17,8 +17,11 @@
// under the License.
//
+using System;
using System.Collections.ObjectModel;
+#nullable enable
+
namespace OpenQA.Selenium
{
///
@@ -35,6 +38,7 @@ public interface ICookieJar
/// Adds a cookie to the current page.
///
/// The object to be added.
+ /// If is .
void AddCookie(Cookie cookie);
///
@@ -43,18 +47,21 @@ public interface ICookieJar
/// The name of the cookie to retrieve.
/// The containing the name. Returns
/// if no cookie with the specified name is found.
- Cookie GetCookieNamed(string name);
+ /// If is .
+ Cookie? GetCookieNamed(string name);
///
/// Deletes the specified cookie from the page.
///
/// The to be deleted.
+ /// If is .
void DeleteCookie(Cookie cookie);
///
/// Deletes the cookie with the specified name from the page.
///
/// The name of the cookie to be deleted.
+ /// If is .
void DeleteCookieNamed(string name);
///
diff --git a/dotnet/src/webdriver/ILogs.cs b/dotnet/src/webdriver/ILogs.cs
index 1224f6d4f3666..d3f236f36c05e 100644
--- a/dotnet/src/webdriver/ILogs.cs
+++ b/dotnet/src/webdriver/ILogs.cs
@@ -17,8 +17,11 @@
// under the License.
//
+using System;
using System.Collections.ObjectModel;
+#nullable enable
+
namespace OpenQA.Selenium
{
///
@@ -37,6 +40,7 @@ public interface ILogs
/// The log for which to retrieve the log entries.
/// Log types can be found in the class.
/// The list of objects for the specified log.
+ /// If is .
ReadOnlyCollection GetLog(string logKind);
}
}
diff --git a/dotnet/src/webdriver/IWebElement.cs b/dotnet/src/webdriver/IWebElement.cs
index e96d734ca34a8..026fd8a85d9ca 100644
--- a/dotnet/src/webdriver/IWebElement.cs
+++ b/dotnet/src/webdriver/IWebElement.cs
@@ -172,7 +172,6 @@ public interface IWebElement : ISearchContext
///
///
/// Thrown when the target element is no longer valid in the document DOM.
- [Obsolete("Use GetDomAttribute(string attributeName) or GetDomProperty(string propertyName). GetAttribute(string attributeName) will be removed in Selenium 6.")]
string GetAttribute(string attributeName);
///
diff --git a/dotnet/src/webdriver/Interactions/ActionSequence.cs b/dotnet/src/webdriver/Interactions/ActionSequence.cs
index 6b60496e37fc1..2ad1576a084d5 100644
--- a/dotnet/src/webdriver/Interactions/ActionSequence.cs
+++ b/dotnet/src/webdriver/Interactions/ActionSequence.cs
@@ -72,6 +72,7 @@ public int Count
/// Gets the input device for this Action sequence.
///
[Obsolete("This property has been renamed to InputDevice and will be removed in a future version")]
+ [CLSCompliant(false)]
public InputDevice inputDevice => InputDevice;
///
diff --git a/dotnet/src/webdriver/Interactions/Actions.cs b/dotnet/src/webdriver/Interactions/Actions.cs
index 4fc3307982a83..e3672dd5a5c7a 100644
--- a/dotnet/src/webdriver/Interactions/Actions.cs
+++ b/dotnet/src/webdriver/Interactions/Actions.cs
@@ -138,7 +138,7 @@ private InputDevice FindDeviceById(string name)
if (id == name)
{
- return sequence.inputDevice;
+ return sequence.InputDevice;
}
}
diff --git a/dotnet/src/webdriver/Internal/AndroidOptions.cs b/dotnet/src/webdriver/Internal/AndroidOptions.cs
index e2d9e5b94763c..d002d1e6acc81 100644
--- a/dotnet/src/webdriver/Internal/AndroidOptions.cs
+++ b/dotnet/src/webdriver/Internal/AndroidOptions.cs
@@ -19,6 +19,8 @@
using System;
+#nullable enable
+
namespace OpenQA.Selenium.Internal
{
///
@@ -26,14 +28,11 @@ namespace OpenQA.Selenium.Internal
///
public class AndroidOptions
{
- private string androidPackage;
- private string androidDeviceSerial;
- private string androidActivity;
-
///
/// Initializes a new instance of the class.
///
///
+ /// If is or .
protected AndroidOptions(string androidPackage)
{
if (string.IsNullOrEmpty(androidPackage))
@@ -41,33 +40,22 @@ protected AndroidOptions(string androidPackage)
throw new ArgumentException("The Android package cannot be null or the empty string", nameof(androidPackage));
}
- this.androidPackage = androidPackage;
+ this.AndroidPackage = androidPackage;
}
///
/// The package name of the application to automate.
///
- public string AndroidPackage
- {
- get { return this.androidPackage; }
- }
+ public string AndroidPackage { get; }
///
/// The serial number of the device on which to launch the application.
///
- public string AndroidDeviceSerial
- {
- get { return this.androidDeviceSerial; }
- set { this.androidDeviceSerial = value; }
- }
+ public string? AndroidDeviceSerial { get; set; }
///
/// Gets or sets the name of the Activity hosting the app.
///
- public string AndroidActivity
- {
- get { return this.androidActivity; }
- set { this.androidActivity = value; }
- }
+ public string? AndroidActivity { get; set; }
}
}
diff --git a/dotnet/src/webdriver/Internal/Base64UrlEncoder.cs b/dotnet/src/webdriver/Internal/Base64UrlEncoder.cs
index 87fb7085e86c5..c8b22e7223e8b 100644
--- a/dotnet/src/webdriver/Internal/Base64UrlEncoder.cs
+++ b/dotnet/src/webdriver/Internal/Base64UrlEncoder.cs
@@ -25,9 +25,9 @@ namespace OpenQA.Selenium.Internal
{
/*
* Based on: https://github.com/AzureAD/azure-activedirectory-identitymodel-extensions-for-dotnet/blob/6.19.0/src/Microsoft.IdentityModel.Tokens/Base64UrlEncoder.cs
- *
+ *
* Now it is a part of .NET 9+ as System.Buffers.Text.Base64Url
- * https://github.com/SeleniumHQ/selenium/issues/14813
+ * https://github.com/SeleniumHQ/selenium/issues/14813
*/
///
diff --git a/dotnet/src/webdriver/Internal/FileUtilities.cs b/dotnet/src/webdriver/Internal/FileUtilities.cs
index 0d83a6927aeca..d288a58e5f296 100644
--- a/dotnet/src/webdriver/Internal/FileUtilities.cs
+++ b/dotnet/src/webdriver/Internal/FileUtilities.cs
@@ -23,6 +23,8 @@
using System.IO;
using System.Reflection;
+#nullable enable
+
namespace OpenQA.Selenium.Internal
{
///
@@ -40,7 +42,7 @@ internal static class FileUtilities
/// if the copy is completed; otherwise .
public static bool CopyDirectory(string sourceDirectory, string destinationDirectory)
{
- bool copyComplete = false;
+ bool copyComplete;
DirectoryInfo sourceDirectoryInfo = new DirectoryInfo(sourceDirectory);
DirectoryInfo destinationDirectoryInfo = new DirectoryInfo(destinationDirectory);
@@ -132,7 +134,7 @@ public static string FindFile(string fileName)
// If it's not in the same directory as the executing assembly,
// try looking in the system path.
- string systemPath = Environment.GetEnvironmentVariable("PATH");
+ string? systemPath = Environment.GetEnvironmentVariable("PATH");
if (!string.IsNullOrEmpty(systemPath))
{
string expandedPath = Environment.ExpandEnvironmentVariables(systemPath);
@@ -165,7 +167,7 @@ public static string FindFile(string fileName)
public static string GetCurrentDirectory()
{
Assembly executingAssembly = typeof(FileUtilities).Assembly;
- string location = null;
+ string? location = null;
// Make sure not to call Path.GetDirectoryName if assembly location is null or empty
if (!string.IsNullOrEmpty(executingAssembly.Location))
@@ -184,13 +186,13 @@ public static string GetCurrentDirectory()
location = Directory.GetCurrentDirectory();
}
- string currentDirectory = location;
+ string currentDirectory = location!;
// If we're shadow copying, get the directory from the codebase instead
if (AppDomain.CurrentDomain.ShadowCopyFiles)
{
Uri uri = new Uri(executingAssembly.CodeBase);
- currentDirectory = Path.GetDirectoryName(uri.LocalPath);
+ currentDirectory = Path.GetDirectoryName(uri.LocalPath)!;
}
return currentDirectory;
diff --git a/dotnet/src/webdriver/Internal/IFindsElement.cs b/dotnet/src/webdriver/Internal/IFindsElement.cs
index a43055f9c91bd..7bcd08751a8fb 100644
--- a/dotnet/src/webdriver/Internal/IFindsElement.cs
+++ b/dotnet/src/webdriver/Internal/IFindsElement.cs
@@ -19,6 +19,8 @@
using System.Collections.ObjectModel;
+#nullable enable
+
namespace OpenQA.Selenium.Internal
{
///
diff --git a/dotnet/src/webdriver/Internal/IHasCapabilitiesDictionary.cs b/dotnet/src/webdriver/Internal/IHasCapabilitiesDictionary.cs
index 8c281818c4e0d..8723b5b11e580 100644
--- a/dotnet/src/webdriver/Internal/IHasCapabilitiesDictionary.cs
+++ b/dotnet/src/webdriver/Internal/IHasCapabilitiesDictionary.cs
@@ -19,6 +19,8 @@
using System.Collections.Generic;
+#nullable enable
+
namespace OpenQA.Selenium.Internal
{
///
diff --git a/dotnet/src/webdriver/Internal/Logging/ConsoleLogHandler.cs b/dotnet/src/webdriver/Internal/Logging/ConsoleLogHandler.cs
index 32a51421bf524..30a1a36efe128 100644
--- a/dotnet/src/webdriver/Internal/Logging/ConsoleLogHandler.cs
+++ b/dotnet/src/webdriver/Internal/Logging/ConsoleLogHandler.cs
@@ -19,6 +19,8 @@
using System;
+#nullable enable
+
namespace OpenQA.Selenium.Internal.Logging
{
///
diff --git a/dotnet/src/webdriver/Internal/Logging/FileLogHandler.cs b/dotnet/src/webdriver/Internal/Logging/FileLogHandler.cs
index 8c92cf46aa3b4..7bb673486f793 100644
--- a/dotnet/src/webdriver/Internal/Logging/FileLogHandler.cs
+++ b/dotnet/src/webdriver/Internal/Logging/FileLogHandler.cs
@@ -20,6 +20,8 @@
using System;
using System.IO;
+#nullable enable
+
namespace OpenQA.Selenium.Internal.Logging
{
///
@@ -40,6 +42,7 @@ public class FileLogHandler : ILogHandler, IDisposable
/// Initializes a new instance of the class with the specified file path.
///
/// The path of the log file.
+ /// If is or .
public FileLogHandler(string filePath)
: this(filePath, overwrite: true)
{
@@ -51,6 +54,7 @@ public FileLogHandler(string filePath)
///
/// The path of the log file.
/// Specifies whether the file should be overwritten if it exists on the disk.
+ /// If is or .
public FileLogHandler(string filePath, bool overwrite)
{
if (string.IsNullOrEmpty(filePath)) throw new ArgumentException("File log path cannot be null or empty.", nameof(filePath));
@@ -112,9 +116,9 @@ protected virtual void Dispose(bool disposing)
if (disposing)
{
_streamWriter?.Dispose();
- _streamWriter = null;
+ _streamWriter = null!;
_fileStream?.Dispose();
- _fileStream = null;
+ _fileStream = null!;
}
_isDisposed = true;
diff --git a/dotnet/src/webdriver/Internal/Logging/ILogContext.cs b/dotnet/src/webdriver/Internal/Logging/ILogContext.cs
index d1cc52cae4509..321c2bc99bd07 100644
--- a/dotnet/src/webdriver/Internal/Logging/ILogContext.cs
+++ b/dotnet/src/webdriver/Internal/Logging/ILogContext.cs
@@ -19,6 +19,8 @@
using System;
+#nullable enable
+
namespace OpenQA.Selenium.Internal.Logging
{
///
diff --git a/dotnet/src/webdriver/Internal/Logging/ILogHandler.cs b/dotnet/src/webdriver/Internal/Logging/ILogHandler.cs
index 59c8133d007b3..c7ab4cc7bb0c1 100644
--- a/dotnet/src/webdriver/Internal/Logging/ILogHandler.cs
+++ b/dotnet/src/webdriver/Internal/Logging/ILogHandler.cs
@@ -17,6 +17,8 @@
// under the License.
//
+#nullable enable
+
namespace OpenQA.Selenium.Internal.Logging
{
///
diff --git a/dotnet/src/webdriver/Internal/Logging/ILogHandlerList.cs b/dotnet/src/webdriver/Internal/Logging/ILogHandlerList.cs
index f27b10a53b416..4930613c86957 100644
--- a/dotnet/src/webdriver/Internal/Logging/ILogHandlerList.cs
+++ b/dotnet/src/webdriver/Internal/Logging/ILogHandlerList.cs
@@ -19,6 +19,8 @@
using System.Collections.Generic;
+#nullable enable
+
namespace OpenQA.Selenium.Internal.Logging
{
///
diff --git a/dotnet/src/webdriver/Internal/Logging/ILogger.cs b/dotnet/src/webdriver/Internal/Logging/ILogger.cs
index a92a43e0d8445..ab2713722894b 100644
--- a/dotnet/src/webdriver/Internal/Logging/ILogger.cs
+++ b/dotnet/src/webdriver/Internal/Logging/ILogger.cs
@@ -19,6 +19,8 @@
using System;
+#nullable enable
+
namespace OpenQA.Selenium.Internal.Logging
{
///
diff --git a/dotnet/src/webdriver/Internal/Logging/Log.cs b/dotnet/src/webdriver/Internal/Logging/Log.cs
index 884e147c8659a..01b40ac2bc9fd 100644
--- a/dotnet/src/webdriver/Internal/Logging/Log.cs
+++ b/dotnet/src/webdriver/Internal/Logging/Log.cs
@@ -18,6 +18,9 @@
//
using System;
+using System.Diagnostics.CodeAnalysis;
+
+#nullable enable
namespace OpenQA.Selenium.Internal.Logging
{
@@ -65,16 +68,11 @@ public static ILogContext CreateContext(LogEventLevel minimumLevel)
///
/// Gets or sets the current log context.
///
+ [AllowNull]
internal static ILogContext CurrentContext
{
- get
- {
- return _logContextManager.CurrentContext;
- }
- set
- {
- _logContextManager.CurrentContext = value;
- }
+ get => _logContextManager.CurrentContext;
+ set => _logContextManager.CurrentContext = value;
}
///
diff --git a/dotnet/src/webdriver/Internal/Logging/LogContext.cs b/dotnet/src/webdriver/Internal/Logging/LogContext.cs
index ccf902fb9b35b..bb4d9feede2c5 100644
--- a/dotnet/src/webdriver/Internal/Logging/LogContext.cs
+++ b/dotnet/src/webdriver/Internal/Logging/LogContext.cs
@@ -22,6 +22,8 @@
using System.Collections.Generic;
using System.Linq;
+#nullable enable
+
namespace OpenQA.Selenium.Internal.Logging
{
///
@@ -30,15 +32,15 @@ namespace OpenQA.Selenium.Internal.Logging
///
internal class LogContext : ILogContext
{
- private ConcurrentDictionary _loggers;
+ private ConcurrentDictionary? _loggers;
private LogEventLevel _level;
- private readonly ILogContext _parentLogContext;
+ private readonly ILogContext? _parentLogContext;
private readonly Lazy _lazyLogHandlerList;
- public LogContext(LogEventLevel level, ILogContext parentLogContext, ConcurrentDictionary loggers, IEnumerable handlers)
+ public LogContext(LogEventLevel level, ILogContext? parentLogContext, ConcurrentDictionary? loggers, IEnumerable? handlers)
{
_level = level;
@@ -63,7 +65,7 @@ public ILogContext CreateContext()
public ILogContext CreateContext(LogEventLevel minimumLevel)
{
- ConcurrentDictionary loggers = null;
+ ConcurrentDictionary? loggers = null;
if (_loggers != null)
{
@@ -89,12 +91,9 @@ public ILogger GetLogger(Type type)
throw new ArgumentNullException(nameof(type));
}
- if (_loggers is null)
- {
- _loggers = new ConcurrentDictionary();
- }
+ _loggers ??= new ConcurrentDictionary();
- return _loggers.GetOrAdd(type, _ => new Logger(type, _level));
+ return _loggers.GetOrAdd(type, type => new Logger(type, _level));
}
public bool IsEnabled(ILogger logger, LogEventLevel level)
diff --git a/dotnet/src/webdriver/Internal/Logging/LogContextManager.cs b/dotnet/src/webdriver/Internal/Logging/LogContextManager.cs
index 41594f1125447..834e806d8b74a 100644
--- a/dotnet/src/webdriver/Internal/Logging/LogContextManager.cs
+++ b/dotnet/src/webdriver/Internal/Logging/LogContextManager.cs
@@ -17,45 +17,31 @@
// under the License.
//
+using System.Diagnostics.CodeAnalysis;
using System.Threading;
+#nullable enable
+
namespace OpenQA.Selenium.Internal.Logging
{
internal class LogContextManager
{
- private readonly ILogContext _globalLogContext;
-
- private readonly AsyncLocal _currentAmbientLogContext = new AsyncLocal();
+ private readonly AsyncLocal _currentAmbientLogContext = new AsyncLocal();
public LogContextManager()
{
var defaulConsoleLogHandler = new ConsoleLogHandler();
- _globalLogContext = new LogContext(LogEventLevel.Info, null, null, new[] { defaulConsoleLogHandler });
+ GlobalContext = new LogContext(LogEventLevel.Info, null, null, new[] { defaulConsoleLogHandler });
}
- public ILogContext GlobalContext
- {
- get { return _globalLogContext; }
- }
+ public ILogContext GlobalContext { get; }
+ [AllowNull]
public ILogContext CurrentContext
{
- get
- {
- if (_currentAmbientLogContext.Value is null)
- {
- return _globalLogContext;
- }
- else
- {
- return _currentAmbientLogContext.Value;
- }
- }
- set
- {
- _currentAmbientLogContext.Value = value;
- }
+ get => _currentAmbientLogContext.Value ?? GlobalContext;
+ set => _currentAmbientLogContext.Value = value;
}
}
}
diff --git a/dotnet/src/webdriver/Internal/Logging/LogEvent.cs b/dotnet/src/webdriver/Internal/Logging/LogEvent.cs
index 2a4f9daaf27f9..2fad19a93dc2b 100644
--- a/dotnet/src/webdriver/Internal/Logging/LogEvent.cs
+++ b/dotnet/src/webdriver/Internal/Logging/LogEvent.cs
@@ -19,6 +19,8 @@
using System;
+#nullable enable
+
namespace OpenQA.Selenium.Internal.Logging
{
///
@@ -33,9 +35,10 @@ public sealed class LogEvent
/// The timestamp of the log event.
/// The level of the log event.
/// The message of the log event.
+ /// If is .
public LogEvent(Type issuedBy, DateTimeOffset timestamp, LogEventLevel level, string message)
{
- IssuedBy = issuedBy;
+ IssuedBy = issuedBy ?? throw new ArgumentNullException(nameof(issuedBy));
Timestamp = timestamp;
Level = level;
Message = message;
diff --git a/dotnet/src/webdriver/Internal/Logging/LogEventLevel.cs b/dotnet/src/webdriver/Internal/Logging/LogEventLevel.cs
index af8b728f0d326..57090b75de4e7 100644
--- a/dotnet/src/webdriver/Internal/Logging/LogEventLevel.cs
+++ b/dotnet/src/webdriver/Internal/Logging/LogEventLevel.cs
@@ -17,6 +17,8 @@
// under the License.
//
+#nullable enable
+
namespace OpenQA.Selenium.Internal.Logging
{
///
diff --git a/dotnet/src/webdriver/Internal/Logging/LogHandlerList.cs b/dotnet/src/webdriver/Internal/Logging/LogHandlerList.cs
index 7c75c36f4b2cf..9f05d3d5c52fa 100644
--- a/dotnet/src/webdriver/Internal/Logging/LogHandlerList.cs
+++ b/dotnet/src/webdriver/Internal/Logging/LogHandlerList.cs
@@ -19,13 +19,15 @@
using System.Collections.Generic;
+#nullable enable
+
namespace OpenQA.Selenium.Internal.Logging
{
///
/// Represents a list of log handlers.
///
///
- internal class LogHandlerList : List, ILogHandlerList
+ internal sealed class LogHandlerList : List, ILogHandlerList
{
private readonly ILogContext _logContext;
diff --git a/dotnet/src/webdriver/Internal/Logging/Logger.cs b/dotnet/src/webdriver/Internal/Logging/Logger.cs
index 0c92d0c0f299f..058d7944af153 100644
--- a/dotnet/src/webdriver/Internal/Logging/Logger.cs
+++ b/dotnet/src/webdriver/Internal/Logging/Logger.cs
@@ -19,13 +19,15 @@
using System;
+#nullable enable
+
namespace OpenQA.Selenium.Internal.Logging
{
///
/// The implementation of the interface through which log messages are emitted.
///
///
- internal class Logger : ILogger
+ internal sealed class Logger : ILogger
{
public Logger(Type issuer, LogEventLevel level)
{
diff --git a/dotnet/src/webdriver/Internal/ResourceUtilities.cs b/dotnet/src/webdriver/Internal/ResourceUtilities.cs
index 2f854a70214d4..0f22a33681c83 100644
--- a/dotnet/src/webdriver/Internal/ResourceUtilities.cs
+++ b/dotnet/src/webdriver/Internal/ResourceUtilities.cs
@@ -22,6 +22,8 @@
using System.Reflection;
using System.Runtime.InteropServices;
+#nullable enable
+
namespace OpenQA.Selenium.Internal
{
///
@@ -29,8 +31,8 @@ namespace OpenQA.Selenium.Internal
///
internal static class ResourceUtilities
{
- private static string productVersion;
- private static string platformFamily;
+ private static string? productVersion;
+ private static string? platformFamily;
///
/// Gets a string representing the informational version of the Selenium product.
@@ -60,18 +62,7 @@ public static string ProductVersion
///
/// Gets a string representing the platform family on which the Selenium assembly is executing.
///
- public static string PlatformFamily
- {
- get
- {
- if (string.IsNullOrEmpty(platformFamily))
- {
- platformFamily = GetPlatformString();
- }
-
- return platformFamily;
- }
- }
+ public static string PlatformFamily => platformFamily ??= GetPlatformString();
///
/// Gets a that contains the resource to use.
@@ -94,7 +85,7 @@ public static string PlatformFamily
///
public static Stream GetResourceStream(string fileName, string resourceId)
{
- Stream resourceStream = null;
+ Stream? resourceStream;
string resourceFilePath = Path.Combine(FileUtilities.GetCurrentDirectory(), Path.GetFileName(fileName));
if (File.Exists(resourceFilePath))
{
@@ -125,20 +116,22 @@ public static Stream GetResourceStream(string fileName, string resourceId)
private static string GetPlatformString()
{
- string platformName = "unknown";
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
- platformName = "windows";
+ return "windows";
}
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
{
- platformName = "linux";
+ return "linux";
}
else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
{
- platformName = "mac";
+ return "mac";
+ }
+ else
+ {
+ return "unknown";
}
- return platformName;
}
}
}
diff --git a/dotnet/src/webdriver/Internal/ResponseValueJsonConverter.cs b/dotnet/src/webdriver/Internal/ResponseValueJsonConverter.cs
index 2732cebbd13a2..66b962b2878a8 100644
--- a/dotnet/src/webdriver/Internal/ResponseValueJsonConverter.cs
+++ b/dotnet/src/webdriver/Internal/ResponseValueJsonConverter.cs
@@ -22,6 +22,8 @@
using System.Text.Json;
using System.Text.Json.Serialization;
+#nullable enable
+
namespace OpenQA.Selenium.Internal
{
///
@@ -29,7 +31,7 @@ namespace OpenQA.Selenium.Internal
///
internal class ResponseValueJsonConverter : JsonConverter
{
- public override object Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
+ public override object? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
{
return ProcessReadToken(ref reader, options);
}
@@ -67,19 +69,19 @@ public override void Write(Utf8JsonWriter writer, object value, JsonSerializerOp
}
}
- private static object ProcessReadToken(ref Utf8JsonReader reader, JsonSerializerOptions options)
+ private static object? ProcessReadToken(ref Utf8JsonReader reader, JsonSerializerOptions options)
{
// Recursively processes a token. This is required for elements that next other elements.
- object processedObject;
+ object? processedObject;
switch (reader.TokenType)
{
case JsonTokenType.StartObject:
{
- Dictionary dictionaryValue = [];
+ Dictionary dictionaryValue = [];
while (reader.Read() && reader.TokenType != JsonTokenType.EndObject)
{
- string elementKey = reader.GetString();
+ string elementKey = reader.GetString()!;
reader.Read();
dictionaryValue.Add(elementKey, ProcessReadToken(ref reader, options));
}
@@ -90,7 +92,7 @@ private static object ProcessReadToken(ref Utf8JsonReader reader, JsonSerializer
case JsonTokenType.StartArray:
{
- List arrayValue = [];
+ List arrayValue = [];
while (reader.Read() && reader.TokenType != JsonTokenType.EndArray)
{
arrayValue.Add(ProcessReadToken(ref reader, options));
diff --git a/dotnet/src/webdriver/Internal/ReturnedCapabilities.cs b/dotnet/src/webdriver/Internal/ReturnedCapabilities.cs
index 3bac423108923..2932b75273e84 100644
--- a/dotnet/src/webdriver/Internal/ReturnedCapabilities.cs
+++ b/dotnet/src/webdriver/Internal/ReturnedCapabilities.cs
@@ -22,13 +22,15 @@
using System.Collections.ObjectModel;
using System.Globalization;
+#nullable enable
+
namespace OpenQA.Selenium.Internal
{
///
/// Class to Create the capabilities of the browser you require for .
/// If you wish to use default values use the static methods
///
- internal class ReturnedCapabilities : ICapabilities, IHasCapabilitiesDictionary
+ internal sealed class ReturnedCapabilities : ICapabilities, IHasCapabilitiesDictionary
{
private readonly Dictionary capabilities = new Dictionary();
@@ -43,32 +45,26 @@ public ReturnedCapabilities()
/// Initializes a new instance of the class
///
/// Dictionary of items for the remote driver
- public ReturnedCapabilities(Dictionary rawMap)
+ public ReturnedCapabilities(Dictionary? rawMap)
{
if (rawMap != null)
{
- foreach (string key in rawMap.Keys)
+ foreach (KeyValuePair rawItem in rawMap)
{
- this.capabilities[key] = rawMap[key];
+ this.capabilities[rawItem.Key] = rawItem.Value;
}
}
}
///
- /// Gets the browser name
+ /// Gets the browser name, or if not specified.
///
public string BrowserName
{
get
{
- string name = string.Empty;
- object capabilityValue = this.GetCapability(CapabilityType.BrowserName);
- if (capabilityValue != null)
- {
- name = capabilityValue.ToString();
- }
-
- return name;
+ object? capabilityValue = this.GetCapability(CapabilityType.BrowserName);
+ return capabilityValue?.ToString() ?? string.Empty;
}
}
@@ -84,30 +80,24 @@ public object this[string capabilityName]
{
get
{
- if (!this.capabilities.ContainsKey(capabilityName))
+ if (!this.capabilities.TryGetValue(capabilityName, out object? capabilityValue))
{
throw new ArgumentException(string.Format(CultureInfo.InvariantCulture, "The capability {0} is not present in this set of capabilities", capabilityName));
}
- return this.capabilities[capabilityName];
+ return capabilityValue;
}
}
///
/// Gets the underlying Dictionary for a given set of capabilities.
///
- IDictionary IHasCapabilitiesDictionary.CapabilitiesDictionary
- {
- get { return this.CapabilitiesDictionary; }
- }
+ IDictionary IHasCapabilitiesDictionary.CapabilitiesDictionary => this.CapabilitiesDictionary;
///
/// Gets the internal capabilities dictionary.
///
- internal IDictionary CapabilitiesDictionary
- {
- get { return new ReadOnlyDictionary(this.capabilities); }
- }
+ internal IDictionary CapabilitiesDictionary => new ReadOnlyDictionary(this.capabilities);
///
/// Gets a value indicating whether the browser has a given capability.
@@ -125,15 +115,14 @@ public bool HasCapability(string capability)
/// The capability to get.
/// An object associated with the capability, or
/// if the capability is not set on the browser.
- public object GetCapability(string capability)
+ public object? GetCapability(string capability)
{
- object capabilityValue = null;
- if (this.capabilities.ContainsKey(capability))
+ if (this.capabilities.TryGetValue(capability, out object? capabilityValue))
{
- capabilityValue = this.capabilities[capability];
+ return capabilityValue;
}
- return capabilityValue;
+ return null;
}
///
diff --git a/dotnet/src/webdriver/LogEntry.cs b/dotnet/src/webdriver/LogEntry.cs
index 1f43ac5df8a7e..d10a2f3492930 100644
--- a/dotnet/src/webdriver/LogEntry.cs
+++ b/dotnet/src/webdriver/LogEntry.cs
@@ -21,6 +21,8 @@
using System.Collections.Generic;
using System.Globalization;
+#nullable enable
+
namespace OpenQA.Selenium
{
///
@@ -28,9 +30,6 @@ namespace OpenQA.Selenium
///
public class LogEntry
{
- private LogLevel level = LogLevel.All;
- private DateTime timestamp = DateTime.MinValue;
- private string message = string.Empty;
///
/// Initializes a new instance of the class.
@@ -42,26 +41,19 @@ private LogEntry()
///
/// Gets the timestamp value of the log entry.
///
- public DateTime Timestamp
- {
- get { return this.timestamp; }
- }
+ public DateTime Timestamp { get; private set; } = DateTime.MinValue;
///
/// Gets the logging level of the log entry.
///
- public LogLevel Level
- {
- get { return this.level; }
- }
+ public LogLevel Level { get; private set; } = LogLevel.All;
///
/// Gets the message of the log entry.
///
- public string Message
- {
- get { return this.message; }
- }
+ public string Message { get; private set; } = string.Empty;
+
+ private static readonly DateTime UnixEpoch = new(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
///
/// Returns a string that represents the current .
@@ -69,7 +61,7 @@ public string Message
/// A string that represents the current .
public override string ToString()
{
- return string.Format(CultureInfo.InvariantCulture, "[{0:yyyy-MM-ddTHH:mm:ssZ}] [{1}] {2}", this.timestamp, this.level, this.message);
+ return string.Format(CultureInfo.InvariantCulture, "[{0:yyyy-MM-ddTHH:mm:ssZ}] [{1}] {2}", this.Timestamp, this.Level, this.Message);
}
///
@@ -78,32 +70,31 @@ public override string ToString()
/// The from
/// which to create the .
/// A with the values in the dictionary.
- internal static LogEntry FromDictionary(Dictionary entryDictionary)
+ internal static LogEntry FromDictionary(Dictionary entryDictionary)
{
LogEntry entry = new LogEntry();
- if (entryDictionary.ContainsKey("message"))
+ if (entryDictionary.TryGetValue("message", out object? message))
{
- entry.message = entryDictionary["message"].ToString();
+ entry.Message = message?.ToString() ?? string.Empty;
}
- if (entryDictionary.ContainsKey("timestamp"))
+ if (entryDictionary.TryGetValue("timestamp", out object? timestamp))
{
- DateTime zeroDate = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
- double timestampValue = Convert.ToDouble(entryDictionary["timestamp"], CultureInfo.InvariantCulture);
- entry.timestamp = zeroDate.AddMilliseconds(timestampValue);
+ double timestampValue = Convert.ToDouble(timestamp, CultureInfo.InvariantCulture);
+ entry.Timestamp = UnixEpoch.AddMilliseconds(timestampValue);
}
- if (entryDictionary.ContainsKey("level"))
+ if (entryDictionary.TryGetValue("level", out object? level))
{
- string levelValue = entryDictionary["level"].ToString();
- try
+ if (Enum.TryParse(level?.ToString(), ignoreCase: true, out LogLevel result))
{
- entry.level = (LogLevel)Enum.Parse(typeof(LogLevel), levelValue, true);
+ entry.Level = result;
}
- catch (ArgumentException)
+ else
{
// If the requested log level string is not a valid log level,
// ignore it and use LogLevel.All.
+ entry.Level = LogLevel.All;
}
}
diff --git a/dotnet/src/webdriver/LogLevel.cs b/dotnet/src/webdriver/LogLevel.cs
index 962d32cae682e..fd5c291c3a165 100644
--- a/dotnet/src/webdriver/LogLevel.cs
+++ b/dotnet/src/webdriver/LogLevel.cs
@@ -17,6 +17,8 @@
// under the License.
//
+#nullable enable
+
namespace OpenQA.Selenium
{
///
diff --git a/dotnet/src/webdriver/Logs.cs b/dotnet/src/webdriver/Logs.cs
index 74fa3102977d5..91afcc03eb6cd 100644
--- a/dotnet/src/webdriver/Logs.cs
+++ b/dotnet/src/webdriver/Logs.cs
@@ -21,6 +21,8 @@
using System.Collections.Generic;
using System.Collections.ObjectModel;
+#nullable enable
+
namespace OpenQA.Selenium
{
///
@@ -28,15 +30,16 @@ namespace OpenQA.Selenium
///
public class Logs : ILogs
{
- private WebDriver driver;
+ private readonly WebDriver driver;
///
/// Initializes a new instance of the class.
///
/// Instance of the driver currently in use
+ /// If is .
public Logs(WebDriver driver)
{
- this.driver = driver;
+ this.driver = driver ?? throw new ArgumentNullException(nameof(driver));
}
///
@@ -50,12 +53,11 @@ public ReadOnlyCollection AvailableLogTypes
try
{
Response commandResponse = this.driver.InternalExecute(DriverCommand.GetAvailableLogTypes, null);
- object[] responseValue = commandResponse.Value as object[];
- if (responseValue != null)
+ if (commandResponse.Value is object[] responseValue)
{
foreach (object logKind in responseValue)
{
- availableLogTypes.Add(logKind.ToString());
+ availableLogTypes.Add(logKind.ToString()!);
}
}
}
@@ -74,21 +76,25 @@ public ReadOnlyCollection AvailableLogTypes
/// The log for which to retrieve the log entries.
/// Log types can be found in the class.
/// The list of objects for the specified log.
+ /// If is .
public ReadOnlyCollection GetLog(string logKind)
{
+ if (logKind is null)
+ {
+ throw new ArgumentNullException(nameof(logKind));
+ }
+
List entries = new List();
Dictionary parameters = new Dictionary();
parameters.Add("type", logKind);
Response commandResponse = this.driver.InternalExecute(DriverCommand.GetLog, parameters);
- object[] responseValue = commandResponse.Value as object[];
- if (responseValue != null)
+ if (commandResponse.Value is object?[] responseValue)
{
- foreach (object rawEntry in responseValue)
+ foreach (object? rawEntry in responseValue)
{
- Dictionary entryDictionary = rawEntry as Dictionary;
- if (entryDictionary != null)
+ if (rawEntry is Dictionary entryDictionary)
{
entries.Add(LogEntry.FromDictionary(entryDictionary));
}
diff --git a/dotnet/src/webdriver/Platform.cs b/dotnet/src/webdriver/Platform.cs
index c143fd682d3b7..4ea2cc9be61c8 100644
--- a/dotnet/src/webdriver/Platform.cs
+++ b/dotnet/src/webdriver/Platform.cs
@@ -19,6 +19,8 @@
using System;
+#nullable enable
+
namespace OpenQA.Selenium
{
///
@@ -84,10 +86,7 @@ public enum PlatformType
///
public class Platform
{
- private static Platform current;
- private PlatformType platformTypeValue;
- private int major;
- private int minor;
+ private static Platform? current;
///
/// Initializes a new instance of the class for a specific platform type.
@@ -95,39 +94,39 @@ public class Platform
/// The platform type.
public Platform(PlatformType typeValue)
{
- this.platformTypeValue = typeValue;
+ this.PlatformType = typeValue;
}
private Platform()
{
- this.major = Environment.OSVersion.Version.Major;
- this.minor = Environment.OSVersion.Version.Minor;
+ this.MajorVersion = Environment.OSVersion.Version.Major;
+ this.MinorVersion = Environment.OSVersion.Version.Minor;
switch (Environment.OSVersion.Platform)
{
case PlatformID.Win32NT:
- if (this.major == 5)
+ if (this.MajorVersion == 5)
{
- this.platformTypeValue = PlatformType.XP;
+ this.PlatformType = PlatformType.XP;
}
- else if (this.major == 6)
+ else if (this.MajorVersion == 6)
{
- this.platformTypeValue = PlatformType.Vista;
+ this.PlatformType = PlatformType.Vista;
}
else
{
- this.platformTypeValue = PlatformType.Windows;
+ this.PlatformType = PlatformType.Windows;
}
break;
// Thanks to a bug in Mono Mac and Linux will be treated the same https://bugzilla.novell.com/show_bug.cgi?id=515570 but adding this in case
case PlatformID.MacOSX:
- this.platformTypeValue = PlatformType.Mac;
+ this.PlatformType = PlatformType.Mac;
break;
case PlatformID.Unix:
- this.platformTypeValue = PlatformType.Unix;
+ this.PlatformType = PlatformType.Unix;
break;
}
}
@@ -135,87 +134,44 @@ private Platform()
///
/// Gets the current platform.
///
- public static Platform CurrentPlatform
- {
- get
- {
- if (current == null)
- {
- current = new Platform();
- }
-
- return current;
- }
- }
+ public static Platform CurrentPlatform => current ??= new Platform();
///
/// Gets the major version of the platform operating system.
///
- public int MajorVersion
- {
- get { return this.major; }
- }
+ public int MajorVersion { get; }
///
/// Gets the major version of the platform operating system.
///
- public int MinorVersion
- {
- get { return this.minor; }
- }
+ public int MinorVersion { get; }
///
/// Gets the type of the platform.
///
- public PlatformType PlatformType
- {
- get { return this.platformTypeValue; }
- }
+ public PlatformType PlatformType { get; }
///
/// Gets the value of the platform type for transmission using the JSON Wire Protocol.
///
- public string ProtocolPlatformType
- {
- get { return this.platformTypeValue.ToString("G").ToUpperInvariant(); }
- }
+ public string ProtocolPlatformType => this.PlatformType.ToString("G").ToUpperInvariant();
///
/// Compares the platform to the specified type.
///
- /// A value to compare to.
+ /// A value to compare to.
/// if the platforms match; otherwise .
public bool IsPlatformType(PlatformType compareTo)
{
- bool platformIsType = false;
- switch (compareTo)
+ return compareTo switch
{
- case PlatformType.Any:
- platformIsType = true;
- break;
-
- case PlatformType.Windows:
- platformIsType = this.platformTypeValue == PlatformType.Windows || this.platformTypeValue == PlatformType.XP || this.platformTypeValue == PlatformType.Vista;
- break;
-
- case PlatformType.Vista:
- platformIsType = this.platformTypeValue == PlatformType.Windows || this.platformTypeValue == PlatformType.Vista;
- break;
-
- case PlatformType.XP:
- platformIsType = this.platformTypeValue == PlatformType.Windows || this.platformTypeValue == PlatformType.XP;
- break;
-
- case PlatformType.Linux:
- platformIsType = this.platformTypeValue == PlatformType.Linux || this.platformTypeValue == PlatformType.Unix;
- break;
-
- default:
- platformIsType = this.platformTypeValue == compareTo;
- break;
- }
-
- return platformIsType;
+ PlatformType.Any => true,
+ PlatformType.Windows => this.PlatformType is PlatformType.Windows or PlatformType.XP or PlatformType.Vista,
+ PlatformType.Vista => this.PlatformType is PlatformType.Windows or PlatformType.Vista,
+ PlatformType.XP => this.PlatformType is PlatformType.Windows or PlatformType.XP,
+ PlatformType.Linux => this.PlatformType is PlatformType.Linux or PlatformType.Unix,
+ _ => this.PlatformType == compareTo,
+ };
}
///
@@ -224,7 +180,7 @@ public bool IsPlatformType(PlatformType compareTo)
/// The string value for this platform type.
public override string ToString()
{
- return this.platformTypeValue.ToString();
+ return this.PlatformType.ToString();
}
///
@@ -234,18 +190,15 @@ public override string ToString()
/// The Platform object represented by the string name.
internal static Platform FromString(string platformName)
{
- PlatformType platformTypeFromString = PlatformType.Any;
- try
+ if (Enum.TryParse(platformName, ignoreCase: true, out PlatformType platformTypeFromString))
{
- platformTypeFromString = (PlatformType)Enum.Parse(typeof(PlatformType), platformName, true);
- }
- catch (ArgumentException)
- {
- // If the requested platform string is not a valid platform type,
- // ignore it and use PlatformType.Any.
+ return new Platform(platformTypeFromString);
}
- return new Platform(platformTypeFromString);
+ // If the requested platform string is not a valid platform type,
+ // ignore it and use PlatformType.Any.
+
+ return new Platform(PlatformType.Any);
}
}
}
diff --git a/dotnet/src/webdriver/Proxy.cs b/dotnet/src/webdriver/Proxy.cs
index 0216c50105ce8..fbbf55a3b9c97 100644
--- a/dotnet/src/webdriver/Proxy.cs
+++ b/dotnet/src/webdriver/Proxy.cs
@@ -23,6 +23,8 @@
using System.Globalization;
using System.Text.Json.Serialization;
+#nullable enable
+
namespace OpenQA.Selenium
{
///
@@ -72,13 +74,13 @@ public class Proxy
{
private ProxyKind proxyKind = ProxyKind.Unspecified;
private bool isAutoDetect;
- private string ftpProxyLocation;
- private string httpProxyLocation;
- private string proxyAutoConfigUrl;
- private string sslProxyLocation;
- private string socksProxyLocation;
- private string socksUserName;
- private string socksPassword;
+ private string? ftpProxyLocation;
+ private string? httpProxyLocation;
+ private string? proxyAutoConfigUrl;
+ private string? sslProxyLocation;
+ private string? socksProxyLocation;
+ private string? socksUserName;
+ private string? socksPassword;
private int? socksVersion;
private List noProxyAddresses = new List();
@@ -93,6 +95,8 @@ public Proxy()
/// Initializes a new instance of the class with the given proxy settings.
///
/// A dictionary of settings to use with the proxy.
+ /// If is .
+ /// If The "noProxy" value is a list with a element.
public Proxy(Dictionary settings)
{
if (settings == null)
@@ -100,46 +104,44 @@ public Proxy(Dictionary settings)
throw new ArgumentNullException(nameof(settings), "settings dictionary cannot be null");
}
- if (settings.ContainsKey("proxyType") && settings["proxyType"] != null)
+ if (settings.TryGetValue("proxyType", out object? proxyTypeObj) && proxyTypeObj?.ToString() is string proxyType)
{
// Special-case "PAC" since that is the correct serialization.
- if (settings["proxyType"].ToString().ToLowerInvariant() == "pac")
+ if (proxyType.Equals("pac", StringComparison.InvariantCultureIgnoreCase))
{
this.Kind = ProxyKind.ProxyAutoConfigure;
}
else
{
- ProxyKind rawType = (ProxyKind)Enum.Parse(typeof(ProxyKind), settings["proxyType"].ToString(), true);
+ ProxyKind rawType = (ProxyKind)Enum.Parse(typeof(ProxyKind), proxyType, ignoreCase: true);
this.Kind = rawType;
}
}
- if (settings.ContainsKey("ftpProxy") && settings["ftpProxy"] != null)
+ if (settings.TryGetValue("ftpProxy", out object? ftpProxyObj) && ftpProxyObj?.ToString() is string ftpProxy)
{
- this.FtpProxy = settings["ftpProxy"].ToString();
+ this.FtpProxy = ftpProxy;
}
- if (settings.ContainsKey("httpProxy") && settings["httpProxy"] != null)
+ if (settings.TryGetValue("httpProxy", out object? httpProxyObj) && httpProxyObj?.ToString() is string httpProxy)
{
- this.HttpProxy = settings["httpProxy"].ToString();
+ this.HttpProxy = httpProxy;
}
- if (settings.ContainsKey("noProxy") && settings["noProxy"] != null)
+ if (settings.TryGetValue("noProxy", out object? noProxy) && noProxy != null)
{
List bypassAddresses = new List();
- string addressesAsString = settings["noProxy"] as string;
- if (addressesAsString != null)
+ if (noProxy is string addressesAsString)
{
bypassAddresses.AddRange(addressesAsString.Split(';'));
}
else
{
- object[] addressesAsArray = settings["noProxy"] as object[];
- if (addressesAsArray != null)
+ if (noProxy is object?[] addressesAsArray)
{
- foreach (object address in addressesAsArray)
+ foreach (object? address in addressesAsArray)
{
- bypassAddresses.Add(address.ToString());
+ bypassAddresses.Add(address?.ToString() ?? throw new ArgumentException("Proxy bypass address list \"noProxy\" contained a null element", nameof(settings)));
}
}
}
@@ -147,39 +149,39 @@ public Proxy(Dictionary settings)
this.AddBypassAddresses(bypassAddresses);
}
- if (settings.ContainsKey("proxyAutoconfigUrl") && settings["proxyAutoconfigUrl"] != null)
+ if (settings.TryGetValue("proxyAutoconfigUrl", out object? proxyAutoconfigUrlObj) && proxyAutoconfigUrlObj?.ToString() is string proxyAutoconfigUrl)
{
- this.ProxyAutoConfigUrl = settings["proxyAutoconfigUrl"].ToString();
+ this.ProxyAutoConfigUrl = proxyAutoconfigUrl;
}
- if (settings.ContainsKey("sslProxy") && settings["sslProxy"] != null)
+ if (settings.TryGetValue("sslProxy", out object? sslProxyObj) && sslProxyObj?.ToString() is string sslProxy)
{
- this.SslProxy = settings["sslProxy"].ToString();
+ this.SslProxy = sslProxy;
}
- if (settings.ContainsKey("socksProxy") && settings["socksProxy"] != null)
+ if (settings.TryGetValue("socksProxy", out object? socksProxyObj) && socksProxyObj?.ToString() is string socksProxy)
{
- this.SocksProxy = settings["socksProxy"].ToString();
+ this.SocksProxy = socksProxy;
}
- if (settings.ContainsKey("socksUsername") && settings["socksUsername"] != null)
+ if (settings.TryGetValue("socksUsername", out object? socksUsernameObj) && socksUsernameObj?.ToString() is string socksUsername)
{
- this.SocksUserName = settings["socksUsername"].ToString();
+ this.SocksUserName = socksUsername;
}
- if (settings.ContainsKey("socksPassword") && settings["socksPassword"] != null)
+ if (settings.TryGetValue("socksPassword", out object? socksPasswordObj) && socksPasswordObj?.ToString() is string socksPassword)
{
- this.SocksPassword = settings["socksPassword"].ToString();
+ this.SocksPassword = socksPassword;
}
- if (settings.ContainsKey("socksVersion") && settings["socksVersion"] != null)
+ if (settings.TryGetValue("socksVersion", out object? socksVersion) && socksVersion != null)
{
- this.SocksVersion = Convert.ToInt32(settings["socksVersion"]);
+ this.SocksVersion = Convert.ToInt32(socksVersion);
}
- if (settings.ContainsKey("autodetect") && settings["autodetect"] != null)
+ if (settings.TryGetValue("autodetect", out object? autodetect) && autodetect != null)
{
- this.IsAutoDetect = (bool)settings["autodetect"];
+ this.IsAutoDetect = Convert.ToBoolean(autodetect);
}
}
@@ -189,10 +191,7 @@ public Proxy(Dictionary settings)
[JsonIgnore]
public ProxyKind Kind
{
- get
- {
- return this.proxyKind;
- }
+ get => this.proxyKind;
set
{
@@ -224,10 +223,7 @@ public string SerializableProxyKind
[JsonIgnore]
public bool IsAutoDetect
{
- get
- {
- return this.isAutoDetect;
- }
+ get => this.isAutoDetect;
set
{
@@ -247,12 +243,9 @@ public bool IsAutoDetect
///
[JsonPropertyName("ftpProxy")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]
- public string FtpProxy
+ public string? FtpProxy
{
- get
- {
- return this.ftpProxyLocation;
- }
+ get => this.ftpProxyLocation;
set
{
@@ -267,12 +260,9 @@ public string FtpProxy
///
[JsonPropertyName("httpProxy")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]
- public string HttpProxy
+ public string? HttpProxy
{
- get
- {
- return this.httpProxyLocation;
- }
+ get => this.httpProxyLocation;
set
{
@@ -287,7 +277,7 @@ public string HttpProxy
///
[JsonPropertyName("noProxy")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]
- public ReadOnlyCollection BypassProxyAddresses
+ public ReadOnlyCollection? BypassProxyAddresses
{
get
{
@@ -305,12 +295,9 @@ public ReadOnlyCollection BypassProxyAddresses
///
[JsonPropertyName("proxyAutoconfigUrl")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]
- public string ProxyAutoConfigUrl
+ public string? ProxyAutoConfigUrl
{
- get
- {
- return this.proxyAutoConfigUrl;
- }
+ get => this.proxyAutoConfigUrl;
set
{
@@ -325,12 +312,9 @@ public string ProxyAutoConfigUrl
///
[JsonPropertyName("sslProxy")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]
- public string SslProxy
+ public string? SslProxy
{
- get
- {
- return this.sslProxyLocation;
- }
+ get => this.sslProxyLocation;
set
{
@@ -345,12 +329,9 @@ public string SslProxy
///
[JsonPropertyName("socksProxy")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]
- public string SocksProxy
+ public string? SocksProxy
{
- get
- {
- return this.socksProxyLocation;
- }
+ get => this.socksProxyLocation;
set
{
@@ -365,12 +346,9 @@ public string SocksProxy
///
[JsonPropertyName("socksUsername")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]
- public string SocksUserName
+ public string? SocksUserName
{
- get
- {
- return this.socksUserName;
- }
+ get => this.socksUserName;
set
{
@@ -388,10 +366,7 @@ public string SocksUserName
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]
public int? SocksVersion
{
- get
- {
- return this.socksVersion;
- }
+ get => this.socksVersion;
set
{
@@ -403,7 +378,7 @@ public int? SocksVersion
{
if (value.Value <= 0)
{
- throw new ArgumentException("SocksVersion must be a positive integer");
+ throw new ArgumentOutOfRangeException(nameof(value), "SocksVersion must be a positive integer");
}
this.VerifyProxyTypeCompatilibily(ProxyKind.Manual);
@@ -418,12 +393,9 @@ public int? SocksVersion
///
[JsonPropertyName("socksPassword")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]
- public string SocksPassword
+ public string? SocksPassword
{
- get
- {
- return this.socksPassword;
- }
+ get => this.socksPassword;
set
{
@@ -453,7 +425,7 @@ public void AddBypassAddress(string address)
/// An array of addresses to add.
public void AddBypassAddresses(params string[] addressesToAdd)
{
- this.AddBypassAddresses(new List(addressesToAdd));
+ this.AddBypassAddresses((IEnumerable)addressesToAdd);
}
///
@@ -478,7 +450,7 @@ public void AddBypassAddresses(IEnumerable addressesToAdd)
///
/// A dictionary suitable for serializing to the W3C Specification
/// dialect of the wire protocol.
- internal Dictionary ToCapability()
+ internal Dictionary? ToCapability()
{
return this.AsDictionary(true);
}
@@ -489,17 +461,17 @@ internal Dictionary ToCapability()
///
/// A dictionary suitable for serializing to the OSS dialect of the
/// wire protocol.
- internal Dictionary ToLegacyCapability()
+ internal Dictionary? ToLegacyCapability()
{
return this.AsDictionary(false);
}
- private Dictionary AsDictionary(bool isSpecCompliant)
+ private Dictionary? AsDictionary(bool isSpecCompliant)
{
- Dictionary serializedDictionary = null;
+ Dictionary? serializedDictionary = null;
if (this.proxyKind != ProxyKind.Unspecified)
{
- serializedDictionary = new Dictionary();
+ serializedDictionary = new Dictionary();
if (this.proxyKind == ProxyKind.ProxyAutoConfigure)
{
serializedDictionary["proxyType"] = "pac";
@@ -556,17 +528,12 @@ private Dictionary AsDictionary(bool isSpecCompliant)
return serializedDictionary;
}
- private object GetNoProxyAddressList(bool isSpecCompliant)
+ private object? GetNoProxyAddressList(bool isSpecCompliant)
{
- object addresses = null;
+ object? addresses = null;
if (isSpecCompliant)
{
- List addressList = new List();
- foreach (string address in this.noProxyAddresses)
- {
- addressList.Add(address);
- }
-
+ List addressList = [.. this.noProxyAddresses];
addresses = addressList;
}
else
diff --git a/dotnet/src/webdriver/Remote/DriverServiceCommandExecutor.cs b/dotnet/src/webdriver/Remote/DriverServiceCommandExecutor.cs
index 2a374d5f5eb14..b9bb4efcf0084 100644
--- a/dotnet/src/webdriver/Remote/DriverServiceCommandExecutor.cs
+++ b/dotnet/src/webdriver/Remote/DriverServiceCommandExecutor.cs
@@ -20,6 +20,8 @@
using System;
using System.Threading.Tasks;
+#nullable enable
+
namespace OpenQA.Selenium.Remote
{
///
@@ -27,8 +29,7 @@ namespace OpenQA.Selenium.Remote
///
public class DriverServiceCommandExecutor : ICommandExecutor
{
- private DriverService service;
- private HttpCommandExecutor internalExecutor;
+ private readonly DriverService service;
private bool isDisposed;
///
@@ -36,6 +37,7 @@ public class DriverServiceCommandExecutor : ICommandExecutor
///
/// The that drives the browser.
/// The maximum amount of time to wait for each command.
+ /// If is .
public DriverServiceCommandExecutor(DriverService driverService, TimeSpan commandTimeout)
: this(driverService, commandTimeout, true)
{
@@ -48,10 +50,11 @@ public DriverServiceCommandExecutor(DriverService driverService, TimeSpan comman
/// The maximum amount of time to wait for each command.
/// if the KeepAlive header should be sent
/// with HTTP requests; otherwise, .
+ /// If is .
public DriverServiceCommandExecutor(DriverService driverService, TimeSpan commandTimeout, bool enableKeepAlive)
{
- this.service = driverService;
- this.internalExecutor = new HttpCommandExecutor(driverService.ServiceUrl, commandTimeout, enableKeepAlive);
+ this.service = driverService ?? throw new ArgumentNullException(nameof(driverService));
+ this.HttpExecutor = new HttpCommandExecutor(driverService.ServiceUrl, commandTimeout, enableKeepAlive);
}
///
@@ -60,10 +63,11 @@ public DriverServiceCommandExecutor(DriverService driverService, TimeSpan comman
/// The that drives the browser.
/// The object used to execute commands,
/// communicating with the service via HTTP.
+ /// If or are .
public DriverServiceCommandExecutor(DriverService service, HttpCommandExecutor commandExecutor)
{
- this.service = service;
- this.internalExecutor = commandExecutor;
+ this.service = service ?? throw new ArgumentNullException(nameof(service));
+ this.HttpExecutor = commandExecutor ?? throw new ArgumentNullException(nameof(commandExecutor));
}
///
@@ -71,22 +75,19 @@ public DriverServiceCommandExecutor(DriverService service, HttpCommandExecutor c
///
//public CommandInfoRepository CommandInfoRepository
//{
- // get { return this.internalExecutor.CommandInfoRepository; }
+ // get { return this.HttpExecutor.CommandInfoRepository; }
//}
public bool TryAddCommand(string commandName, CommandInfo info)
{
- return this.internalExecutor.TryAddCommand(commandName, info);
+ return this.HttpExecutor.TryAddCommand(commandName, info);
}
///
/// Gets the that sends commands to the remote
/// end WebDriver implementation.
///
- public HttpCommandExecutor HttpExecutor
- {
- get { return this.internalExecutor; }
- }
+ public HttpCommandExecutor HttpExecutor { get; }
///
/// Executes a command
@@ -110,7 +111,7 @@ public async Task ExecuteAsync(Command commandToExecute)
throw new ArgumentNullException(nameof(commandToExecute), "Command to execute cannot be null");
}
- Response toReturn = null;
+ Response toReturn;
if (commandToExecute.Name == DriverCommand.NewSession)
{
this.service.Start();
@@ -120,7 +121,7 @@ public async Task ExecuteAsync(Command commandToExecute)
// command, so that we can get the finally block.
try
{
- toReturn = await this.internalExecutor.ExecuteAsync(commandToExecute).ConfigureAwait(false);
+ toReturn = await this.HttpExecutor.ExecuteAsync(commandToExecute).ConfigureAwait(false);
}
finally
{
@@ -139,6 +140,7 @@ public async Task ExecuteAsync(Command commandToExecute)
public void Dispose()
{
this.Dispose(true);
+ GC.SuppressFinalize(this);
}
///
@@ -153,7 +155,7 @@ protected virtual void Dispose(bool disposing)
{
if (disposing)
{
- this.internalExecutor.Dispose();
+ this.HttpExecutor.Dispose();
this.service.Dispose();
}
diff --git a/dotnet/src/webdriver/Remote/HttpCommandExecutor.cs b/dotnet/src/webdriver/Remote/HttpCommandExecutor.cs
index a5d60f67e49ff..0686239405e38 100644
--- a/dotnet/src/webdriver/Remote/HttpCommandExecutor.cs
+++ b/dotnet/src/webdriver/Remote/HttpCommandExecutor.cs
@@ -326,7 +326,7 @@ private Response CreateResponse(HttpResponseInfo responseInfo)
}
else
{
- response.Status = WebDriverResult.UnhandledError;
+ response.Status = WebDriverResult.UnknownError;
response.Value = body;
}
}
diff --git a/dotnet/src/webdriver/Remote/ICommandServer.cs b/dotnet/src/webdriver/Remote/ICommandServer.cs
index 395616482f7d5..f70d536dfd042 100644
--- a/dotnet/src/webdriver/Remote/ICommandServer.cs
+++ b/dotnet/src/webdriver/Remote/ICommandServer.cs
@@ -19,6 +19,8 @@
using System;
+#nullable enable
+
namespace OpenQA.Selenium.Remote
{
///
diff --git a/dotnet/src/webdriver/Remote/W3CWireProtocolCommandInfoRepository.cs b/dotnet/src/webdriver/Remote/W3CWireProtocolCommandInfoRepository.cs
index 8c51b36fd6035..d800da185613e 100644
--- a/dotnet/src/webdriver/Remote/W3CWireProtocolCommandInfoRepository.cs
+++ b/dotnet/src/webdriver/Remote/W3CWireProtocolCommandInfoRepository.cs
@@ -19,6 +19,8 @@
using System;
+#nullable enable
+
namespace OpenQA.Selenium.Remote
{
///
@@ -40,18 +42,12 @@ public W3CWireProtocolCommandInfoRepository()
///
/// Gets the level of the W3C WebDriver specification that this repository supports.
///
- public override int SpecificationLevel
- {
- get { return 1; }
- }
+ public override int SpecificationLevel => 1;
///
/// Gets the that is valid for this
///
- protected override Type RepositoryCommandInfoType
- {
- get { return typeof(HttpCommandInfo); }
- }
+ protected override Type RepositoryCommandInfoType => typeof(HttpCommandInfo);
///
/// Initializes the dictionary of commands for the CommandInfoRepository
diff --git a/dotnet/src/webdriver/Response.cs b/dotnet/src/webdriver/Response.cs
index 39962a0484a1f..abe4bb2a9fcdd 100644
--- a/dotnet/src/webdriver/Response.cs
+++ b/dotnet/src/webdriver/Response.cs
@@ -31,16 +31,12 @@ namespace OpenQA.Selenium
///
public class Response
{
- private readonly static JsonSerializerOptions s_jsonSerializerOptions = new()
+ private static readonly JsonSerializerOptions s_jsonSerializerOptions = new()
{
TypeInfoResolver = ResponseJsonSerializerContext.Default,
Converters = { new ResponseValueJsonConverter() } // we still need it to make `Object` as `Dictionary`
};
- private object responseValue;
- private string responseSessionId;
- private WebDriverResult responseStatus;
-
///
/// Initializes a new instance of the class
///
@@ -56,23 +52,33 @@ public Response(SessionId sessionId)
{
if (sessionId != null)
{
- this.responseSessionId = sessionId.ToString();
+ this.SessionId = sessionId.ToString();
}
}
- private Response(Dictionary rawResponse)
+ ///
+ /// Returns a new from a JSON-encoded string.
+ ///
+ /// The JSON string to deserialize into a .
+ /// A object described by the JSON string.
+ public static Response FromJson(string value)
{
+ Dictionary rawResponse = JsonSerializer.Deserialize>(value, s_jsonSerializerOptions)
+ ?? throw new WebDriverException("JSON success response returned \"null\" value");
+
+ var response = new Response();
+
if (rawResponse.ContainsKey("sessionId"))
{
if (rawResponse["sessionId"] != null)
{
- this.responseSessionId = rawResponse["sessionId"].ToString();
+ response.SessionId = rawResponse["sessionId"].ToString();
}
}
- if (rawResponse.ContainsKey("value"))
+ if (rawResponse.TryGetValue("value", out object valueObj))
{
- this.responseValue = rawResponse["value"];
+ response.Value = valueObj;
}
// If the returned object does *not* have a "value" property
@@ -80,78 +86,56 @@ private Response(Dictionary rawResponse)
// TODO: Remove this if statement altogether; there should
// never be a spec-compliant response that does not contain a
// value property.
- if (!rawResponse.ContainsKey("value") && this.responseValue == null)
+ if (!rawResponse.ContainsKey("value") && response.Value == null)
{
// Special-case for the new session command, where the "capabilities"
// property of the response is the actual value we're interested in.
if (rawResponse.ContainsKey("capabilities"))
{
- this.responseValue = rawResponse["capabilities"];
+ response.Value = rawResponse["capabilities"];
}
else
{
- this.responseValue = rawResponse;
+ response.Value = rawResponse;
}
}
- Dictionary valueDictionary = this.responseValue as Dictionary;
- if (valueDictionary != null)
+ if (response.Value is Dictionary valueDictionary)
{
// Special case code for the new session command. If the response contains
// sessionId and capabilities properties, fix up the session ID and value members.
if (valueDictionary.ContainsKey("sessionId"))
{
- this.responseSessionId = valueDictionary["sessionId"].ToString();
- if (valueDictionary.ContainsKey("capabilities"))
+ response.SessionId = valueDictionary["sessionId"].ToString();
+ if (valueDictionary.TryGetValue("capabilities", out object capabilities))
{
- this.responseValue = valueDictionary["capabilities"];
+ response.Value = capabilities;
}
else
{
- this.responseValue = valueDictionary["value"];
+ response.Value = valueDictionary["value"];
}
}
}
+
+ return response;
}
///
/// Gets or sets the value from JSON.
///
- public object Value
- {
- get { return this.responseValue; }
- set { this.responseValue = value; }
- }
+ public object Value { get; set; }
///
/// Gets or sets the session ID.
///
- public string SessionId
- {
- get { return this.responseSessionId; }
- set { this.responseSessionId = value; }
- }
+ public string SessionId { get; set; }
///
/// Gets or sets the status value of the response.
///
- public WebDriverResult Status
- {
- get { return this.responseStatus; }
- set { this.responseStatus = value; }
- }
+ public WebDriverResult Status { get; set; }
- ///
- /// Returns a new from a JSON-encoded string.
- ///
- /// The JSON string to deserialize into a .
- /// A object described by the JSON string.
- public static Response FromJson(string value)
- {
- Dictionary deserializedResponse = JsonSerializer.Deserialize>(value, s_jsonSerializerOptions);
- Response response = new Response(deserializedResponse);
- return response;
- }
///
/// Returns a new from a JSON-encoded string.
@@ -160,7 +144,8 @@ public static Response FromJson(string value)
/// A object described by the JSON string.
public static Response FromErrorJson(string value)
{
- var deserializedResponse = JsonSerializer.Deserialize>(value, s_jsonSerializerOptions);
+ var deserializedResponse = JsonSerializer.Deserialize>(value, s_jsonSerializerOptions)
+ ?? throw new WebDriverException("JSON error response returned \"null\" value");
var response = new Response();
@@ -181,14 +166,14 @@ public static Response FromErrorJson(string value)
throw new WebDriverException($"The 'value > error' property was not found in the response:{Environment.NewLine}{value}");
}
- if (errorObject is not string)
+ if (errorObject is not string errorString)
{
throw new WebDriverException($"The 'value > error' property is not a string{Environment.NewLine}{value}");
}
response.Value = deserializedResponse["value"];
- response.Status = WebDriverError.ResultFromError(errorObject.ToString());
+ response.Status = WebDriverError.ResultFromError(errorString);
return response;
}
@@ -213,8 +198,5 @@ public override string ToString()
}
[JsonSerializable(typeof(Dictionary))]
- internal partial class ResponseJsonSerializerContext : JsonSerializerContext
- {
-
- }
+ internal sealed partial class ResponseJsonSerializerContext : JsonSerializerContext;
}
diff --git a/dotnet/src/webdriver/SessionId.cs b/dotnet/src/webdriver/SessionId.cs
index 7cf90da7f69d1..8f605d4731775 100644
--- a/dotnet/src/webdriver/SessionId.cs
+++ b/dotnet/src/webdriver/SessionId.cs
@@ -17,6 +17,10 @@
// under the License.
//
+using System;
+
+#nullable enable
+
namespace OpenQA.Selenium
{
///
@@ -24,15 +28,16 @@ namespace OpenQA.Selenium
///
public class SessionId
{
- private string sessionOpaqueKey;
+ private readonly string sessionOpaqueKey;
///
/// Initializes a new instance of the class
///
/// Key for the session in use
+ /// If is .
public SessionId(string opaqueKey)
{
- this.sessionOpaqueKey = opaqueKey;
+ this.sessionOpaqueKey = opaqueKey ?? throw new ArgumentNullException(nameof(opaqueKey));
}
///
@@ -54,20 +59,13 @@ public override int GetHashCode()
}
///
- /// Compares two Sessions
+ /// Indicates whether the current session ID value is the same as .
///
- /// Session to compare
- /// True if they are equal or False if they are not
- public override bool Equals(object obj)
+ /// The session to compare to.
+ /// if the values are equal; otherwise, .
+ public override bool Equals(object? obj)
{
- bool objectsAreEqual = false;
- SessionId other = obj as SessionId;
- if (other != null)
- {
- objectsAreEqual = this.sessionOpaqueKey.Equals(other.sessionOpaqueKey);
- }
-
- return objectsAreEqual;
+ return obj is SessionId otherSession && this.sessionOpaqueKey.Equals(otherSession.sessionOpaqueKey);
}
}
}
diff --git a/dotnet/src/webdriver/UnknownErrorException.cs b/dotnet/src/webdriver/UnknownErrorException.cs
new file mode 100644
index 0000000000000..466bc19d9c479
--- /dev/null
+++ b/dotnet/src/webdriver/UnknownErrorException.cs
@@ -0,0 +1,51 @@
+//
+// 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;
+
+#nullable enable
+
+namespace OpenQA.Selenium
+{
+ ///
+ /// An unknown error occurred in the remote end while processing the command.
+ ///
+ [Serializable]
+ public class UnknownErrorException : WebDriverException
+ {
+ ///
+ /// Initializes a new instance of the class with the specified message.
+ ///
+ /// The message of the exception.
+ public UnknownErrorException(string? message)
+ : base(message)
+ {
+ }
+
+ ///
+ /// Initializes a new instance of the class with the specified message and inner exception.
+ ///
+ /// The message of the exception.
+ /// The inner exception for this exception.
+ public UnknownErrorException(string? message, Exception? innerException)
+ : base(message, innerException)
+ {
+ }
+ }
+}
diff --git a/dotnet/src/webdriver/UnknownMethodException.cs b/dotnet/src/webdriver/UnknownMethodException.cs
new file mode 100644
index 0000000000000..168fc2dfedbec
--- /dev/null
+++ b/dotnet/src/webdriver/UnknownMethodException.cs
@@ -0,0 +1,49 @@
+//
+// 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;
+
+#nullable enable
+
+namespace OpenQA.Selenium
+{
+ ///
+ /// Exception that is thrown when the requested command matched a known URL but did not match any method for that URL.
+ ///
+ [Serializable]
+ public class UnknownMethodException : WebDriverException
+ {
+ ///
+ /// Initializes a new instance of the class with the specified message.
+ ///
+ /// The message of the exception.
+ public UnknownMethodException(string? message) : base(message)
+ {
+ }
+
+ ///
+ /// Initializes a new instance of the class with the specified message and inner exception.
+ ///
+ /// The message of the exception.
+ /// The inner exception for this exception.
+ public UnknownMethodException(string? message, Exception? innerException) : base(message, innerException)
+ {
+ }
+ }
+}
diff --git a/dotnet/src/webdriver/UnsupportedOperationException.cs b/dotnet/src/webdriver/UnsupportedOperationException.cs
new file mode 100644
index 0000000000000..a8d104400d6b3
--- /dev/null
+++ b/dotnet/src/webdriver/UnsupportedOperationException.cs
@@ -0,0 +1,50 @@
+//
+// 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;
+
+#nullable enable
+
+namespace OpenQA.Selenium
+{
+ ///
+ /// Indicates that a command that should have executed properly cannot be supported for some reason.
+ ///
+ public class UnsupportedOperationException : WebDriverException
+ {
+ ///
+ /// Initializes a new instance of the class with the specified message.
+ ///
+ /// The message of the exception.
+ public UnsupportedOperationException(string? message)
+ : base(message)
+ {
+ }
+
+ ///
+ /// Initializes a new instance of the class with the specified message and inner exception.
+ ///
+ /// The message of the exception.
+ /// The inner exception for this exception.
+ public UnsupportedOperationException(string? message, Exception? innerException)
+ : base(message, innerException)
+ {
+ }
+ }
+}
diff --git a/dotnet/src/webdriver/VirtualAuth/Credential.cs b/dotnet/src/webdriver/VirtualAuth/Credential.cs
index 170677b12e035..57dbcbe76ff45 100644
--- a/dotnet/src/webdriver/VirtualAuth/Credential.cs
+++ b/dotnet/src/webdriver/VirtualAuth/Credential.cs
@@ -18,31 +18,30 @@
//
using OpenQA.Selenium.Internal;
+using System;
using System.Collections.Generic;
+#nullable enable
+
namespace OpenQA.Selenium.VirtualAuth
{
///
/// A credential stored in a virtual authenticator.
- /// Refer https://w3c.github.io/webauthn/#credential-parameters
+ /// Refer
///
- public class Credential
+ public sealed class Credential
{
private readonly byte[] id;
- private readonly bool isResidentCredential;
- private readonly string rpId;
- private readonly string privateKey;
- private readonly byte[] userHandle;
- private readonly int signCount;
+ private readonly byte[]? userHandle;
- private Credential(byte[] id, bool isResidentCredential, string rpId, string privateKey, byte[] userHandle, int signCount)
+ private Credential(byte[] id, bool isResidentCredential, string rpId, string privateKey, byte[]? userHandle, int signCount)
{
- this.id = id;
- this.isResidentCredential = isResidentCredential;
- this.rpId = rpId;
- this.privateKey = privateKey;
+ this.id = id ?? throw new ArgumentNullException(nameof(id));
+ this.IsResidentCredential = isResidentCredential;
+ this.RpId = rpId ?? throw new ArgumentNullException(nameof(rpId));
+ this.PrivateKey = privateKey ?? throw new ArgumentNullException(nameof(privateKey));
this.userHandle = userHandle;
- this.signCount = signCount;
+ this.SignCount = signCount;
}
///
@@ -53,6 +52,7 @@ private Credential(byte[] id, bool isResidentCredential, string rpId, string pri
/// The private Key for the credentials.
/// The signature counter for the credentials.
/// The created instance of the Credential class.
+ /// If , , or are .
public static Credential CreateNonResidentCredential(byte[] id, string rpId, string privateKey, int signCount)
{
return new Credential(id, false, rpId, privateKey, null, signCount);
@@ -67,6 +67,7 @@ public static Credential CreateNonResidentCredential(byte[] id, string rpId, str
/// The user handle associated to the credential.
/// The signature counter for the credentials.
/// The created instance of the Credential class.
+ /// If , , or are .
public static Credential CreateResidentCredential(byte[] id, string rpId, string privateKey, byte[] userHandle, int signCount)
{
return new Credential(id, true, rpId, privateKey, userHandle, signCount);
@@ -75,50 +76,32 @@ public static Credential CreateResidentCredential(byte[] id, string rpId, string
///
/// Gets the byte array of the ID of the credential.
///
- public byte[] Id
- {
- get { return (byte[])id.Clone(); }
- }
+ public byte[] Id => (byte[])id.Clone();
///
/// Gets a value indicating whether this Credential is a resident credential.
///
- public bool IsResidentCredential
- {
- get { return this.isResidentCredential; }
- }
+ public bool IsResidentCredential { get; }
///
/// Gets the ID of the relying party of this credential.
///
- public string RpId
- {
- get { return this.rpId; }
- }
+ public string RpId { get; }
///
/// Gets the private key of the credential.
///
- public string PrivateKey
- {
- get { return this.privateKey; }
- }
+ public string PrivateKey { get; }
///
/// Gets the user handle of the credential.
///
- public byte[] UserHandle
- {
- get { return userHandle == null ? null : (byte[])userHandle.Clone(); }
- }
+ public byte[]? UserHandle => (byte[]?)userHandle?.Clone();
///
/// Gets the signature counter associated to the public key credential source.
///
- public int SignCount
- {
- get { return this.signCount; }
- }
+ public int SignCount { get; }
///
/// Creates a Credential instance from a dictionary of values.
@@ -127,13 +110,14 @@ public int SignCount
/// The created instance of the Credential.
public static Credential FromDictionary(Dictionary dictionary)
{
- return new Credential(
- Base64UrlEncoder.DecodeBytes((string)dictionary["credentialId"]),
- (bool)dictionary["isResidentCredential"],
- dictionary.ContainsKey("rpId") ? (string)dictionary["rpId"] : null,
- (string)dictionary["privateKey"],
- dictionary.ContainsKey("userHandle") ? Base64UrlEncoder.DecodeBytes((string)dictionary["userHandle"]) : null,
- (int)((long)dictionary["signCount"]));
+ byte[] id = Base64UrlEncoder.DecodeBytes((string)dictionary["credentialId"]);
+ bool isResidentCredential = (bool)dictionary["isResidentCredential"];
+ string? rpId = dictionary.TryGetValue("rpId", out object? r) ? (string)r : null;
+ string privateKey = (string)dictionary["privateKey"];
+ byte[]? userHandle = dictionary.TryGetValue("userHandle", out object? u) ? Base64UrlEncoder.DecodeBytes((string)u) : null;
+ int signCount = (int)(long)dictionary["signCount"];
+
+ return new Credential(id, isResidentCredential, rpId, privateKey, userHandle, signCount);
}
///
@@ -145,11 +129,11 @@ public Dictionary ToDictionary()
Dictionary toReturn = new Dictionary();
toReturn["credentialId"] = Base64UrlEncoder.Encode(this.id);
- toReturn["isResidentCredential"] = this.isResidentCredential;
- toReturn["rpId"] = this.rpId;
- toReturn["privateKey"] = this.privateKey;
- toReturn["signCount"] = this.signCount;
- if (this.userHandle != null)
+ toReturn["isResidentCredential"] = this.IsResidentCredential;
+ toReturn["rpId"] = this.RpId;
+ toReturn["privateKey"] = this.PrivateKey;
+ toReturn["signCount"] = this.SignCount;
+ if (this.userHandle is not null)
{
toReturn["userHandle"] = Base64UrlEncoder.Encode(this.userHandle);
}
diff --git a/dotnet/src/webdriver/VirtualAuth/IHasVirtualAuthenticator.cs b/dotnet/src/webdriver/VirtualAuth/IHasVirtualAuthenticator.cs
index 92619ded68acb..2d8616416f90e 100644
--- a/dotnet/src/webdriver/VirtualAuth/IHasVirtualAuthenticator.cs
+++ b/dotnet/src/webdriver/VirtualAuth/IHasVirtualAuthenticator.cs
@@ -17,8 +17,11 @@
// under the License.
//
+using System;
using System.Collections.Generic;
+#nullable enable
+
namespace OpenQA.Selenium.VirtualAuth
{
///
@@ -31,18 +34,23 @@ public interface IHasVirtualAuthenticator
///
/// The VirtualAuthenticatorOptions to use in creating the authenticator.
/// The ID of the added virtual authenticator.
+ /// If is .
string AddVirtualAuthenticator(VirtualAuthenticatorOptions options);
///
/// Removes a virtual authenticator.
///
/// The ID of the virtual authenticator to remove.
+ /// If is .
+ /// If the specified virtual authenticator does not exist.
void RemoveVirtualAuthenticator(string id);
///
/// Adds a credential to the virtual authenticator.
///
/// The credential to add to the authenticator.
+ /// If is .
+ /// If a Virtual Authenticator has not been added yet.
void AddCredential(Credential credential);
///
@@ -55,23 +63,29 @@ public interface IHasVirtualAuthenticator
/// Removes a credential from the virtual authenticator.
///
/// A byte array representing the ID of the credential to remove.
+ /// If is .
+ /// If a Virtual Authenticator has not been added yet.
void RemoveCredential(byte[] credentialId);
///
/// Removes a credential from the virtual authenticator.
///
/// A string representing the ID of the credential to remove.
+ /// If is .
+ /// If a Virtual Authenticator has not been added yet.
void RemoveCredential(string credentialId);
///
/// Removes all credentials registered to this virtual authenticator.
///
+ /// If a Virtual Authenticator has not been added yet.
void RemoveAllCredentials();
///
/// Sets whether or not a user is verified in this virtual authenticator.
///
/// if the user is verified; otherwise .
+ /// If a Virtual Authenticator has not been added yet.
void SetUserVerified(bool verified);
}
}
diff --git a/dotnet/src/webdriver/VirtualAuth/VirtualAuthenticatorOptions.cs b/dotnet/src/webdriver/VirtualAuth/VirtualAuthenticatorOptions.cs
index 6e118df89e037..502d1368f9d0f 100644
--- a/dotnet/src/webdriver/VirtualAuth/VirtualAuthenticatorOptions.cs
+++ b/dotnet/src/webdriver/VirtualAuth/VirtualAuthenticatorOptions.cs
@@ -20,6 +20,8 @@
using System;
using System.Collections.Generic;
+#nullable enable
+
namespace OpenQA.Selenium.VirtualAuth
{
///
@@ -78,10 +80,13 @@ public static class Transport
private bool isUserVerified = false;
///
- /// Sets the protocol the Virtual Authenticator speaks
+ /// Sets the Client to Authenticator Protocol (CTAP) this Virtual Authenticator speaks.
///
- /// Valid protocol value
- /// VirtualAuthenticatorOptions
+ /// The CTAP protocol identifier.
+ /// This options instance for chaining.
+ /// Valid protocols are available on the type.
+ /// If is not a supported protocol value.
+ ///
public VirtualAuthenticatorOptions SetProtocol(string protocol)
{
if (string.Equals(Protocol.CTAP2, protocol) || string.Equals(Protocol.U2F, protocol))
@@ -92,15 +97,19 @@ public VirtualAuthenticatorOptions SetProtocol(string protocol)
else
{
throw new ArgumentException("Enter a valid protocol value." +
- "Refer to https://www.w3.org/TR/webauthn-2/#sctn-automation-virtual-authenticators for supported protocols.");
+ "Refer to https://www.w3.org/TR/webauthn-2/#sctn-automation-virtual-authenticators for supported protocols.");
}
}
///
- /// Sets the transport authenticator needs to implement to communicate with clients
+ /// Sets the Authenticator Transport this Virtual Authenticator needs to implement, to communicate with clients.
///
- /// Valid transport value
- /// VirtualAuthenticatorOptions
+ /// Valid transport value.
+ ///
+ /// This options instance for chaining.
+ /// Valid protocols are available on the type.
+ /// If is not a supported transport value.
+ ///
public VirtualAuthenticatorOptions SetTransport(string transport)
{
if (Transport.BLE == transport || Transport.INTERNAL == transport || Transport.NFC == transport || Transport.USB == transport)
@@ -111,16 +120,15 @@ public VirtualAuthenticatorOptions SetTransport(string transport)
else
{
throw new ArgumentException("Enter a valid transport value." +
- "Refer to https://www.w3.org/TR/webauthn-2/#enum-transport for supported transport values.");
+ "Refer to https://www.w3.org/TR/webauthn-2/#enum-transport for supported transport values.");
}
}
///
- /// If set to true the authenticator will support client-side discoverable credentials.
- /// Refer https://w3c.github.io/webauthn/#client-side-discoverable-credential
+ /// If set to , the authenticator will support Client-side discoverable Credentials .
///
- /// boolean value to set
- /// VirtualAuthenticatorOptions
+ /// Whether authenticator will support client-side discoverable credentials.
+ /// This options instance for chaining.
public VirtualAuthenticatorOptions SetHasResidentKey(bool hasResidentKey)
{
this.hasResidentKey = hasResidentKey;
@@ -128,11 +136,10 @@ public VirtualAuthenticatorOptions SetHasResidentKey(bool hasResidentKey)
}
///
- /// If set to true, the authenticator supports user verification.
- /// Refer https://w3c.github.io/webauthn/#user-verification.
+ /// If set to , the authenticator will support User Verification .
///
- /// boolean value to set
- ///
+ /// Whether the authenticator supports user verification.
+ /// This options instance for chaining.
public VirtualAuthenticatorOptions SetHasUserVerification(bool hasUserVerification)
{
this.hasUserVerification = hasUserVerification;
@@ -140,11 +147,10 @@ public VirtualAuthenticatorOptions SetHasUserVerification(bool hasUserVerificati
}
///
- /// If set to true, a user consent will always be granted.
- /// Refer https://w3c.github.io/webauthn/#user-consent
+ /// If set to , a User Consent will always be granted.
///
- /// boolean value to set
- /// VirtualAuthenticatorOptions
+ /// Whether a user consent will always be granted.
+ /// This options instance for chaining.
public VirtualAuthenticatorOptions SetIsUserConsenting(bool isUserConsenting)
{
this.isUserConsenting = isUserConsenting;
@@ -152,11 +158,10 @@ public VirtualAuthenticatorOptions SetIsUserConsenting(bool isUserConsenting)
}
///
- /// If set to true, User Verification will always succeed.
- /// Refer https://w3c.github.io/webauthn/#user-verification
+ /// If set to , User Verification will always succeed.
///
- /// boolean value to set
- /// VirtualAuthenticatorOptions
+ /// Whether User Verification will always succeed.
+ /// This options instance for chaining.
public VirtualAuthenticatorOptions SetIsUserVerified(bool isUserVerified)
{
this.isUserVerified = isUserVerified;
@@ -164,7 +169,7 @@ public VirtualAuthenticatorOptions SetIsUserVerified(bool isUserVerified)
}
///
- /// Serializes this set of options to a dictionary of key-value pairs.
+ /// Serializes this set of options into a dictionary of key-value pairs.
///
/// The dictionary containing the values of this set of options.
public Dictionary ToDictionary()
diff --git a/dotnet/src/webdriver/WebDriver.cs b/dotnet/src/webdriver/WebDriver.cs
index d9960ea97b235..57d1a2bab91fc 100644
--- a/dotnet/src/webdriver/WebDriver.cs
+++ b/dotnet/src/webdriver/WebDriver.cs
@@ -24,6 +24,7 @@
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
+using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.Threading.Tasks;
@@ -44,7 +45,7 @@ public class WebDriver : IWebDriver, ISearchContext, IJavaScriptExecutor, IFinds
private IFileDetector fileDetector = new DefaultFileDetector();
private NetworkManager network;
private WebElementFactory elementFactory;
- private SessionId sessionId;
+
private List registeredCommands = new List();
///
@@ -191,10 +192,7 @@ public bool IsActionExecutor
///
/// Gets the for the current session of this driver.
///
- public SessionId SessionId
- {
- get { return this.sessionId; }
- }
+ public SessionId SessionId { get; private set; }
///
/// Gets or sets the responsible for detecting
@@ -612,7 +610,7 @@ protected virtual Response Execute(string driverCommandToExecute,
/// A containing information about the success or failure of the command and any data returned by the command.
protected virtual async Task ExecuteAsync(string driverCommandToExecute, Dictionary parameters)
{
- Command commandToExecute = new Command(this.sessionId, driverCommandToExecute, parameters);
+ Command commandToExecute = new Command(SessionId, driverCommandToExecute, parameters);
Response commandResponse;
@@ -624,7 +622,7 @@ protected virtual async Task ExecuteAsync(string driverCommandToExecut
{
commandResponse = new Response
{
- Status = WebDriverResult.UnhandledError,
+ Status = WebDriverResult.UnknownError,
Value = e
};
}
@@ -641,6 +639,7 @@ protected virtual async Task ExecuteAsync(string driverCommandToExecut
/// Starts a session with the driver
///
/// Capabilities of the browser
+ [MemberNotNull(nameof(SessionId))]
protected void StartSession(ICapabilities capabilities)
{
Dictionary parameters = new Dictionary();
@@ -679,7 +678,9 @@ protected void StartSession(ICapabilities capabilities)
ReturnedCapabilities returnedCapabilities = new ReturnedCapabilities(rawCapabilities);
this.capabilities = returnedCapabilities;
- this.sessionId = new SessionId(response.SessionId);
+
+ string sessionId = response.SessionId ?? throw new WebDriverException($"The remote end did not respond with ID of a session when it was required. {response.Value}");
+ this.SessionId = new SessionId(sessionId);
}
///
@@ -723,7 +724,7 @@ protected virtual void Dispose(bool disposing)
{
try
{
- if (this.sessionId is not null)
+ if (this.SessionId is not null)
{
this.Execute(DriverCommand.Quit, null);
}
@@ -739,7 +740,7 @@ protected virtual void Dispose(bool disposing)
}
finally
{
- this.sessionId = null;
+ this.SessionId = null;
}
this.executor.Dispose();
}
@@ -781,9 +782,6 @@ private static void UnpackAndThrowOnError(Response errorResponse, string command
case WebDriverResult.ElementNotSelectable:
throw new InvalidElementStateException(errorMessage);
- case WebDriverResult.UnhandledError:
- throw new WebDriverException(errorMessage);
-
case WebDriverResult.NoSuchDocument:
throw new NoSuchElementException(errorMessage);
@@ -853,6 +851,15 @@ private static void UnpackAndThrowOnError(Response errorResponse, string command
case WebDriverResult.InsecureCertificate:
throw new InsecureCertificateException(errorMessage);
+ case WebDriverResult.UnknownError:
+ throw new UnknownErrorException(errorMessage);
+
+ case WebDriverResult.UnknownMethod:
+ throw new UnknownMethodException(errorMessage);
+
+ case WebDriverResult.UnsupportedOperation:
+ throw new UnsupportedOperationException(errorMessage);
+
default:
throw new InvalidOperationException(string.Format(CultureInfo.InvariantCulture, "{0} ({1})", errorMessage, errorResponse.Status));
}
@@ -1036,44 +1043,68 @@ private object ParseJavaScriptReturnValue(object responseValue)
return returnValue;
}
+#nullable enable
+
///
/// Creates a Virtual Authenticator.
///
- /// VirtualAuthenticator Options (https://w3c.github.io/webauthn/#sctn-automation-virtual-authenticators)
+ /// Virtual Authenticator Options .
/// Authenticator id as string
+ /// If is .
public string AddVirtualAuthenticator(VirtualAuthenticatorOptions options)
{
+ if (options is null)
+ {
+ throw new ArgumentNullException(nameof(options));
+ }
+
Response commandResponse = this.Execute(DriverCommand.AddVirtualAuthenticator, options.ToDictionary());
- string id = commandResponse.Value.ToString();
+ string id = (string)commandResponse.Value!;
this.AuthenticatorId = id;
- return this.AuthenticatorId;
+ return id;
}
///
/// Removes the Virtual Authenticator
///
- /// Id as string that uniquely identifies a Virtual Authenticator
+ /// Id as string that uniquely identifies a Virtual Authenticator.
+ /// If is .
public void RemoveVirtualAuthenticator(string authenticatorId)
{
+ if (authenticatorId is null)
+ {
+ throw new ArgumentNullException(nameof(authenticatorId));
+ }
+
Dictionary parameters = new Dictionary();
- parameters.Add("authenticatorId", this.AuthenticatorId);
+ parameters.Add("authenticatorId", authenticatorId);
+
this.Execute(DriverCommand.RemoveVirtualAuthenticator, parameters);
this.AuthenticatorId = null;
}
///
- /// Gets the virtual authenticator ID for this WebDriver instance.
+ /// Gets the cached virtual authenticator ID, or if no authenticator ID is set.
///
- public string AuthenticatorId { get; private set; }
+ public string? AuthenticatorId { get; private set; }
///
/// Add a credential to the Virtual Authenticator/
///
/// The credential to be stored in the Virtual Authenticator
+ /// If is .
+ /// If a Virtual Authenticator has not been added yet.
public void AddCredential(Credential credential)
{
+ if (credential is null)
+ {
+ throw new ArgumentNullException(nameof(credential));
+ }
+
+ string authenticatorId = this.AuthenticatorId ?? throw new InvalidOperationException("Virtual Authenticator needs to be added before it can perform operations");
+
Dictionary parameters = new Dictionary(credential.ToDictionary());
- parameters.Add("authenticatorId", this.AuthenticatorId);
+ parameters.Add("authenticatorId", authenticatorId);
this.Execute(driverCommandToExecute: DriverCommand.AddCredential, parameters);
}
@@ -1082,18 +1113,25 @@ public void AddCredential(Credential credential)
/// Retrieves all the credentials stored in the Virtual Authenticator
///
/// List of credentials
+ /// If a Virtual Authenticator has not been added yet.
public List GetCredentials()
{
+ string authenticatorId = this.AuthenticatorId ?? throw new InvalidOperationException("Virtual Authenticator needs to be added before it can perform operations");
+
Dictionary parameters = new Dictionary();
- parameters.Add("authenticatorId", this.AuthenticatorId);
+ parameters.Add("authenticatorId", authenticatorId);
- object[] commandResponse = (object[])this.Execute(driverCommandToExecute: DriverCommand.GetCredentials, parameters).Value;
+ Response getCredentialsResponse = this.Execute(driverCommandToExecute: DriverCommand.GetCredentials, parameters);
- List credentials = new List();
+ if (getCredentialsResponse.Value is not object?[] credentialsList)
+ {
+ throw new WebDriverException($"Get credentials call succeeded, but the response was not a list of credentials: {getCredentialsResponse.Value}");
+ }
- foreach (object dictionary in commandResponse)
+ List credentials = new List(credentialsList.Length);
+ foreach (object? dictionary in credentialsList)
{
- Credential credential = Credential.FromDictionary((Dictionary)dictionary);
+ Credential credential = Credential.FromDictionary((Dictionary)dictionary!);
credentials.Add(credential);
}
@@ -1104,6 +1142,8 @@ public List GetCredentials()
/// Removes the credential identified by the credentialId from the Virtual Authenticator.
///
/// The id as byte array that uniquely identifies a credential
+ /// If is .
+ /// If a Virtual Authenticator has not been added yet.
public void RemoveCredential(byte[] credentialId)
{
RemoveCredential(Base64UrlEncoder.Encode(credentialId));
@@ -1113,10 +1153,19 @@ public void RemoveCredential(byte[] credentialId)
/// Removes the credential identified by the credentialId from the Virtual Authenticator.
///
/// The id as string that uniquely identifies a credential
+ /// If is .
+ /// If a Virtual Authenticator has not been added yet.
public void RemoveCredential(string credentialId)
{
+ if (credentialId is null)
+ {
+ throw new ArgumentNullException(nameof(credentialId));
+ }
+
+ string authenticatorId = this.AuthenticatorId ?? throw new InvalidOperationException("Virtual Authenticator needs to be added before it can perform operations");
+
Dictionary parameters = new Dictionary();
- parameters.Add("authenticatorId", this.AuthenticatorId);
+ parameters.Add("authenticatorId", authenticatorId);
parameters.Add("credentialId", credentialId);
this.Execute(driverCommandToExecute: DriverCommand.RemoveCredential, parameters);
@@ -1125,10 +1174,13 @@ public void RemoveCredential(string credentialId)
///
/// Removes all the credentials stored in the Virtual Authenticator.
///
+ /// If a Virtual Authenticator has not been added yet.
public void RemoveAllCredentials()
{
+ string authenticatorId = this.AuthenticatorId ?? throw new InvalidOperationException("Virtual Authenticator needs to be added before it can perform operations");
+
Dictionary parameters = new Dictionary();
- parameters.Add("authenticatorId", this.AuthenticatorId);
+ parameters.Add("authenticatorId", authenticatorId);
this.Execute(driverCommandToExecute: DriverCommand.RemoveAllCredentials, parameters);
}
@@ -1139,8 +1191,10 @@ public void RemoveAllCredentials()
/// The boolean value representing value to be set
public void SetUserVerified(bool verified)
{
+ string authenticatorId = this.AuthenticatorId ?? throw new InvalidOperationException("Virtual Authenticator needs to be added before it can perform operations");
+
Dictionary parameters = new Dictionary();
- parameters.Add("authenticatorId", this.AuthenticatorId);
+ parameters.Add("authenticatorId", authenticatorId);
parameters.Add("isUserVerified", verified);
this.Execute(driverCommandToExecute: DriverCommand.SetUserVerified, parameters);
diff --git a/dotnet/src/webdriver/WebDriverError.cs b/dotnet/src/webdriver/WebDriverError.cs
index e87f8aeae5253..5811d924f53cb 100644
--- a/dotnet/src/webdriver/WebDriverError.cs
+++ b/dotnet/src/webdriver/WebDriverError.cs
@@ -27,32 +27,16 @@ namespace OpenQA.Selenium
///
internal static class WebDriverError
{
- ///
- /// Represents the detached shadow root error.
- ///
- public const string DetachedShadowRoot = "detached shadow root";
-
///
/// Represents the element click intercepted error.
///
public const string ElementClickIntercepted = "element click intercepted";
- ///
- /// Represents the element not selectable error.
- ///
- public const string ElementNotSelectable = "element not selectable";
-
///
/// Represents the element not interactable error.
///
public const string ElementNotInteractable = "element not interactable";
- ///
- /// Represents the element not visible error.
- ///
- /// TODO: Remove this string; it is no longer valid in the specification.
- public const string ElementNotVisible = "element not visible";
-
///
/// Represents the insecure certificate error.
///
@@ -68,17 +52,6 @@ internal static class WebDriverError
///
public const string InvalidCookieDomain = "invalid cookie domain";
- ///
- /// Represents the invalid coordinates error.
- ///
- public const string InvalidCoordinates = "invalid coordinates";
-
- ///
- /// Represents the invalid element coordinates error.
- ///
- /// TODO: Remove this string; it is no longer valid in the specification.
- public const string InvalidElementCoordinates = "invalid element coordinates";
-
///
/// Represents the invalid element state error.
///
@@ -149,6 +122,11 @@ internal static class WebDriverError
///
public const string StaleElementReference = "stale element reference";
+ ///
+ /// Represents the detached shadow root error.
+ ///
+ public const string DetachedShadowRoot = "detached shadow root";
+
///
/// Represents the timeout error.
///
@@ -194,16 +172,11 @@ internal static class WebDriverError
static WebDriverError()
{
resultMap = new Dictionary();
- resultMap[DetachedShadowRoot] = WebDriverResult.DetachedShadowRoot;
resultMap[ElementClickIntercepted] = WebDriverResult.ElementClickIntercepted;
- resultMap[ElementNotSelectable] = WebDriverResult.ElementNotSelectable;
- resultMap[ElementNotVisible] = WebDriverResult.ElementNotDisplayed;
resultMap[ElementNotInteractable] = WebDriverResult.ElementNotInteractable;
resultMap[InsecureCertificate] = WebDriverResult.InsecureCertificate;
resultMap[InvalidArgument] = WebDriverResult.InvalidArgument;
resultMap[InvalidCookieDomain] = WebDriverResult.InvalidCookieDomain;
- resultMap[InvalidCoordinates] = WebDriverResult.InvalidElementCoordinates;
- resultMap[InvalidElementCoordinates] = WebDriverResult.InvalidElementCoordinates;
resultMap[InvalidElementState] = WebDriverResult.InvalidElementState;
resultMap[InvalidSelector] = WebDriverResult.InvalidSelector;
resultMap[InvalidSessionId] = WebDriverResult.NoSuchDriver;
@@ -218,14 +191,15 @@ static WebDriverError()
resultMap[ScriptTimeout] = WebDriverResult.AsyncScriptTimeout;
resultMap[SessionNotCreated] = WebDriverResult.SessionNotCreated;
resultMap[StaleElementReference] = WebDriverResult.ObsoleteElement;
+ resultMap[DetachedShadowRoot] = WebDriverResult.DetachedShadowRoot;
resultMap[Timeout] = WebDriverResult.Timeout;
resultMap[UnableToSetCookie] = WebDriverResult.UnableToSetCookie;
resultMap[UnableToCaptureScreen] = WebDriverResult.UnableToCaptureScreen;
resultMap[UnexpectedAlertOpen] = WebDriverResult.UnexpectedAlertOpen;
resultMap[UnknownCommand] = WebDriverResult.UnknownCommand;
- resultMap[UnknownError] = WebDriverResult.UnhandledError;
- resultMap[UnknownMethod] = WebDriverResult.UnknownCommand;
- resultMap[UnsupportedOperation] = WebDriverResult.UnhandledError;
+ resultMap[UnknownError] = WebDriverResult.UnknownError;
+ resultMap[UnknownMethod] = WebDriverResult.UnknownMethod;
+ resultMap[UnsupportedOperation] = WebDriverResult.UnsupportedOperation;
}
///
diff --git a/dotnet/src/webdriver/WebDriverResult.cs b/dotnet/src/webdriver/WebDriverResult.cs
index 962c21d4bac76..a18dcce7c6a42 100644
--- a/dotnet/src/webdriver/WebDriverResult.cs
+++ b/dotnet/src/webdriver/WebDriverResult.cs
@@ -17,6 +17,8 @@
// under the License.
//
+using System;
+
namespace OpenQA.Selenium
{
///
@@ -32,115 +34,134 @@ public enum WebDriverResult
///
/// The index specified for the action was out of the acceptable range.
///
+ [Obsolete("This error status is no longer returned by the WebDriver Specification https://www.w3.org/TR/webdriver2/#errors. Will be removed in 4.30")]
IndexOutOfBounds = 1,
///
/// No collection was specified.
///
+ [Obsolete("This error status is no longer returned by the WebDriver Specification https://www.w3.org/TR/webdriver2/#errors. Will be removed in 4.30")]
NoCollection = 2,
///
/// No string was specified.
///
+ [Obsolete("This error status is no longer returned by the WebDriver Specification https://www.w3.org/TR/webdriver2/#errors. Will be removed in 4.30")]
NoString = 3,
///
/// No string length was specified.
///
+ [Obsolete("This error status is no longer returned by the WebDriver Specification https://www.w3.org/TR/webdriver2/#errors. Will be removed in 4.30")]
NoStringLength = 4,
///
/// No string wrapper was specified.
///
+ [Obsolete("This error status is no longer returned by the WebDriver Specification https://www.w3.org/TR/webdriver2/#errors. Will be removed in 4.30")]
NoStringWrapper = 5,
///
- /// No driver matching the criteria exists.
+ /// Occurs if the given session id is not in the list of active sessions , meaning the session either does not exist or that it's not active.
///
NoSuchDriver = 6,
///
- /// No element matching the criteria exists.
+ /// An element could not be located on the page using the given search parameters.
///
NoSuchElement = 7,
///
- /// No frame matching the criteria exists.
+ /// A command to switch to a frame could not be satisfied because the frame could not be found.
///
NoSuchFrame = 8,
///
- /// The functionality is not supported.
+ /// A command could not be executed because the remote end is not aware of it.
///
UnknownCommand = 9,
///
- /// The specified element is no longer valid.
+ /// A command failed because the referenced element is no longer attached to the DOM.
///
ObsoleteElement = 10,
///
/// The specified element is not displayed.
///
+ [Obsolete("This error status is no longer returned by the WebDriver Specification https://www.w3.org/TR/webdriver2/#errors. Will be removed in 4.30")]
ElementNotDisplayed = 11,
///
- /// The specified element is not enabled.
+ /// A command could not be completed because the element is in an invalid state, e.g. attempting to clear an element that isn't both editable and resettable .
///
InvalidElementState = 12,
+ ///
+ /// An unknown error occurred in the remote end while processing the command.
+ ///
+ UnknownError = 13,
+
///
/// An unhandled error occurred.
///
- UnhandledError = 13,
+ [Obsolete("This value is no longer set for unknown errors: use UnknownError instead. Will be removed in 4.30")]
+ UnhandledError = UnknownError,
///
/// An error occurred, but it was expected.
///
+ [Obsolete("This error status is no longer returned by the WebDriver Specification https://www.w3.org/TR/webdriver2/#errors. Will be removed in 4.30")]
ExpectedError = 14,
///
/// The specified element is not selected.
///
+ [Obsolete("This error status is no longer returned by the WebDriver Specification https://www.w3.org/TR/webdriver2/#errors. Will be removed in 4.30")]
ElementNotSelectable = 15,
///
/// No document matching the criteria exists.
///
+ [Obsolete("This error status is no longer returned by the WebDriver Specification https://www.w3.org/TR/webdriver2/#errors. Will be removed in 4.30")]
NoSuchDocument = 16,
///
- /// An unexpected JavaScript error occurred.
+ /// An error occurred while executing JavaScript supplied by the user.
///
UnexpectedJavaScriptError = 17,
///
/// No result is available from the JavaScript execution.
///
+ [Obsolete("This error status is no longer returned by the WebDriver Specification https://www.w3.org/TR/webdriver2/#errors. Will be removed in 4.30")]
NoScriptResult = 18,
///
/// The result from the JavaScript execution is not recognized.
///
+ [Obsolete("This error status is no longer returned by the WebDriver Specification https://www.w3.org/TR/webdriver2/#errors. Will be removed in 4.30")]
XPathLookupError = 19,
///
/// No collection matching the criteria exists.
///
+ [Obsolete("This error status is no longer returned by the WebDriver Specification https://www.w3.org/TR/webdriver2/#errors. Will be removed in 4.30")]
NoSuchCollection = 20,
///
- /// A timeout occurred.
+ /// An operation did not complete before its timeout expired.
///
Timeout = 21,
///
/// A null pointer was received.
///
+ [Obsolete("This error status is no longer returned by the WebDriver Specification https://www.w3.org/TR/webdriver2/#errors. Will be removed in 4.30")]
NullPointer = 22,
///
- /// No window matching the criteria exists.
+ /// A command to switch to a window could not be satisfied because the window could not be found.
///
NoSuchWindow = 23,
@@ -150,77 +171,79 @@ public enum WebDriverResult
InvalidCookieDomain = 24,
///
- /// A request to set a cookie's value could not be satisfied.
+ /// A command to set a cookie's value could not be satisfied.
///
UnableToSetCookie = 25,
///
- /// An alert was found open unexpectedly.
+ /// A modal dialog was open, blocking this operation.
///
UnexpectedAlertOpen = 26,
///
- /// A request was made to switch to an alert, but no alert is currently open.
+ /// An attempt was made to operate on a modal dialog when one was not open.
///
NoAlertPresent = 27,
///
- /// An asynchronous JavaScript execution timed out.
+ /// A script did not complete before its timeout expired.
///
AsyncScriptTimeout = 28,
///
/// The coordinates of the element are invalid.
///
+ [Obsolete("This error status is no longer returned by the WebDriver Specification https://www.w3.org/TR/webdriver2/#errors. Will be removed in 4.30")]
InvalidElementCoordinates = 29,
///
- /// The selector used (CSS/XPath) was invalid.
+ /// Argument was an invalid selector.
///
InvalidSelector = 32,
///
- /// A session was not created by the driver
+ /// A new session could not be created.
///
SessionNotCreated = 33,
///
- /// The requested move was outside the active view port
+ /// The target for mouse interaction is not in the browser's viewport and cannot be brought into that viewport.
///
MoveTargetOutOfBounds = 34,
///
/// The XPath selector was invalid.
///
+ [Obsolete("This error status is no longer returned by the WebDriver Specification https://www.w3.org/TR/webdriver2/#errors. Will be removed in 4.30")]
InvalidXPathSelector = 51,
///
- /// An insecure SSl certificate was specified.
+ /// Navigation caused the user agent to hit a certificate warning, which is usually the result of an expired or invalid TLS certificate.
///
InsecureCertificate = 59,
///
- /// The element was not interactable
+ /// A command could not be completed because the element is not pointer - or keyboard interactable.
///
ElementNotInteractable = 60,
///
- /// An invalid argument was passed to the command.
+ /// The arguments passed to a command are either invalid or malformed.
///
InvalidArgument = 61,
///
- /// No cookie was found matching the name requested.
+ /// No cookie matching the given path name was found amongst the associated cookies of session's current browsing context's active document.
///
NoSuchCookie = 62,
///
- /// The driver was unable to capture the screen.
+ /// A screen capture was made impossible.
///
UnableToCaptureScreen = 63,
///
- /// The click on the element was intercepted by a different element.
+ /// The Element Click command could not be completed because the element receiving the events is obscuring the element that was requested clicked.
///
ElementClickIntercepted = 64,
@@ -233,5 +256,15 @@ public enum WebDriverResult
/// The referenced shadow root is no longer attached to the DOM.
///
DetachedShadowRoot = 66,
+
+ ///
+ /// The requested command matched a known URL but did not match any method for that URL.
+ ///
+ UnknownMethod = 67,
+
+ ///
+ /// Indicates that a command that should have executed properly cannot be supported for some reason.
+ ///
+ UnsupportedOperation = 68,
}
}
diff --git a/dotnet/src/webdriver/WebElement.cs b/dotnet/src/webdriver/WebElement.cs
index b3e4356ca55b1..51cce73e1eb67 100644
--- a/dotnet/src/webdriver/WebElement.cs
+++ b/dotnet/src/webdriver/WebElement.cs
@@ -411,7 +411,6 @@ public virtual ReadOnlyCollection FindElements(string mechanism, st
/// via JavaScript.
///
/// Thrown when the target element is no longer valid in the document DOM.
- [Obsolete("Use GetDomAttribute(string attributeName) or GetDomProperty(string propertyName). GetAttribute(string attributeName) will be removed in Selenium 6.")]
public virtual string GetAttribute(string attributeName)
{
Response commandResponse = null;
diff --git a/dotnet/test/common/AlertsTest.cs b/dotnet/test/common/AlertsTest.cs
index 84a05f4a6a78c..8d093a783acf9 100644
--- a/dotnet/test/common/AlertsTest.cs
+++ b/dotnet/test/common/AlertsTest.cs
@@ -48,7 +48,7 @@ public void ShouldAllowUsersToAcceptAnAlertManually()
alert.Accept();
// If we can perform any action, we're good to go
- Assert.AreEqual("Testing Alerts", driver.Title);
+ Assert.That(driver.Title, Is.EqualTo("Testing Alerts"));
}
[Test]
@@ -81,7 +81,7 @@ public void ShouldAllowUsersToAcceptAnAlertWithNoTextManually()
alert.Accept();
// If we can perform any action, we're good to go
- Assert.AreEqual("Testing Alerts", driver.Title);
+ Assert.That(driver.Title, Is.EqualTo("Testing Alerts"));
}
[Test]
@@ -95,7 +95,7 @@ public void ShouldAllowUsersToDismissAnAlertManually()
alert.Dismiss();
// If we can perform any action, we're good to go
- Assert.AreEqual("Testing Alerts", driver.Title);
+ Assert.That(driver.Title, Is.EqualTo("Testing Alerts"));
}
[Test]
@@ -109,7 +109,7 @@ public void ShouldAllowAUserToAcceptAPrompt()
alert.Accept();
// If we can perform any action, we're good to go
- Assert.AreEqual("Testing Prompt", driver.Title);
+ Assert.That(driver.Title, Is.EqualTo("Testing Prompt"));
}
[Test]
@@ -123,7 +123,7 @@ public void ShouldAllowAUserToDismissAPrompt()
alert.Dismiss();
// If we can perform any action, we're good to go
- Assert.AreEqual("Testing Prompt", driver.Title);
+ Assert.That(driver.Title, Is.EqualTo("Testing Prompt"));
}
[Test]
@@ -138,7 +138,7 @@ public void ShouldAllowAUserToSetTheValueOfAPrompt()
alert.Accept();
string result = driver.FindElement(By.Id("text")).Text;
- Assert.AreEqual("cheese", result);
+ Assert.That(result, Is.EqualTo("cheese"));
}
[Test]
@@ -173,7 +173,7 @@ public void ShouldAllowTheUserToGetTheTextOfAnAlert()
string value = alert.Text;
alert.Accept();
- Assert.AreEqual("cheese", value);
+ Assert.That(value, Is.EqualTo("cheese"));
}
[Test]
@@ -187,7 +187,7 @@ public void ShouldAllowTheUserToGetTheTextOfAPrompt()
string value = alert.Text;
alert.Accept();
- Assert.AreEqual("Enter something", value);
+ Assert.That(value, Is.EqualTo("Enter something"));
}
[Test]
@@ -222,7 +222,7 @@ public void ShouldAllowUsersToAcceptAnAlertInAFrame()
alert.Accept();
// If we can perform any action, we're good to go
- Assert.AreEqual("Testing Alerts", driver.Title);
+ Assert.That(driver.Title, Is.EqualTo("Testing Alerts"));
}
[Test]
@@ -244,7 +244,7 @@ public void ShouldAllowUsersToAcceptAnAlertInANestedFrame()
alert.Accept();
// If we can perform any action, we're good to go
- Assert.AreEqual("Testing Alerts", driver.Title);
+ Assert.That(driver.Title, Is.EqualTo("Testing Alerts"));
}
[Test]
@@ -298,7 +298,7 @@ public void PromptShouldUseDefaultValueIfNoKeysSent()
IWebElement element = driver.FindElement(By.Id("text"));
WaitFor(ElementTextToEqual(element, "This is a default value"), "Element text was not 'This is a default value'");
- Assert.AreEqual("This is a default value", element.Text);
+ Assert.That(element.Text, Is.EqualTo("This is a default value"));
}
[Test]
@@ -311,7 +311,7 @@ public void PromptShouldHaveNullValueIfDismissed()
alert.Dismiss();
IWebElement element = driver.FindElement(By.Id("text"));
WaitFor(ElementTextToEqual(element, "null"), "Element text was not 'null'");
- Assert.AreEqual("null", element.Text);
+ Assert.That(element.Text, Is.EqualTo("null"));
}
[Test]
@@ -349,10 +349,10 @@ function displayTwoPrompts() {
IWebElement element1 = driver.FindElement(By.Id("text1"));
WaitFor(ElementTextToEqual(element1, "brie"), "Element text was not 'brie'");
- Assert.AreEqual("brie", element1.Text);
+ Assert.That(element1.Text, Is.EqualTo("brie"));
IWebElement element2 = driver.FindElement(By.Id("text2"));
WaitFor(ElementTextToEqual(element2, "cheddar"), "Element text was not 'cheddar'");
- Assert.AreEqual("cheddar", element2.Text);
+ Assert.That(element2.Text, Is.EqualTo("cheddar"));
}
[Test]
@@ -370,7 +370,7 @@ public void ShouldHandleAlertOnPageLoad()
string value = alert.Text;
alert.Accept();
- Assert.AreEqual("onload", value);
+ Assert.That(value, Is.EqualTo("onload"));
IWebElement element = driver.FindElement(By.TagName("p"));
WaitFor(ElementTextToEqual(element, "Page with onload event handler"), "Element text was not 'Page with onload event handler'");
}
@@ -387,7 +387,7 @@ public void ShouldHandleAlertOnPageLoadUsingGet()
string value = alert.Text;
alert.Accept();
- Assert.AreEqual("onload", value);
+ Assert.That(value, Is.EqualTo("onload"));
WaitFor(ElementTextToEqual(driver.FindElement(By.TagName("p")), "Page with onload event handler"), "Could not find element with text 'Page with onload event handler'");
}
@@ -412,7 +412,7 @@ public void ShouldNotHandleAlertInAnotherWindow()
driver.FindElement(By.Id("open-new-window")).Click();
List allWindows = new List(driver.WindowHandles);
allWindows.Remove(mainWindow);
- Assert.AreEqual(1, allWindows.Count);
+ Assert.That(allWindows, Has.One.Items);
onloadWindow = allWindows[0];
Assert.That(() =>
@@ -472,8 +472,8 @@ public void ShouldHandleAlertOnFormSubmit()
string text = alert.Text;
alert.Accept();
- Assert.AreEqual("Tasty cheese", text);
- Assert.AreEqual("Testing Alerts", driver.Title);
+ Assert.That(text, Is.EqualTo("Tasty cheese"));
+ Assert.That(driver.Title, Is.EqualTo("Testing Alerts"));
}
private IAlert AlertToBePresent()
diff --git a/dotnet/test/common/BiDi/Browser/BrowserTest.cs b/dotnet/test/common/BiDi/Browser/BrowserTest.cs
index ede287cefd953..096970d178543 100644
--- a/dotnet/test/common/BiDi/Browser/BrowserTest.cs
+++ b/dotnet/test/common/BiDi/Browser/BrowserTest.cs
@@ -41,7 +41,7 @@ public async Task CanGetUserContexts()
var userContexts = await bidi.Browser.GetUserContextsAsync();
Assert.That(userContexts, Is.Not.Null);
- Assert.That(userContexts.Count, Is.GreaterThanOrEqualTo(2));
+ Assert.That(userContexts, Has.Count.GreaterThanOrEqualTo(2));
Assert.That(userContexts, Does.Contain(userContext1));
Assert.That(userContexts, Does.Contain(userContext2));
}
diff --git a/dotnet/test/common/BiDi/BrowsingContext/BrowsingContextTest.cs b/dotnet/test/common/BiDi/BrowsingContext/BrowsingContextTest.cs
index 45e67e37892fa..59f451fe421e4 100644
--- a/dotnet/test/common/BiDi/BrowsingContext/BrowsingContextTest.cs
+++ b/dotnet/test/common/BiDi/BrowsingContext/BrowsingContextTest.cs
@@ -289,8 +289,7 @@ public async Task CanCaptureScreenshotOfElement()
var screenshot = await context.CaptureScreenshotAsync(new()
{
- // TODO: Seems Node implements ISharedReference
- Clip = new ClipRectangle.Element(new Modules.Script.SharedReference(nodes[0].SharedId))
+ Clip = new ClipRectangle.Element(nodes[0])
});
Assert.That(screenshot, Is.Not.Null);
diff --git a/dotnet/test/common/BiDi/Network/NetworkEventsTest.cs b/dotnet/test/common/BiDi/Network/NetworkEventsTest.cs
index 14baaf25d8f9a..74e736e70b0c4 100644
--- a/dotnet/test/common/BiDi/Network/NetworkEventsTest.cs
+++ b/dotnet/test/common/BiDi/Network/NetworkEventsTest.cs
@@ -99,7 +99,7 @@ public async Task CanListenToBeforeRequestSentEventWithCookie()
var req = await tcs.Task.WaitAsync(TimeSpan.FromSeconds(5));
- Assert.That(req.Request.Cookies.Count, Is.EqualTo(1));
+ Assert.That(req.Request.Cookies, Has.Count.EqualTo(1));
Assert.That(req.Request.Cookies[0].Name, Is.EqualTo("foo"));
Assert.That((req.Request.Cookies[0].Value as BytesValue.String).Value, Is.EqualTo("bar"));
}
diff --git a/dotnet/test/common/BiDi/Script/ScriptCommandsTest.cs b/dotnet/test/common/BiDi/Script/ScriptCommandsTest.cs
index da692fd898111..798ea1cbbf9f2 100644
--- a/dotnet/test/common/BiDi/Script/ScriptCommandsTest.cs
+++ b/dotnet/test/common/BiDi/Script/ScriptCommandsTest.cs
@@ -34,7 +34,7 @@ public async Task CanGetAllRealms()
var realms = await bidi.Script.GetRealmsAsync();
Assert.That(realms, Is.Not.Null);
- Assert.That(realms.Count, Is.EqualTo(2));
+ Assert.That(realms, Has.Count.EqualTo(2));
Assert.That(realms[0], Is.AssignableFrom());
Assert.That(realms[0].Realm, Is.Not.Null);
@@ -51,7 +51,7 @@ public async Task CanGetAllRealmsByType()
var realms = await bidi.Script.GetRealmsAsync(new() { Type = RealmType.Window });
Assert.That(realms, Is.Not.Null);
- Assert.That(realms.Count, Is.EqualTo(2));
+ Assert.That(realms, Has.Count.EqualTo(2));
Assert.That(realms[0], Is.AssignableFrom());
Assert.That(realms[0].Realm, Is.Not.Null);
diff --git a/dotnet/test/common/BiDi/Storage/StorageTest.cs b/dotnet/test/common/BiDi/Storage/StorageTest.cs
index 19db76a0d4a7b..642f17756ef57 100644
--- a/dotnet/test/common/BiDi/Storage/StorageTest.cs
+++ b/dotnet/test/common/BiDi/Storage/StorageTest.cs
@@ -94,7 +94,7 @@ await context.Storage.SetCookieAsync(new("fish", "cod", UrlBuilder.HostName)
var cookies = await context.Storage.GetCookiesAsync();
Assert.That(cookies, Is.Not.Null);
- Assert.That(cookies.Count, Is.EqualTo(1));
+ Assert.That(cookies, Has.Count.EqualTo(1));
var cookie = cookies[0];
@@ -119,7 +119,7 @@ public async Task CanGetAllCookies()
var cookies = await bidi.Storage.GetCookiesAsync();
Assert.That(cookies, Is.Not.Null);
- Assert.That(cookies.Count, Is.EqualTo(2));
+ Assert.That(cookies, Has.Count.EqualTo(2));
Assert.That(cookies[0].Name, Is.EqualTo("key1"));
Assert.That(cookies[1].Name, Is.EqualTo("key2"));
}
@@ -157,7 +157,7 @@ public async Task CanDeleteCookieWithName()
var cookies = await bidi.Storage.GetCookiesAsync();
Assert.That(cookies, Is.Not.Null);
- Assert.That(cookies.Count, Is.EqualTo(1));
+ Assert.That(cookies, Has.Count.EqualTo(1));
Assert.That(cookies[0].Name, Is.EqualTo("key2"));
}
diff --git a/dotnet/test/common/ChildrenFindingTest.cs b/dotnet/test/common/ChildrenFindingTest.cs
index 1bbe8ccfe1e6e..6588c7c88a43a 100644
--- a/dotnet/test/common/ChildrenFindingTest.cs
+++ b/dotnet/test/common/ChildrenFindingTest.cs
@@ -31,7 +31,7 @@ public void FindElementByXPath()
driver.Url = nestedPage;
IWebElement element = driver.FindElement(By.Name("form2"));
IWebElement child = element.FindElement(By.XPath("select"));
- Assert.AreEqual("2", child.GetAttribute("id"));
+ Assert.That(child.GetAttribute("id"), Is.EqualTo("2"));
}
[Test]
@@ -41,7 +41,7 @@ public void FindingElementsOnElementByXPathShouldFindTopLevelElements()
IWebElement parent = driver.FindElement(By.Id("multiline"));
ReadOnlyCollection allParaElements = driver.FindElements(By.XPath("//p"));
ReadOnlyCollection children = parent.FindElements(By.XPath("//p"));
- Assert.AreEqual(allParaElements.Count, children.Count);
+ Assert.That(children, Has.Exactly(allParaElements.Count).Items);
}
[Test]
@@ -49,9 +49,10 @@ public void FindingDotSlashElementsOnElementByXPathShouldFindNotTopLevelElements
{
driver.Url = simpleTestPage;
IWebElement parent = driver.FindElement(By.Id("multiline"));
+
ReadOnlyCollection children = parent.FindElements(By.XPath("./p"));
- Assert.AreEqual(1, children.Count);
- Assert.AreEqual("A div containing", children[0].Text);
+ Assert.That(children, Has.One.Items);
+ Assert.That(children[0].Text, Is.EqualTo("A div containing"));
}
[Test]
@@ -59,7 +60,10 @@ public void FindElementByXPathWhenNoMatch()
{
driver.Url = nestedPage;
IWebElement element = driver.FindElement(By.Name("form2"));
- Assert.That(() => element.FindElement(By.XPath("select/x")), Throws.InstanceOf());
+
+ Assert.That(
+ () => element.FindElement(By.XPath("select/x")),
+ Throws.InstanceOf());
}
[Test]
@@ -67,10 +71,11 @@ public void FindElementsByXPath()
{
driver.Url = nestedPage;
IWebElement element = driver.FindElement(By.Name("form2"));
+
ReadOnlyCollection children = element.FindElements(By.XPath("select/option"));
- Assert.AreEqual(8, children.Count);
- Assert.AreEqual("One", children[0].Text);
- Assert.AreEqual("Two", children[1].Text);
+ Assert.That(children, Has.Exactly(8).Items);
+ Assert.That(children[0].Text, Is.EqualTo("One"));
+ Assert.That(children[1].Text, Is.EqualTo("Two"));
}
[Test]
@@ -79,7 +84,7 @@ public void FindElementsByXPathWhenNoMatch()
driver.Url = nestedPage;
IWebElement element = driver.FindElement(By.Name("form2"));
ReadOnlyCollection children = element.FindElements(By.XPath("select/x"));
- Assert.AreEqual(0, children.Count);
+ Assert.That(children, Is.Empty);
}
[Test]
@@ -88,7 +93,7 @@ public void FindElementByName()
driver.Url = nestedPage;
IWebElement element = driver.FindElement(By.Name("form2"));
IWebElement child = element.FindElement(By.Name("selectomatic"));
- Assert.AreEqual("2", child.GetAttribute("id"));
+ Assert.That(child.GetAttribute("id"), Is.EqualTo("2"));
}
[Test]
@@ -96,8 +101,9 @@ public void FindElementsByName()
{
driver.Url = nestedPage;
IWebElement element = driver.FindElement(By.Name("form2"));
+
ReadOnlyCollection children = element.FindElements(By.Name("selectomatic"));
- Assert.AreEqual(children.Count, 2);
+ Assert.That(children, Has.Exactly(2).Items);
}
[Test]
@@ -105,8 +111,9 @@ public void FindElementById()
{
driver.Url = nestedPage;
IWebElement element = driver.FindElement(By.Name("form2"));
+
IWebElement child = element.FindElement(By.Id("2"));
- Assert.AreEqual(child.GetAttribute("name"), "selectomatic");
+ Assert.That(child.GetAttribute("name"), Is.EqualTo("selectomatic"));
}
@@ -115,8 +122,9 @@ public void FindElementByIdWhenMultipleMatchesExist()
{
driver.Url = nestedPage;
IWebElement element = driver.FindElement(By.Id("test_id_div"));
+
IWebElement child = element.FindElement(By.Id("test_id"));
- Assert.AreEqual(child.Text, "inside");
+ Assert.That(child.Text, Is.EqualTo("inside"));
}
[Test]
@@ -124,8 +132,9 @@ public void FindElementByIdWhenIdContainsNonAlphanumericCharacters()
{
driver.Url = nestedPage;
IWebElement element = driver.FindElement(By.Id("test_special_chars"));
+
IWebElement childWithSpaces = element.FindElement(By.Id("white space"));
- Assert.That(childWithSpaces.Text.Contains("space"));
+ Assert.That(childWithSpaces.Text, Does.Contain("space"));
IWebElement childWithCssChars = element.FindElement(By.Id("css#.chars"));
Assert.That(childWithCssChars.Text, Is.EqualTo("css escapes"));
}
@@ -135,7 +144,10 @@ public void FindElementByIdWhenNoMatchInContext()
{
driver.Url = nestedPage;
IWebElement element = driver.FindElement(By.Id("test_id_div"));
- Assert.That(() => element.FindElement(By.Id("test_id_out")), Throws.InstanceOf());
+
+ Assert.That(
+ () => element.FindElement(By.Id("test_id_out")),
+ Throws.InstanceOf());
}
[Test]
@@ -144,7 +156,7 @@ public void FindElementsById()
driver.Url = nestedPage;
IWebElement element = driver.FindElement(By.Name("form2"));
ReadOnlyCollection children = element.FindElements(By.Id("2"));
- Assert.AreEqual(children.Count, 2);
+ Assert.That(children, Has.Exactly(2).Items);
}
[Test]
@@ -153,9 +165,9 @@ public void FindElementsByIdWithNonAlphanumericCharacters()
driver.Url = nestedPage;
IWebElement element = driver.FindElement(By.Id("test_special_chars"));
ReadOnlyCollection children = element.FindElements(By.Id("white space"));
- Assert.That(children.Count, Is.EqualTo(1));
+ Assert.That(children, Has.One.Items);
ReadOnlyCollection children2 = element.FindElements(By.Id("css#.chars"));
- Assert.That(children2.Count, Is.EqualTo(1));
+ Assert.That(children2, Has.One.Items);
}
[Test]
@@ -163,8 +175,9 @@ public void FindElementByLinkText()
{
driver.Url = nestedPage;
IWebElement element = driver.FindElement(By.Name("div1"));
+
IWebElement child = element.FindElement(By.LinkText("hello world"));
- Assert.AreEqual(child.GetAttribute("name"), "link1");
+ Assert.That(child.GetAttribute("name"), Is.EqualTo("link1"));
}
@@ -175,9 +188,9 @@ public void FindElementsByLinkText()
IWebElement element = driver.FindElement(By.Name("div1"));
ReadOnlyCollection elements = element.FindElements(By.LinkText("hello world"));
- Assert.AreEqual(2, elements.Count);
- Assert.AreEqual(elements[0].GetAttribute("name"), "link1");
- Assert.AreEqual(elements[1].GetAttribute("name"), "link2");
+ Assert.That(elements, Has.Exactly(2).Items);
+ Assert.That(elements[0].GetAttribute("name"), Is.EqualTo("link1"));
+ Assert.That(elements[1].GetAttribute("name"), Is.EqualTo("link2"));
}
[Test]
@@ -185,8 +198,9 @@ public void ShouldFindChildElementsById()
{
driver.Url = nestedPage;
IWebElement parent = driver.FindElement(By.Id("test_id_div"));
+
IWebElement element = parent.FindElement(By.Id("test_id"));
- Assert.AreEqual("inside", element.Text);
+ Assert.That(element.Text, Is.EqualTo("inside"));
}
[Test]
@@ -195,8 +209,10 @@ public void ShouldNotReturnRootElementWhenFindingChildrenById()
driver.Url = nestedPage;
IWebElement parent = driver.FindElement(By.Id("test_id"));
- Assert.AreEqual(0, parent.FindElements(By.Id("test_id")).Count);
- Assert.That(() => parent.FindElement(By.Id("test_id")), Throws.InstanceOf());
+ Assert.That(parent.FindElements(By.Id("test_id")), Is.Empty);
+ Assert.That(
+ () => parent.FindElement(By.Id("test_id")),
+ Throws.InstanceOf());
}
[Test]
@@ -207,7 +223,7 @@ public void ShouldFindChildElementsByClassName()
IWebElement element = parent.FindElement(By.ClassName("one"));
- Assert.AreEqual("Find me", element.Text);
+ Assert.That(element.Text, Is.EqualTo("Find me"));
}
[Test]
@@ -218,7 +234,7 @@ public void ShouldFindChildrenByClassName()
ReadOnlyCollection elements = parent.FindElements(By.ClassName("one"));
- Assert.AreEqual(2, elements.Count);
+ Assert.That(elements, Has.Exactly(2).Items);
}
@@ -230,7 +246,7 @@ public void ShouldFindChildElementsByTagName()
IWebElement element = parent.FindElement(By.TagName("a"));
- Assert.AreEqual("link1", element.GetAttribute("name"));
+ Assert.That(element.GetAttribute("name"), Is.EqualTo("link1"));
}
@@ -242,7 +258,7 @@ public void ShouldFindChildrenByTagName()
ReadOnlyCollection elements = parent.FindElements(By.TagName("a"));
- Assert.AreEqual(2, elements.Count);
+ Assert.That(elements, Has.Exactly(2).Items);
}
[Test]
@@ -253,7 +269,7 @@ public void ShouldBeAbleToFindAnElementByCssSelector()
IWebElement element = parent.FindElement(By.CssSelector("*[name=\"selectomatic\"]"));
- Assert.AreEqual("2", element.GetAttribute("id"));
+ Assert.That(element.GetAttribute("id"), Is.EqualTo("2"));
}
[Test]
@@ -264,7 +280,7 @@ public void ShouldBeAbleToFindAnElementByCss3Selector()
IWebElement element = parent.FindElement(By.CssSelector("*[name^=\"selecto\"]"));
- Assert.AreEqual("2", element.GetAttribute("id"));
+ Assert.That(element.GetAttribute("id"), Is.EqualTo("2"));
}
[Test]
@@ -275,7 +291,7 @@ public void ShouldBeAbleToFindElementsByCssSelector()
ReadOnlyCollection elements = parent.FindElements(By.CssSelector("*[name=\"selectomatic\"]"));
- Assert.AreEqual(2, elements.Count);
+ Assert.That(elements, Has.Exactly(2).Items);
}
[Test]
@@ -284,8 +300,9 @@ public void ShouldBeAbleToFindChildrenOfANode()
driver.Url = selectableItemsPage;
ReadOnlyCollection elements = driver.FindElements(By.XPath("/html/head"));
IWebElement head = elements[0];
+
ReadOnlyCollection importedScripts = head.FindElements(By.TagName("script"));
- Assert.That(importedScripts.Count, Is.EqualTo(3));
+ Assert.That(importedScripts, Has.Exactly(3).Items);
}
[Test]
@@ -293,9 +310,9 @@ public void ReturnAnEmptyListWhenThereAreNoChildrenOfANode()
{
driver.Url = xhtmlTestPage;
IWebElement table = driver.FindElement(By.Id("table"));
- ReadOnlyCollection rows = table.FindElements(By.TagName("tr"));
- Assert.That(rows.Count, Is.EqualTo(0));
+ ReadOnlyCollection rows = table.FindElements(By.TagName("tr"));
+ Assert.That(rows, Is.Empty);
}
[Test]
@@ -311,7 +328,9 @@ public void ShouldNotFindElementOutSideTree()
{
driver.Url = formsPage;
IWebElement element = driver.FindElement(By.Name("login"));
- Assert.That(() => element.FindElement(By.Name("x")), Throws.InstanceOf());
+ Assert.That(
+ () => element.FindElement(By.Name("x")),
+ Throws.InstanceOf());
}
[Test]
@@ -320,8 +339,8 @@ public void FindingByTagNameShouldNotIncludeParentElementIfSameTagType()
driver.Url = xhtmlTestPage;
IWebElement parent = driver.FindElement(By.Id("my_span"));
- Assert.AreEqual(2, parent.FindElements(By.TagName("div")).Count);
- Assert.AreEqual(2, parent.FindElements(By.TagName("span")).Count);
+ Assert.That(parent.FindElements(By.TagName("div")), Has.Exactly(2).Items);
+ Assert.That(parent.FindElements(By.TagName("span")), Has.Exactly(2).Items);
}
[Test]
@@ -331,7 +350,7 @@ public void FindingByCssShouldNotIncludeParentElementIfSameTagType()
IWebElement parent = driver.FindElement(By.CssSelector("div#parent"));
IWebElement child = parent.FindElement(By.CssSelector("div"));
- Assert.AreEqual("child", child.GetAttribute("id"));
+ Assert.That(child.GetAttribute("id"), Is.EqualTo("child"));
}
[Test]
@@ -342,7 +361,7 @@ public void FindMultipleElements()
ReadOnlyCollection elements = elem.FindElements(By.PartialLinkText("link"));
Assert.That(elements, Is.Not.Null);
- Assert.AreEqual(6, elements.Count);
+ Assert.That(elements, Has.Exactly(6).Items);
}
[Test]
@@ -353,7 +372,7 @@ public void LinkWithLeadingSpaces()
IWebElement elem = driver.FindElement(By.Id("links"));
IWebElement res = elem.FindElement(By.PartialLinkText("link with leading space"));
- Assert.AreEqual("link with leading space", res.Text);
+ Assert.That(res.Text, Is.EqualTo("link with leading space"));
}
[Test]
@@ -364,7 +383,7 @@ public void LinkWithTrailingSpace()
IWebElement elem = driver.FindElement(By.Id("links"));
IWebElement res = elem.FindElement(By.PartialLinkText("link with trailing space"));
- Assert.AreEqual("link with trailing space", res.Text);
+ Assert.That(res.Text, Is.EqualTo("link with trailing space"));
}
[Test]
@@ -374,7 +393,7 @@ public void ElementCanGetLinkByLinkTestIgnoringTrailingWhitespace()
IWebElement elem = driver.FindElement(By.Id("links"));
IWebElement link = elem.FindElement(By.LinkText("link with trailing space"));
- Assert.AreEqual("linkWithTrailingSpace", link.GetAttribute("id"));
+ Assert.That(link.GetAttribute("id"), Is.EqualTo("linkWithTrailingSpace"));
}
}
}
diff --git a/dotnet/test/common/ClearTest.cs b/dotnet/test/common/ClearTest.cs
index 9d31803834b63..d65a7f7e7a00a 100644
--- a/dotnet/test/common/ClearTest.cs
+++ b/dotnet/test/common/ClearTest.cs
@@ -31,7 +31,7 @@ public void WritableTextInputShouldClear()
driver.Url = readOnlyPage;
IWebElement element = driver.FindElement(By.Id("writableTextInput"));
element.Clear();
- Assert.AreEqual(string.Empty, element.GetAttribute("value"));
+ Assert.That(element.GetAttribute("value"), Is.Empty);
}
[Test]
@@ -42,7 +42,9 @@ public void TextInputShouldNotClearWhenDisabled()
driver.Url = readOnlyPage;
IWebElement element = driver.FindElement(By.Id("textInputNotEnabled"));
Assert.That(element.Enabled, Is.False);
- Assert.That(() => element.Clear(), Throws.InstanceOf());
+ Assert.That(
+ () => element.Clear(),
+ Throws.InstanceOf());
}
[Test]
@@ -50,7 +52,9 @@ public void TextInputShouldNotClearWhenReadOnly()
{
driver.Url = readOnlyPage;
IWebElement element = driver.FindElement(By.Id("readOnlyTextInput"));
- Assert.That(() => element.Clear(), Throws.InstanceOf());
+ Assert.That(
+ () => element.Clear(),
+ Throws.InstanceOf());
}
[Test]
@@ -59,7 +63,7 @@ public void WritableTextAreaShouldClear()
driver.Url = readOnlyPage;
IWebElement element = driver.FindElement(By.Id("writableTextArea"));
element.Clear();
- Assert.AreEqual(string.Empty, element.GetAttribute("value"));
+ Assert.That(element.GetAttribute("value"), Is.Empty);
}
[Test]
@@ -77,7 +81,9 @@ public void TextAreaShouldNotClearWhenReadOnly()
{
driver.Url = readOnlyPage;
IWebElement element = driver.FindElement(By.Id("textAreaReadOnly"));
- Assert.That(() => element.Clear(), Throws.InstanceOf());
+ Assert.That(
+ () => element.Clear(),
+ Throws.InstanceOf());
}
[Test]
@@ -86,7 +92,8 @@ public void ContentEditableAreaShouldClear()
driver.Url = readOnlyPage;
IWebElement element = driver.FindElement(By.Id("content-editable"));
element.Clear();
- Assert.AreEqual(string.Empty, element.Text);
+
+ Assert.That(element.Text, Is.Empty);
}
[Test]
@@ -195,9 +202,10 @@ private void ShouldBeAbleToClearInput(By locator, string oldValue, string cleare
{
driver.Url = EnvironmentManager.Instance.UrlBuilder.WhereIs("inputs.html");
IWebElement element = driver.FindElement(locator);
- Assert.AreEqual(oldValue, element.GetAttribute("value"));
+ Assert.That(element.GetAttribute("value"), Is.EqualTo(oldValue));
+
element.Clear();
- Assert.AreEqual(clearedValue, element.GetAttribute("value"));
+ Assert.That(element.GetAttribute("value"), Is.EqualTo(clearedValue));
}
}
}
diff --git a/dotnet/test/common/ClickScrollingTest.cs b/dotnet/test/common/ClickScrollingTest.cs
index 92489f1c6d943..d5a73aed7c33c 100644
--- a/dotnet/test/common/ClickScrollingTest.cs
+++ b/dotnet/test/common/ClickScrollingTest.cs
@@ -44,7 +44,7 @@ public void ClickingOnAnchorScrollsPage()
// Sometimes JS is returning a double
object result = ((IJavaScriptExecutor)driver).ExecuteScript(scrollScript);
- var yOffset = Convert.ChangeType(result, typeof(long));
+ var yOffset = Convert.ToInt64(result);
//Focusing on to click, but not actually following,
//the link will scroll it in to view, which is a few pixels further than 0
@@ -69,7 +69,8 @@ public void ShouldBeAbleToClickOnAnElementHiddenByOverflow()
IWebElement link = driver.FindElement(By.Id("line8"));
// This used to throw a MoveTargetOutOfBoundsException - we don't expect it to
link.Click();
- Assert.AreEqual("line8", driver.FindElement(By.Id("clicked")).Text);
+
+ Assert.That(driver.FindElement(By.Id("clicked")).Text, Is.EqualTo("line8"));
}
[Test]
@@ -109,7 +110,7 @@ public void ShouldNotScrollOverflowElementsWhichAreVisible()
IWebElement item = list.FindElement(By.Id("desired"));
item.Click();
long yOffset = (long)((IJavaScriptExecutor)driver).ExecuteScript("return arguments[0].scrollTop;", list);
- Assert.AreEqual(0, yOffset, "Should not have scrolled");
+ Assert.That(yOffset, Is.Zero, "Should not have scrolled");
}
@@ -122,7 +123,7 @@ public void ShouldNotScrollIfAlreadyScrolledAndElementIsInView()
driver.FindElement(By.Id("button2")).Click();
double scrollTop = GetScrollTop();
driver.FindElement(By.Id("button1")).Click();
- Assert.AreEqual(scrollTop, GetScrollTop());
+ Assert.That(GetScrollTop(), Is.EqualTo(scrollTop));
}
[Test]
@@ -139,7 +140,7 @@ public void ShouldScrollOverflowElementsIfClickPointIsOutOfViewButElementIsInVie
{
driver.Url = EnvironmentManager.Instance.UrlBuilder.WhereIs("scroll5.html");
driver.FindElement(By.Id("inner")).Click();
- Assert.AreEqual("clicked", driver.FindElement(By.Id("clicked")).Text);
+ Assert.That(driver.FindElement(By.Id("clicked")).Text, Is.EqualTo("clicked"));
}
[Test]
@@ -238,7 +239,7 @@ public void ShouldNotScrollWhenGettingElementSize()
driver.Url = EnvironmentManager.Instance.UrlBuilder.WhereIs("scroll3.html");
double scrollTop = GetScrollTop();
Size ignoredSize = driver.FindElement(By.Id("button1")).Size;
- Assert.AreEqual(scrollTop, GetScrollTop());
+ Assert.That(GetScrollTop(), Is.EqualTo(scrollTop));
}
[Test]
@@ -266,7 +267,7 @@ public void ShouldBeAbleToClickInlineTextElementWithChildElementAfterScrolling()
IWebElement label = driver.FindElement(By.Id("wrapper"));
label.Click();
IWebElement checkbox = driver.FindElement(By.Id("check"));
- Assert.IsFalse(checkbox.Selected, "Checkbox should not be selected after click");
+ Assert.That(checkbox.Selected, Is.False, "Checkbox should not be selected after click");
}
private double GetScrollTop()
diff --git a/dotnet/test/common/ClickTest.cs b/dotnet/test/common/ClickTest.cs
index 5a5f9cd06a4fa..20739bbe3d114 100644
--- a/dotnet/test/common/ClickTest.cs
+++ b/dotnet/test/common/ClickTest.cs
@@ -43,7 +43,7 @@ public void CanClickOnALinkAndFollowIt()
{
driver.FindElement(By.Id("normal")).Click();
WaitFor(() => { return driver.Title == "XHTML Test Page"; }, "Browser title was not 'XHTML Test Page'");
- Assert.AreEqual("XHTML Test Page", driver.Title);
+ Assert.That(driver.Title, Is.EqualTo("XHTML Test Page"));
}
[Test]
@@ -63,7 +63,7 @@ public void CanClickOnAnAnchorAndNotReloadThePage()
bool samePage = (bool)((IJavaScriptExecutor)driver).ExecuteScript("return document.latch");
- Assert.AreEqual(true, samePage, "Latch was reset");
+ Assert.That(samePage, Is.True, "Latch was reset");
}
[Test]
@@ -115,7 +115,7 @@ public void CanClickOnAnElementWithTopSetToANegativeNumber()
driver.FindElement(By.Name("btn")).Click();
string log = driver.FindElement(By.Id("log")).Text;
- Assert.AreEqual("click", log);
+ Assert.That(log, Is.EqualTo("click"));
}
[Test]
@@ -136,7 +136,7 @@ public void ShouldSetRelatedTargetForMouseOver()
}
else
{
- Assert.AreEqual("parent matches? true", log);
+ Assert.That(log, Is.EqualTo("parent matches? true"));
}
}
@@ -145,7 +145,7 @@ public void ShouldClickOnFirstBoundingClientRectWithNonZeroSize()
{
driver.FindElement(By.Id("twoClientRects")).Click();
WaitFor(() => { return driver.Title == "XHTML Test Page"; }, "Browser title was not 'XHTML Test Page'");
- Assert.AreEqual("XHTML Test Page", driver.Title);
+ Assert.That(driver.Title, Is.EqualTo("XHTML Test Page"));
}
[Test]
@@ -158,7 +158,7 @@ public void ShouldOnlyFollowHrefOnce()
driver.FindElement(By.Id("new-window")).Click();
WaitFor(() => { return driver.WindowHandles.Count >= windowHandlesBefore + 1; }, "Window handles was not " + (windowHandlesBefore + 1).ToString());
- Assert.AreEqual(windowHandlesBefore + 1, driver.WindowHandles.Count);
+ Assert.That(driver.WindowHandles, Has.Exactly(windowHandlesBefore + 1).Items);
}
[Test]
@@ -176,7 +176,7 @@ public void CanClickOnALinkWithEnclosedImage()
{
driver.FindElement(By.Id("link-with-enclosed-image")).Click();
WaitFor(() => { return driver.Title == "XHTML Test Page"; }, "Browser title was not 'XHTML Test Page'");
- Assert.AreEqual("XHTML Test Page", driver.Title);
+ Assert.That(driver.Title, Is.EqualTo("XHTML Test Page"));
}
[Test]
@@ -184,7 +184,7 @@ public void CanClickOnAnImageEnclosedInALink()
{
driver.FindElement(By.Id("link-with-enclosed-image")).FindElement(By.TagName("img")).Click();
WaitFor(() => { return driver.Title == "XHTML Test Page"; }, "Browser title was not 'XHTML Test Page'");
- Assert.AreEqual("XHTML Test Page", driver.Title);
+ Assert.That(driver.Title, Is.EqualTo("XHTML Test Page"));
}
[Test]
@@ -192,7 +192,7 @@ public void CanClickOnALinkThatContainsTextWrappedInASpan()
{
driver.FindElement(By.Id("link-with-enclosed-span")).Click();
WaitFor(() => { return driver.Title == "XHTML Test Page"; }, "Browser title was not 'XHTML Test Page'");
- Assert.AreEqual("XHTML Test Page", driver.Title);
+ Assert.That(driver.Title, Is.EqualTo("XHTML Test Page"));
}
[Test]
@@ -201,7 +201,7 @@ public void CanClickOnALinkThatContainsEmbeddedBlockElements()
{
driver.FindElement(By.Id("embeddedBlock")).Click();
WaitFor(() => { return driver.Title == "XHTML Test Page"; }, "Browser title was not 'XHTML Test Page'");
- Assert.AreEqual("XHTML Test Page", driver.Title);
+ Assert.That(driver.Title, Is.EqualTo("XHTML Test Page"));
}
[Test]
@@ -209,7 +209,7 @@ public void CanClickOnAnElementEnclosedInALink()
{
driver.FindElement(By.Id("link-with-enclosed-span")).FindElement(By.TagName("span")).Click();
WaitFor(() => { return driver.Title == "XHTML Test Page"; }, "Browser title was not 'XHTML Test Page'");
- Assert.AreEqual("XHTML Test Page", driver.Title);
+ Assert.That(driver.Title, Is.EqualTo("XHTML Test Page"));
}
[Test]
@@ -287,7 +287,7 @@ public void ShouldBeAbleToClickOnRightToLeftLanguageLink()
element.Click();
WaitFor(() => driver.Title == "clicks", "Expected title to be 'clicks'");
- Assert.AreEqual("clicks", driver.Title);
+ Assert.That(driver.Title, Is.EqualTo("clicks"));
}
[Test]
@@ -298,7 +298,7 @@ public void ShouldBeAbleToClickOnLinkInAbsolutelyPositionedFooter()
driver.FindElement(By.Id("link")).Click();
WaitFor(() => { return driver.Title == "XHTML Test Page"; }, "Browser title was not 'XHTML Test Page'");
- Assert.AreEqual("XHTML Test Page", driver.Title);
+ Assert.That(driver.Title, Is.EqualTo("XHTML Test Page"));
}
[Test]
@@ -309,7 +309,7 @@ public void ShouldBeAbleToClickOnLinkInAbsolutelyPositionedFooterInQuirksMode()
driver.FindElement(By.Id("link")).Click();
WaitFor(() => { return driver.Title == "XHTML Test Page"; }, "Browser title was not 'XHTML Test Page'");
- Assert.AreEqual("XHTML Test Page", driver.Title);
+ Assert.That(driver.Title, Is.EqualTo("XHTML Test Page"));
}
[Test]
@@ -321,7 +321,7 @@ public void ShouldBeAbleToClickOnLinksWithNoHrefAttribute()
element.Click();
WaitFor(() => driver.Title == "Changed", "Expected title to be 'Changed'");
- Assert.AreEqual("Changed", driver.Title);
+ Assert.That(driver.Title, Is.EqualTo("Changed"));
}
[Test]
@@ -332,7 +332,7 @@ public void ShouldBeAbleToClickOnALinkThatWrapsToTheNextLine()
driver.FindElement(By.Id("link")).Click();
WaitFor(() => driver.Title == "Submitted Successfully!", "Expected title to be 'Submitted Successfully!'");
- Assert.AreEqual("Submitted Successfully!", driver.Title);
+ Assert.That(driver.Title, Is.EqualTo("Submitted Successfully!"));
}
[Test]
@@ -343,7 +343,7 @@ public void ShouldBeAbleToClickOnASpanThatWrapsToTheNextLine()
driver.FindElement(By.Id("span")).Click();
WaitFor(() => driver.Title == "Submitted Successfully!", "Expected title to be 'Submitted Successfully!'");
- Assert.AreEqual("Submitted Successfully!", driver.Title);
+ Assert.That(driver.Title, Is.EqualTo("Submitted Successfully!"));
}
[Test]
@@ -364,7 +364,7 @@ public void ShouldBeAbleToClickLinkContainingLineBreak()
driver.Url = simpleTestPage;
driver.FindElement(By.Id("multilinelink")).Click();
WaitFor(() => { return driver.Title == "We Arrive Here"; }, "Browser title was not 'We Arrive Here'");
- Assert.AreEqual("We Arrive Here", driver.Title);
+ Assert.That(driver.Title, Is.EqualTo("We Arrive Here"));
}
}
}
diff --git a/dotnet/test/common/ContentEditableTest.cs b/dotnet/test/common/ContentEditableTest.cs
index f927694ba078e..73f1e2c3cc20f 100644
--- a/dotnet/test/common/ContentEditableTest.cs
+++ b/dotnet/test/common/ContentEditableTest.cs
@@ -63,7 +63,7 @@ public void NonPrintableCharactersShouldWorkWithContentEditableOrDesignModeSet()
element.SendKeys("Dishy" + Keys.Backspace + Keys.Left + Keys.Left);
element.SendKeys(Keys.Left + Keys.Left + "F" + Keys.Delete + Keys.End + "ee!");
- Assert.AreEqual("Fishee!", element.Text);
+ Assert.That(element.Text, Is.EqualTo("Fishee!"));
}
[Test]
@@ -137,7 +137,7 @@ public void AppendsTextToEndOfContentEditableWithMultipleTextNodes()
IWebElement input = driver.FindElement(By.Id("editable"));
input.SendKeys(", world!");
WaitFor(() => input.Text != "Why hello", "Text remained the original text");
- Assert.AreEqual("Why hello, world!", input.Text);
+ Assert.That(input.Text, Is.EqualTo("Why hello, world!"));
}
}
}
diff --git a/dotnet/test/common/CookieImplementationTest.cs b/dotnet/test/common/CookieImplementationTest.cs
index 846d1a832bdeb..a329895d79b7d 100644
--- a/dotnet/test/common/CookieImplementationTest.cs
+++ b/dotnet/test/common/CookieImplementationTest.cs
@@ -54,7 +54,7 @@ public void ShouldGetCookieByName()
((IJavaScriptExecutor)driver).ExecuteScript("document.cookie = arguments[0] + '=set';", key);
Cookie cookie = driver.Manage().Cookies.GetCookieNamed(key);
- Assert.AreEqual("set", cookie.Value);
+ Assert.That(cookie.Value, Is.EqualTo("set"));
}
[Test]
@@ -73,7 +73,7 @@ public void ShouldBeAbleToAddCookie()
driver.Manage().Cookies.AddCookie(cookie);
AssertCookieHasValue(key, value);
- Assert.That(driver.Manage().Cookies.AllCookies.Contains(cookie), "Cookie was not added successfully");
+ Assert.That(driver.Manage().Cookies.AllCookies, Does.Contain(cookie), "Cookie was not added successfully");
}
[Test]
@@ -101,7 +101,7 @@ public void GetAllCookies()
driver.Url = simpleTestPage;
cookies = driver.Manage().Cookies.AllCookies;
- Assert.AreEqual(count + 2, cookies.Count);
+ Assert.That(cookies, Has.Count.EqualTo(count + 2));
Assert.That(cookies, Does.Contain(one));
Assert.That(cookies, Does.Contain(two));
@@ -389,7 +389,7 @@ public void ShouldWalkThePathToDeleteACookie()
Assert.That(driver.Manage().Cookies.GetCookieNamed("rodent"), Is.Null);
ReadOnlyCollection cookies = driver.Manage().Cookies.AllCookies;
- Assert.That(cookies, Has.Count.EqualTo(2));
+ Assert.That(cookies, Has.Exactly(2).Items);
Assert.That(cookies, Does.Contain(cookie1));
Assert.That(cookies, Does.Contain(cookie3));
@@ -450,7 +450,7 @@ public void CookieEqualityAfterSetAndGet()
Assert.That(retrievedCookie, Is.Not.Null);
//Cookie.equals only compares name, domain and path
- Assert.AreEqual(cookie1, retrievedCookie);
+ Assert.That(retrievedCookie, Is.EqualTo(cookie1));
}
[Test]
@@ -472,7 +472,7 @@ public void ShouldRetainCookieExpiry()
Cookie retrieved = options.Cookies.GetCookieNamed("fish");
Assert.That(retrieved, Is.Not.Null);
- Assert.AreEqual(addCookie.Expiry, retrieved.Expiry, "Cookies are not equal");
+ Assert.That(retrieved.Expiry, Is.EqualTo(addCookie.Expiry), "Cookies are not equal");
}
[Test]
@@ -713,7 +713,7 @@ public void ShouldAddCookieToCurrentDomainAndPath()
Cookie cookie = new Cookie("Homer", "Simpson", this.hostname, "/" + EnvironmentManager.Instance.UrlBuilder.Path, null);
options.Cookies.AddCookie(cookie);
ReadOnlyCollection cookies = options.Cookies.AllCookies;
- Assert.That(cookies.Contains(cookie), "Valid cookie was not returned");
+ Assert.That(cookies, Does.Contain(cookie), "Valid cookie was not returned");
}
[Test]
@@ -727,7 +727,10 @@ public void ShouldNotShowCookieAddedToDifferentDomain()
driver.Url = macbethPage;
IOptions options = driver.Manage();
Cookie cookie = new Cookie("Bart", "Simpson", EnvironmentManager.Instance.UrlBuilder.HostName + ".com", EnvironmentManager.Instance.UrlBuilder.Path, null);
- Assert.That(() => options.Cookies.AddCookie(cookie), Throws.InstanceOf().Or.InstanceOf());
+ Assert.That(
+ () => options.Cookies.AddCookie(cookie),
+ Throws.InstanceOf().Or.InstanceOf());
+
ReadOnlyCollection cookies = options.Cookies.AllCookies;
Assert.That(cookies, Does.Not.Contain(cookie), "Invalid cookie was returned");
}
@@ -771,7 +774,9 @@ public void ShouldThrowExceptionWhenAddingCookieToCookieAverseDocument()
IOptions options = driver.Manage();
Cookie cookie = new Cookie("question", "dunno");
- Assert.That(() => options.Cookies.AddCookie(cookie), Throws.InstanceOf().Or.InstanceOf());
+ Assert.That(
+ () => options.Cookies.AddCookie(cookie),
+ Throws.InstanceOf().Or.InstanceOf());
}
[Test]
@@ -803,7 +808,7 @@ public void ShouldAddCookieToCurrentDomain()
Cookie cookie = new Cookie("Marge", "Simpson", "/");
options.Cookies.AddCookie(cookie);
ReadOnlyCollection cookies = options.Cookies.AllCookies;
- Assert.That(cookies.Contains(cookie), "Valid cookie was not returned");
+ Assert.That(cookies, Does.Contain(cookie), "Valid cookie was not returned");
}
[Test]
@@ -824,7 +829,7 @@ public void ShouldDeleteCookie()
options.Cookies.DeleteCookie(cookieToDelete);
ReadOnlyCollection cookies2 = options.Cookies.AllCookies;
Assert.That(cookies2, Does.Not.Contain(cookieToDelete), "Cookie was not deleted successfully");
- Assert.That(cookies2.Contains(cookieToKeep), "Valid cookie was not returned");
+ Assert.That(cookies2, Does.Contain(cookieToKeep), "Valid cookie was not returned");
}
//////////////////////////////////////////////
@@ -924,21 +929,21 @@ private string GetDocumentCookieOrNull()
private void AssertNoCookiesArePresent()
{
- Assert.That(driver.Manage().Cookies.AllCookies.Count, Is.EqualTo(0), "Cookies were not empty");
+ Assert.That(driver.Manage().Cookies.AllCookies, Is.Empty, "Cookies were not empty");
string documentCookie = GetDocumentCookieOrNull();
if (documentCookie != null)
{
- Assert.AreEqual(string.Empty, documentCookie, "Cookies were not empty");
+ Assert.That(documentCookie, Is.Empty, "Cookies were not empty");
}
}
private void AssertSomeCookiesArePresent()
{
- Assert.That(driver.Manage().Cookies.AllCookies.Count, Is.Not.EqualTo(0), "Cookies were empty");
+ Assert.That(driver.Manage().Cookies.AllCookies, Is.Not.Empty, "Cookies were empty");
String documentCookie = GetDocumentCookieOrNull();
if (documentCookie != null)
{
- Assert.AreNotEqual(string.Empty, documentCookie, "Cookies were empty");
+ Assert.That(documentCookie, Is.Not.Empty, "Cookies were empty");
}
}
@@ -964,7 +969,7 @@ private void AssertCookieIsPresentWithName(string key)
private void AssertCookieHasValue(string key, string value)
{
- Assert.AreEqual(value, driver.Manage().Cookies.GetCookieNamed(key).Value, "Cookie had wrong value");
+ Assert.That(driver.Manage().Cookies.GetCookieNamed(key).Value, Is.EqualTo(value), "Cookie had wrong value");
string documentCookie = GetDocumentCookieOrNull();
if (documentCookie != null)
{
diff --git a/dotnet/test/common/CorrectEventFiringTest.cs b/dotnet/test/common/CorrectEventFiringTest.cs
index d30e205b485fd..6e1da8e0313bd 100644
--- a/dotnet/test/common/CorrectEventFiringTest.cs
+++ b/dotnet/test/common/CorrectEventFiringTest.cs
@@ -158,7 +158,7 @@ public void ShouldIssueMouseDownEvents()
driver.FindElement(By.Id("mousedown")).Click();
String result = driver.FindElement(By.Id("result")).Text;
- Assert.AreEqual(result, "mouse down");
+ Assert.That(result, Is.EqualTo("mouse down"));
}
[Test]
@@ -168,7 +168,7 @@ public void ShouldIssueClickEvents()
driver.FindElement(By.Id("mouseclick")).Click();
String result = driver.FindElement(By.Id("result")).Text;
- Assert.AreEqual("mouse click", result);
+ Assert.That(result, Is.EqualTo("mouse click"));
}
[Test]
@@ -178,7 +178,7 @@ public void ShouldIssueMouseUpEvents()
driver.FindElement(By.Id("mouseup")).Click();
String result = driver.FindElement(By.Id("result")).Text;
- Assert.AreEqual(result, "mouse up");
+ Assert.That(result, Is.EqualTo("mouse up"));
}
[Test]
@@ -188,7 +188,7 @@ public void MouseEventsShouldBubbleUpToContainingElements()
driver.FindElement(By.Id("child")).Click();
String result = driver.FindElement(By.Id("result")).Text;
- Assert.AreEqual(result, "mouse down");
+ Assert.That(result, Is.EqualTo("mouse down"));
}
[Test]
@@ -205,9 +205,9 @@ public void ShouldEmitOnChangeEventsWhenSelectingElements()
IWebElement bar = allOptions[1];
foo.Click();
- Assert.AreEqual(driver.FindElement(By.Id("result")).Text, initialTextValue);
+ Assert.That(driver.FindElement(By.Id("result")).Text, Is.EqualTo(initialTextValue));
bar.Click();
- Assert.AreEqual(driver.FindElement(By.Id("result")).Text, "bar");
+ Assert.That(driver.FindElement(By.Id("result")).Text, Is.EqualTo("bar"));
}
[Test]
@@ -221,9 +221,9 @@ public void ShouldEmitOnClickEventsWhenSelectingElements()
IWebElement bar = allOptions[1];
foo.Click();
- Assert.AreEqual(driver.FindElement(By.Id("result")).Text, "foo");
+ Assert.That(driver.FindElement(By.Id("result")).Text, Is.EqualTo("foo"));
bar.Click();
- Assert.AreEqual(driver.FindElement(By.Id("result")).Text, "bar");
+ Assert.That(driver.FindElement(By.Id("result")).Text, Is.EqualTo("bar"));
}
[Test]
@@ -234,7 +234,7 @@ public void ShouldEmitOnChangeEventsWhenChangingTheStateOfACheckbox()
IWebElement checkbox = driver.FindElement(By.Id("checkbox"));
checkbox.Click();
- Assert.AreEqual(driver.FindElement(By.Id("result")).Text, "checkbox thing");
+ Assert.That(driver.FindElement(By.Id("result")).Text, Is.EqualTo("checkbox thing"));
}
[Test]
@@ -245,7 +245,7 @@ public void ShouldEmitClickEventWhenClickingOnATextInputElement()
IWebElement clicker = driver.FindElement(By.Id("clickField"));
clicker.Click();
- Assert.AreEqual(clicker.GetAttribute("value"), "Clicked");
+ Assert.That(clicker.GetAttribute("value"), Is.EqualTo("Clicked"));
}
[Test]
@@ -269,7 +269,7 @@ public void ClearingAnElementShouldCauseTheOnChangeHandlerToFire()
element.Clear();
IWebElement result = driver.FindElement(By.Id("result"));
- Assert.AreEqual("Cleared", result.Text.Trim());
+ Assert.That(result.Text.Trim(), Is.EqualTo("Cleared"));
}
[Test]
@@ -416,7 +416,7 @@ public void UploadingFileShouldFireOnChangeEvent()
driver.Url = formsPage;
IWebElement uploadElement = driver.FindElement(By.Id("upload"));
IWebElement result = driver.FindElement(By.Id("fileResults"));
- Assert.AreEqual(string.Empty, result.Text);
+ Assert.That(result.Text, Is.Empty);
string filePath = System.IO.Path.Combine(EnvironmentManager.Instance.CurrentDirectory, "test.txt");
System.IO.FileInfo inputFile = new System.IO.FileInfo(filePath);
@@ -429,7 +429,7 @@ public void UploadingFileShouldFireOnChangeEvent()
driver.FindElement(By.Id("id-name1")).Click();
inputFile.Delete();
- Assert.AreEqual("changed", result.Text);
+ Assert.That(result.Text, Is.EqualTo("changed"));
}
[Test]
@@ -445,8 +445,8 @@ public void ShouldReportTheXAndYCoordinatesWhenClicking()
string clientY = driver.FindElement(By.Id("clientY")).Text;
driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(0);
- Assert.AreNotEqual("0", clientX);
- Assert.AreNotEqual("0", clientY);
+ Assert.That(clientX, Is.Not.EqualTo("0"));
+ Assert.That(clientY, Is.Not.EqualTo("0"));
}
[Test]
@@ -487,7 +487,7 @@ public void ClickAnElementThatDisappear()
driver.Url = EnvironmentManager.Instance.UrlBuilder.WhereIs("click_tests/disappearing_element.html");
driver.FindElement(By.Id("over")).Click();
- Assert.That(driver.FindElement(By.Id("log")).Text.StartsWith(expectedLogBuilder.ToString()));
+ Assert.That(driver.FindElement(By.Id("log")).Text, Does.StartWith(expectedLogBuilder.ToString()));
}
private void AssertEventNotFired(string eventName)
diff --git a/dotnet/test/common/DevTools/DevToolsProfilerTest.cs b/dotnet/test/common/DevTools/DevToolsProfilerTest.cs
index 985a336e2c94e..a663278e7bc69 100644
--- a/dotnet/test/common/DevTools/DevToolsProfilerTest.cs
+++ b/dotnet/test/common/DevTools/DevToolsProfilerTest.cs
@@ -131,12 +131,12 @@ private void ValidateProfile(CurrentCdpVersion.Profiler.Profile profiler)
{
Assert.That(profiler, Is.Not.Null);
Assert.That(profiler.Nodes, Is.Not.Null);
- Assert.That(profiler.StartTime, Is.Not.Null);
- Assert.That(profiler.EndTime, Is.Not.Null);
+ Assert.That(profiler.StartTime, Is.Not.Zero);
+ Assert.That(profiler.EndTime, Is.Not.Zero);
Assert.That(profiler.TimeDeltas, Is.Not.Null);
foreach (var delta in profiler.TimeDeltas)
{
- Assert.That(delta, Is.Not.Null);
+ Assert.That(delta, Is.Not.Zero);
}
foreach (var node in profiler.Nodes)
diff --git a/dotnet/test/common/DevTools/DevToolsTestFixture.cs b/dotnet/test/common/DevTools/DevToolsTestFixture.cs
index 18bb78988557f..44f2317370420 100644
--- a/dotnet/test/common/DevTools/DevToolsTestFixture.cs
+++ b/dotnet/test/common/DevTools/DevToolsTestFixture.cs
@@ -39,7 +39,7 @@ public void Setup()
devTools = driver as IDevTools;
if (devTools == null)
{
- Assert.Ignore("{0} does not support Chrome DevTools Protocol", EnvironmentManager.Instance.Browser);
+ Assert.Ignore($"{EnvironmentManager.Instance.Browser} does not support Chrome DevTools Protocol");
return;
}
diff --git a/dotnet/test/common/DownloadsTest.cs b/dotnet/test/common/DownloadsTest.cs
index b03d44d7d8f8d..0043316b2025f 100644
--- a/dotnet/test/common/DownloadsTest.cs
+++ b/dotnet/test/common/DownloadsTest.cs
@@ -76,7 +76,7 @@ public void CanDownloadFile()
((RemoteWebDriver)driver).DownloadFile(fileName, targetDirectory);
string fileContent = File.ReadAllText(Path.Combine(targetDirectory, fileName));
- Assert.AreEqual("Hello, World!", fileContent.Trim());
+ Assert.That(fileContent.Trim(), Is.EqualTo("Hello, World!"));
Directory.Delete(targetDirectory, recursive: true);
}
@@ -90,7 +90,7 @@ public void CanDeleteFiles()
((RemoteWebDriver)driver).DeleteDownloadableFiles();
IReadOnlyList names = ((RemoteWebDriver)driver).GetDownloadableFiles();
- Assert.IsEmpty(names, "The names list should be empty.");
+ Assert.That(names, Is.Empty, "The names list should be empty.");
}
private void DownloadWithBrowser()
diff --git a/dotnet/test/common/DriverElementFindingTest.cs b/dotnet/test/common/DriverElementFindingTest.cs
index f491f4857335b..6c44b9a4602e9 100644
--- a/dotnet/test/common/DriverElementFindingTest.cs
+++ b/dotnet/test/common/DriverElementFindingTest.cs
@@ -93,7 +93,7 @@ public void ShouldFindElementsById()
{
driver.Url = nestedPage;
ReadOnlyCollection elements = driver.FindElements(By.Id("test_id"));
- Assert.That(elements.Count, Is.EqualTo(2));
+ Assert.That(elements, Has.Count.EqualTo(2));
}
[Test]
@@ -101,7 +101,7 @@ public void ShouldFindElementsByLinkText()
{
driver.Url = nestedPage;
ReadOnlyCollection elements = driver.FindElements(By.LinkText("hello world"));
- Assert.That(elements.Count, Is.EqualTo(12));
+ Assert.That(elements, Has.Count.EqualTo(12));
}
[Test]
@@ -109,7 +109,7 @@ public void ShouldFindElementsByName()
{
driver.Url = nestedPage;
ReadOnlyCollection elements = driver.FindElements(By.Name("form1"));
- Assert.That(elements.Count, Is.EqualTo(4));
+ Assert.That(elements, Has.Count.EqualTo(4));
}
[Test]
@@ -117,7 +117,7 @@ public void ShouldFindElementsByXPath()
{
driver.Url = nestedPage;
ReadOnlyCollection elements = driver.FindElements(By.XPath("//a"));
- Assert.That(elements.Count, Is.EqualTo(12));
+ Assert.That(elements, Has.Count.EqualTo(12));
}
[Test]
@@ -125,7 +125,7 @@ public void ShouldFindElementsByClassName()
{
driver.Url = nestedPage;
ReadOnlyCollection elements = driver.FindElements(By.ClassName("one"));
- Assert.That(elements.Count, Is.EqualTo(3));
+ Assert.That(elements, Has.Count.EqualTo(3));
}
[Test]
@@ -133,7 +133,7 @@ public void ShouldFindElementsByPartialLinkText()
{
driver.Url = nestedPage;
ReadOnlyCollection elements = driver.FindElements(By.PartialLinkText("world"));
- Assert.That(elements.Count, Is.EqualTo(12));
+ Assert.That(elements, Has.Count.EqualTo(12));
}
[Test]
@@ -141,7 +141,7 @@ public void ShouldFindElementsByTagName()
{
driver.Url = nestedPage;
ReadOnlyCollection elements = driver.FindElements(By.TagName("a"));
- Assert.That(elements.Count, Is.EqualTo(12));
+ Assert.That(elements, Has.Count.EqualTo(12));
}
#endregion
}
diff --git a/dotnet/test/common/ElementAttributeTest.cs b/dotnet/test/common/ElementAttributeTest.cs
index 43a1be4a063a9..9eb59cfff2f5a 100644
--- a/dotnet/test/common/ElementAttributeTest.cs
+++ b/dotnet/test/common/ElementAttributeTest.cs
@@ -52,7 +52,7 @@ public void ShouldReturnAnAbsoluteUrlWhenGettingSrcAttributeOfAValidImgTag()
driver.Url = simpleTestPage;
IWebElement img = driver.FindElement(By.Id("validImgTag"));
string attribute = img.GetAttribute("src");
- Assert.AreEqual(EnvironmentManager.Instance.UrlBuilder.WhereIs("icon.gif"), attribute);
+ Assert.That(attribute, Is.EqualTo(EnvironmentManager.Instance.UrlBuilder.WhereIs("icon.gif")));
}
[Test]
@@ -61,7 +61,7 @@ public void ShouldReturnAnAbsoluteUrlWhenGettingHrefAttributeOfAValidAnchorTag()
driver.Url = simpleTestPage;
IWebElement img = driver.FindElement(By.Id("validAnchorTag"));
string attribute = img.GetAttribute("href");
- Assert.AreEqual(EnvironmentManager.Instance.UrlBuilder.WhereIs("icon.gif"), attribute);
+ Assert.That(attribute, Is.EqualTo(EnvironmentManager.Instance.UrlBuilder.WhereIs("icon.gif")));
}
@@ -70,7 +70,7 @@ public void ShouldReturnEmptyAttributeValuesWhenPresentAndTheValueIsActuallyEmpt
{
driver.Url = simpleTestPage;
IWebElement body = driver.FindElement(By.XPath("//body"));
- Assert.AreEqual(string.Empty, body.GetAttribute("style"));
+ Assert.That(body.GetAttribute("style"), Is.Empty);
}
[Test]
@@ -93,7 +93,7 @@ public void ShouldReturnTheValueOfTheIndexAttrbuteEvenIfItIsMissing()
IWebElement multiSelect = driver.FindElement(By.Id("multi"));
ReadOnlyCollection options = multiSelect.FindElements(By.TagName("option"));
- Assert.AreEqual("1", options[1].GetAttribute("index"));
+ Assert.That(options[1].GetAttribute("index"), Is.EqualTo("1"));
}
@@ -133,7 +133,7 @@ public void ShouldThrowExceptionIfSendingKeysToElementDisabledUsingRandomDisable
disabledTextElement1.SendKeys("foo");
}, Throws.TypeOf());
- Assert.AreEqual(string.Empty, disabledTextElement1.Text);
+ Assert.That(disabledTextElement1.Text, Is.Empty);
IWebElement disabledTextElement2 = driver.FindElement(By.Id("disabledTextElement2"));
@@ -141,7 +141,7 @@ public void ShouldThrowExceptionIfSendingKeysToElementDisabledUsingRandomDisable
() => disabledTextElement2.SendKeys("bar"),
Throws.TypeOf());
- Assert.AreEqual(string.Empty, disabledTextElement2.Text);
+ Assert.That(disabledTextElement2.Text, Is.Empty);
}
[Test]
@@ -169,9 +169,9 @@ public void ShouldReturnTheValueOfCheckedForACheckboxOnlyIfItIsChecked()
{
driver.Url = formsPage;
IWebElement checkbox = driver.FindElement(By.XPath("//input[@id='checky']"));
- Assert.AreEqual(null, checkbox.GetAttribute("checked"));
+ Assert.That(checkbox.GetAttribute("checked"), Is.Null);
checkbox.Click();
- Assert.AreEqual("true", checkbox.GetAttribute("checked"));
+ Assert.That(checkbox.GetAttribute("checked"), Is.EqualTo("true"));
}
[Test]
@@ -182,14 +182,14 @@ public void ShouldOnlyReturnTheValueOfSelectedForRadioButtonsIfItIsSet()
IWebElement initiallyNotSelected = driver.FindElement(By.Id("peas"));
IWebElement initiallySelected = driver.FindElement(By.Id("cheese_and_peas"));
- Assert.AreEqual(null, neverSelected.GetAttribute("selected"), "false");
- Assert.AreEqual(null, initiallyNotSelected.GetAttribute("selected"), "false");
- Assert.AreEqual("true", initiallySelected.GetAttribute("selected"), "true");
+ Assert.That(neverSelected.GetAttribute("selected"), Is.Null, "false");
+ Assert.That(initiallyNotSelected.GetAttribute("selected"), Is.Null, "false");
+ Assert.That(initiallySelected.GetAttribute("selected"), Is.EqualTo("true"), "true");
initiallyNotSelected.Click();
- Assert.AreEqual(null, neverSelected.GetAttribute("selected"));
- Assert.AreEqual("true", initiallyNotSelected.GetAttribute("selected"));
- Assert.AreEqual(null, initiallySelected.GetAttribute("selected"));
+ Assert.That(neverSelected.GetAttribute("selected"), Is.Null);
+ Assert.That(initiallyNotSelected.GetAttribute("selected"), Is.EqualTo("true"));
+ Assert.That(initiallySelected.GetAttribute("selected"), Is.Null);
}
[Test]
@@ -202,8 +202,8 @@ public void ShouldReturnTheValueOfSelectedForOptionsOnlyIfTheyAreSelected()
IWebElement two = options[1];
Assert.That(one.Selected, Is.True);
Assert.That(two.Selected, Is.False);
- Assert.AreEqual("true", one.GetAttribute("selected"));
- Assert.AreEqual(null, two.GetAttribute("selected"));
+ Assert.That(one.GetAttribute("selected"), Is.EqualTo("true"));
+ Assert.That(two.GetAttribute("selected"), Is.Null);
}
[Test]
@@ -214,7 +214,7 @@ public void ShouldReturnValueOfClassAttributeOfAnElement()
IWebElement heading = driver.FindElement(By.XPath("//h1"));
String className = heading.GetAttribute("class");
- Assert.AreEqual("header", className);
+ Assert.That(className, Is.EqualTo("header"));
}
[Test]
@@ -224,7 +224,7 @@ public void ShouldReturnTheContentsOfATextAreaAsItsValue()
String value = driver.FindElement(By.Id("withText")).GetAttribute("value");
- Assert.AreEqual("Example text", value);
+ Assert.That(value, Is.EqualTo("Example text"));
}
[Test]
@@ -260,7 +260,7 @@ public void ShouldReturnHiddenTextForTextContentAttribute()
IWebElement element = driver.FindElement(By.Id("hiddenline"));
string textContent = element.GetAttribute("textContent");
- Assert.AreEqual("A hidden line of text", textContent);
+ Assert.That(textContent, Is.EqualTo("A hidden line of text"));
}
[Test]
@@ -268,7 +268,7 @@ public void ShouldGetNumericAtribute()
{
driver.Url = formsPage;
IWebElement element = driver.FindElement(By.Id("withText"));
- Assert.AreEqual("5", element.GetAttribute("rows"));
+ Assert.That(element.GetAttribute("rows"), Is.EqualTo("5"));
}
[Test]
@@ -288,11 +288,11 @@ public void ShouldCorrectlyReportValueOfColspan()
IWebElement th1 = driver.FindElement(By.Id("th1"));
IWebElement td2 = driver.FindElement(By.Id("td2"));
- Assert.AreEqual("th1", th1.GetAttribute("id"), "th1 id");
- Assert.AreEqual("3", th1.GetAttribute("colspan"), "th1 colspan should be 3");
+ Assert.That(th1.GetAttribute("id"), Is.EqualTo("th1"), "th1 id");
+ Assert.That(th1.GetAttribute("colspan"), Is.EqualTo("3"), "th1 colspan should be 3");
- Assert.AreEqual("td2", td2.GetAttribute("id"), "td2 id");
- Assert.AreEqual("2", td2.GetAttribute("colspan"), "td2 colspan should be 2");
+ Assert.That(td2.GetAttribute("id"), Is.EqualTo("td2"), "td2 id");
+ Assert.That(td2.GetAttribute("colspan"), Is.EqualTo("2"), "td2 colspan should be 2");
}
// This is a test-case re-creating issue 900.
@@ -325,7 +325,7 @@ public void GetAttributeDoesNotReturnAnObjectForSvgProperties()
driver.Url = svgPage;
IWebElement svgElement = driver.FindElement(By.Id("rotate"));
- Assert.AreEqual("rotate(30)", svgElement.GetAttribute("transform"));
+ Assert.That(svgElement.GetAttribute("transform"), Is.EqualTo("rotate(30)"));
}
[Test]
@@ -333,9 +333,9 @@ public void CanRetrieveTheCurrentValueOfATextFormField_textInput()
{
driver.Url = formsPage;
IWebElement element = driver.FindElement(By.Id("working"));
- Assert.AreEqual(string.Empty, element.GetAttribute("value"));
+ Assert.That(element.GetAttribute("value"), Is.Empty);
element.SendKeys("hello world");
- Assert.AreEqual("hello world", element.GetAttribute("value"));
+ Assert.That(element.GetAttribute("value"), Is.EqualTo("hello world"));
}
[Test]
@@ -343,9 +343,9 @@ public void CanRetrieveTheCurrentValueOfATextFormField_emailInput()
{
driver.Url = formsPage;
IWebElement element = driver.FindElement(By.Id("email"));
- Assert.AreEqual(string.Empty, element.GetAttribute("value"));
+ Assert.That(element.GetAttribute("value"), Is.Empty);
element.SendKeys("hello world");
- Assert.AreEqual("hello world", element.GetAttribute("value"));
+ Assert.That(element.GetAttribute("value"), Is.EqualTo("hello world"));
}
[Test]
@@ -353,9 +353,9 @@ public void CanRetrieveTheCurrentValueOfATextFormField_textArea()
{
driver.Url = formsPage;
IWebElement element = driver.FindElement(By.Id("emptyTextArea"));
- Assert.AreEqual(string.Empty, element.GetAttribute("value"));
+ Assert.That(element.GetAttribute("value"), Is.Empty);
element.SendKeys("hello world");
- Assert.AreEqual("hello world", element.GetAttribute("value"));
+ Assert.That(element.GetAttribute("value"), Is.EqualTo("hello world"));
}
[Test]
@@ -373,15 +373,15 @@ public void ShouldReturnTrueForPresentBooleanAttributes()
{
driver.Url = booleanAttributes;
IWebElement element1 = driver.FindElement(By.Id("emailRequired"));
- Assert.AreEqual("true", element1.GetAttribute("required"));
+ Assert.That(element1.GetAttribute("required"), Is.EqualTo("true"));
IWebElement element2 = driver.FindElement(By.Id("emptyTextAreaRequired"));
- Assert.AreEqual("true", element2.GetAttribute("required"));
+ Assert.That(element2.GetAttribute("required"), Is.EqualTo("true"));
IWebElement element3 = driver.FindElement(By.Id("inputRequired"));
- Assert.AreEqual("true", element3.GetAttribute("required"));
+ Assert.That(element3.GetAttribute("required"), Is.EqualTo("true"));
IWebElement element4 = driver.FindElement(By.Id("textAreaRequired"));
- Assert.AreEqual("true", element4.GetAttribute("required"));
+ Assert.That(element4.GetAttribute("required"), Is.EqualTo("true"));
IWebElement element5 = driver.FindElement(By.Id("unwrappable"));
- Assert.AreEqual("true", element5.GetAttribute("nowrap"));
+ Assert.That(element5.GetAttribute("nowrap"), Is.EqualTo("true"));
}
[Test]
@@ -389,7 +389,7 @@ public void MultipleAttributeShouldBeNullWhenNotSet()
{
driver.Url = selectPage;
IWebElement element = driver.FindElement(By.Id("selectWithoutMultiple"));
- Assert.AreEqual(null, element.GetAttribute("multiple"));
+ Assert.That(element.GetAttribute("multiple"), Is.Null);
}
[Test]
@@ -397,7 +397,7 @@ public void MultipleAttributeShouldBeTrueWhenSet()
{
driver.Url = selectPage;
IWebElement element = driver.FindElement(By.Id("selectWithMultipleEqualsMultiple"));
- Assert.AreEqual("true", element.GetAttribute("multiple"));
+ Assert.That(element.GetAttribute("multiple"), Is.EqualTo("true"));
}
[Test]
@@ -405,7 +405,7 @@ public void MultipleAttributeShouldBeTrueWhenSelectHasMultipleWithValueAsBlank()
{
driver.Url = selectPage;
IWebElement element = driver.FindElement(By.Id("selectWithEmptyStringMultiple"));
- Assert.AreEqual("true", element.GetAttribute("multiple"));
+ Assert.That(element.GetAttribute("multiple"), Is.EqualTo("true"));
}
[Test]
@@ -413,7 +413,7 @@ public void MultipleAttributeShouldBeTrueWhenSelectHasMultipleWithoutAValue()
{
driver.Url = selectPage;
IWebElement element = driver.FindElement(By.Id("selectWithMultipleWithoutValue"));
- Assert.AreEqual("true", element.GetAttribute("multiple"));
+ Assert.That(element.GetAttribute("multiple"), Is.EqualTo("true"));
}
[Test]
@@ -421,7 +421,7 @@ public void MultipleAttributeShouldBeTrueWhenSelectHasMultipleWithValueAsSomethi
{
driver.Url = selectPage;
IWebElement element = driver.FindElement(By.Id("selectWithRandomMultipleValue"));
- Assert.AreEqual("true", element.GetAttribute("multiple"));
+ Assert.That(element.GetAttribute("multiple"), Is.EqualTo("true"));
}
[Test]
@@ -429,7 +429,7 @@ public void GetAttributeOfUserDefinedProperty()
{
driver.Url = EnvironmentManager.Instance.UrlBuilder.WhereIs("userDefinedProperty.html");
IWebElement element = driver.FindElement(By.Id("d"));
- Assert.AreEqual("sampleValue", element.GetAttribute("dynamicProperty"));
+ Assert.That(element.GetAttribute("dynamicProperty"), Is.EqualTo("sampleValue"));
}
[Test]
@@ -440,7 +440,7 @@ public void ShouldReturnValueOfClassAttributeOfAnElementAfterSwitchingIFrame()
IWebElement wallace = driver.FindElement(By.XPath("//div[@id='wallace']"));
String className = wallace.GetAttribute("class");
- Assert.AreEqual("gromit", className);
+ Assert.That(className, Is.EqualTo("gromit"));
}
}
}
diff --git a/dotnet/test/common/ElementElementFindingTest.cs b/dotnet/test/common/ElementElementFindingTest.cs
index 67cf47bbe8f92..26d75b6279374 100644
--- a/dotnet/test/common/ElementElementFindingTest.cs
+++ b/dotnet/test/common/ElementElementFindingTest.cs
@@ -101,7 +101,7 @@ public void ShouldFindElementsById()
driver.Url = nestedPage;
IWebElement parent = driver.FindElement(By.Name("form2"));
ReadOnlyCollection children = parent.FindElements(By.Id("2"));
- Assert.That(children.Count, Is.EqualTo(2));
+ Assert.That(children, Has.Count.EqualTo(2));
}
[Test]
@@ -110,7 +110,7 @@ public void ShouldFindElementsByLinkText()
driver.Url = nestedPage;
IWebElement parent = driver.FindElement(By.Name("div1"));
ReadOnlyCollection children = parent.FindElements(By.PartialLinkText("hello world"));
- Assert.That(children.Count, Is.EqualTo(2));
+ Assert.That(children, Has.Count.EqualTo(2));
Assert.That(children[0].Text, Is.EqualTo("hello world"));
Assert.That(children[1].Text, Is.EqualTo("hello world"));
}
@@ -121,7 +121,7 @@ public void ShouldFindElementsByName()
driver.Url = nestedPage;
IWebElement parent = driver.FindElement(By.Name("form2"));
ReadOnlyCollection children = parent.FindElements(By.Name("selectomatic"));
- Assert.That(children.Count, Is.EqualTo(2));
+ Assert.That(children, Has.Count.EqualTo(2));
}
[Test]
@@ -130,7 +130,7 @@ public void ShouldFindElementsByXPath()
driver.Url = nestedPage;
IWebElement parent = driver.FindElement(By.Name("classes"));
ReadOnlyCollection children = parent.FindElements(By.XPath("span"));
- Assert.That(children.Count, Is.EqualTo(3));
+ Assert.That(children, Has.Count.EqualTo(3));
Assert.That(children[0].Text, Is.EqualTo("Find me"));
Assert.That(children[1].Text, Is.EqualTo("Also me"));
Assert.That(children[2].Text, Is.EqualTo("But not me"));
@@ -142,7 +142,7 @@ public void ShouldFindElementsByClassName()
driver.Url = nestedPage;
IWebElement parent = driver.FindElement(By.Name("classes"));
ReadOnlyCollection children = parent.FindElements(By.ClassName("one"));
- Assert.That(children.Count, Is.EqualTo(2));
+ Assert.That(children, Has.Count.EqualTo(2));
Assert.That(children[0].Text, Is.EqualTo("Find me"));
Assert.That(children[1].Text, Is.EqualTo("Also me"));
}
@@ -153,7 +153,7 @@ public void ShouldFindElementsByPartialLinkText()
driver.Url = nestedPage;
IWebElement parent = driver.FindElement(By.Name("div1"));
ReadOnlyCollection children = parent.FindElements(By.PartialLinkText("hello "));
- Assert.That(children.Count, Is.EqualTo(2));
+ Assert.That(children, Has.Count.EqualTo(2));
Assert.That(children[0].Text, Is.EqualTo("hello world"));
Assert.That(children[1].Text, Is.EqualTo("hello world"));
}
@@ -164,7 +164,7 @@ public void ShouldFindElementsByTagName()
driver.Url = nestedPage;
IWebElement parent = driver.FindElement(By.Name("classes"));
ReadOnlyCollection children = parent.FindElements(By.TagName("span"));
- Assert.That(children.Count, Is.EqualTo(3));
+ Assert.That(children, Has.Count.EqualTo(3));
Assert.That(children[0].Text, Is.EqualTo("Find me"));
Assert.That(children[1].Text, Is.EqualTo("Also me"));
Assert.That(children[2].Text, Is.EqualTo("But not me"));
diff --git a/dotnet/test/common/ElementEqualityTest.cs b/dotnet/test/common/ElementEqualityTest.cs
index b86111ae4414c..0ecf01983c9b8 100644
--- a/dotnet/test/common/ElementEqualityTest.cs
+++ b/dotnet/test/common/ElementEqualityTest.cs
@@ -34,7 +34,7 @@ public void SameElementLookedUpDifferentWaysShouldBeEqual()
IWebElement body = driver.FindElement(By.TagName("body"));
IWebElement xbody = driver.FindElement(By.XPath("//body"));
- Assert.AreEqual(body, xbody);
+ Assert.That(xbody, Is.EqualTo(body));
}
[Test]
@@ -44,7 +44,7 @@ public void DifferentElementsShouldNotBeEqual()
ReadOnlyCollection ps = driver.FindElements(By.TagName("p"));
- Assert.AreNotEqual(ps[0], ps[1]);
+ Assert.That(ps[1], Is.Not.EqualTo(ps[0]));
}
[Test]
@@ -54,7 +54,7 @@ public void SameElementLookedUpDifferentWaysUsingFindElementShouldHaveSameHashCo
IWebElement body = driver.FindElement(By.TagName("body"));
IWebElement xbody = driver.FindElement(By.XPath("//body"));
- Assert.AreEqual(body.GetHashCode(), xbody.GetHashCode());
+ Assert.That(xbody.GetHashCode(), Is.EqualTo(body.GetHashCode()));
}
public void SameElementLookedUpDifferentWaysUsingFindElementsShouldHaveSameHashCode()
@@ -63,7 +63,7 @@ public void SameElementLookedUpDifferentWaysUsingFindElementsShouldHaveSameHashC
ReadOnlyCollection body = driver.FindElements(By.TagName("body"));
ReadOnlyCollection xbody = driver.FindElements(By.XPath("//body"));
- Assert.AreEqual(body[0].GetHashCode(), xbody[0].GetHashCode());
+ Assert.That(xbody[0].GetHashCode(), Is.EqualTo(body[0].GetHashCode()));
}
[Test]
@@ -76,7 +76,7 @@ public void AnElementFoundInViaJsShouldHaveSameId()
IWebElement element = (IWebElement)((IJavaScriptExecutor)driver).ExecuteScript("return document.getElementById('oneline');");
- Assert.AreEqual(first, element);
+ Assert.That(element, Is.EqualTo(first));
}
}
}
diff --git a/dotnet/test/common/ElementFindingTest.cs b/dotnet/test/common/ElementFindingTest.cs
index 313077382fc4f..f1375531be5f3 100644
--- a/dotnet/test/common/ElementFindingTest.cs
+++ b/dotnet/test/common/ElementFindingTest.cs
@@ -34,7 +34,7 @@ public void ShouldBeAbleToFindASingleElementById()
{
driver.Url = xhtmlTestPage;
IWebElement element = driver.FindElement(By.Id("linkId"));
- Assert.AreEqual("linkId", element.GetAttribute("id"));
+ Assert.That(element.GetAttribute("id"), Is.EqualTo("linkId"));
}
[Test]
@@ -60,7 +60,7 @@ public void ShouldBeAbleToFindMultipleElementsById()
{
driver.Url = nestedPage;
ReadOnlyCollection elements = driver.FindElements(By.Id("2"));
- Assert.AreEqual(8, elements.Count);
+ Assert.That(elements, Has.Exactly(8).Items);
}
[Test]
@@ -68,7 +68,7 @@ public void ShouldBeAbleToFindMultipleElementsByNumericId()
{
driver.Url = nestedPage;
ReadOnlyCollection elements = driver.FindElements(By.Id("2"));
- Assert.That(elements.Count, Is.EqualTo(8));
+ Assert.That(elements, Has.Exactly(8).Items);
}
[Test]
@@ -76,9 +76,9 @@ public void ShouldBeAbleToFindMultipleElementsByIdWithNonAlphanumericCharacters(
{
driver.Url = nestedPage;
ReadOnlyCollection elements = driver.FindElements(By.Id("white space"));
- Assert.That(elements.Count, Is.EqualTo(2));
+ Assert.That(elements, Has.Exactly(2).Items);
ReadOnlyCollection elements2 = driver.FindElements(By.Id("css#.chars"));
- Assert.That(elements2.Count, Is.EqualTo(2));
+ Assert.That(elements2, Has.Exactly(2).Items);
}
// By.id negative
@@ -95,7 +95,7 @@ public void ShouldNotBeAbleToLocateByIdMultipleElementsThatDoNotExist()
{
driver.Url = formsPage;
ReadOnlyCollection elements = driver.FindElements(By.Id("nonExistentButton"));
- Assert.AreEqual(0, elements.Count);
+ Assert.That(elements, Is.Empty);
}
[Test]
@@ -110,7 +110,7 @@ public void FindingMultipleElementsByEmptyIdShouldReturnEmptyList()
{
driver.Url = formsPage;
ReadOnlyCollection elements = driver.FindElements(By.Id(""));
- Assert.AreEqual(0, elements.Count);
+ Assert.That(elements, Is.Empty);
}
[Test]
@@ -125,7 +125,7 @@ public void FindingMultipleElementsByIdWithSpaceShouldReturnEmptyList()
{
driver.Url = formsPage;
ReadOnlyCollection elements = driver.FindElements(By.Id("nonexistent button"));
- Assert.AreEqual(0, elements.Count);
+ Assert.That(elements, Is.Empty);
}
// By.Name positive
@@ -135,7 +135,7 @@ public void ShouldBeAbleToFindASingleElementByName()
{
driver.Url = formsPage;
IWebElement element = driver.FindElement(By.Name("checky"));
- Assert.AreEqual("furrfu", element.GetAttribute("value"));
+ Assert.That(element.GetAttribute("value"), Is.EqualTo("furrfu"));
}
[Test]
@@ -151,7 +151,7 @@ public void ShouldBeAbleToFindAnElementThatDoesNotSupportTheNameProperty()
{
driver.Url = nestedPage;
IWebElement element = driver.FindElement(By.Name("div1"));
- Assert.AreEqual("div1", element.GetAttribute("name"));
+ Assert.That(element.GetAttribute("name"), Is.EqualTo("div1"));
}
// By.Name negative
@@ -168,7 +168,7 @@ public void ShouldNotBeAbleToLocateByNameMultipleElementsThatDoNotExist()
{
driver.Url = formsPage;
ReadOnlyCollection elements = driver.FindElements(By.Name("nonExistentButton"));
- Assert.AreEqual(0, elements.Count);
+ Assert.That(elements, Is.Empty);
}
[Test]
@@ -183,7 +183,7 @@ public void FindingMultipleElementsByEmptyNameShouldReturnEmptyList()
{
driver.Url = formsPage;
ReadOnlyCollection elements = driver.FindElements(By.Name(""));
- Assert.AreEqual(0, elements.Count);
+ Assert.That(elements, Is.Empty);
}
[Test]
@@ -198,7 +198,7 @@ public void FindingMultipleElementsByNameWithSpaceShouldReturnEmptyList()
{
driver.Url = formsPage;
ReadOnlyCollection elements = driver.FindElements(By.Name("nonexistent button"));
- Assert.AreEqual(0, elements.Count);
+ Assert.That(elements, Is.Empty);
}
// By.tagName positive
@@ -208,7 +208,7 @@ public void ShouldBeAbleToFindASingleElementByTagName()
{
driver.Url = formsPage;
IWebElement element = driver.FindElement(By.TagName("input"));
- Assert.AreEqual("input", element.TagName.ToLower());
+ Assert.That(element.TagName.ToLower(), Is.EqualTo("input"));
}
[Test]
@@ -233,7 +233,7 @@ public void ShouldNotBeAbleToLocateByTagNameMultipleElementsThatDoNotExist()
{
driver.Url = formsPage;
ReadOnlyCollection elements = driver.FindElements(By.TagName("nonExistentButton"));
- Assert.AreEqual(0, elements.Count);
+ Assert.That(elements, Is.Empty);
}
[Test]
@@ -255,7 +255,7 @@ public void FindingMultipleElementsByTagNameWithSpaceShouldReturnEmptyList()
{
driver.Url = formsPage;
ReadOnlyCollection elements = driver.FindElements(By.TagName("nonexistent button"));
- Assert.AreEqual(0, elements.Count);
+ Assert.That(elements, Is.Empty);
}
// By.ClassName positive
@@ -273,7 +273,7 @@ public void ShouldBeAbleToFindMultipleElementsByClassName()
{
driver.Url = xhtmlTestPage;
ReadOnlyCollection elements = driver.FindElements(By.ClassName("nameC"));
- Assert.That(elements.Count, Is.GreaterThan(1));
+ Assert.That(elements, Has.Count.GreaterThan(1));
}
[Test]
@@ -281,7 +281,7 @@ public void ShouldFindElementByClassWhenItIsTheFirstNameAmongMany()
{
driver.Url = xhtmlTestPage;
IWebElement element = driver.FindElement(By.ClassName("nameA"));
- Assert.AreEqual("An H2 title", element.Text);
+ Assert.That(element.Text, Is.EqualTo("An H2 title"));
}
[Test]
@@ -289,7 +289,7 @@ public void ShouldFindElementByClassWhenItIsTheLastNameAmongMany()
{
driver.Url = xhtmlTestPage;
IWebElement element = driver.FindElement(By.ClassName("nameC"));
- Assert.AreEqual("An H2 title", element.Text);
+ Assert.That(element.Text, Is.EqualTo("An H2 title"));
}
[Test]
@@ -297,7 +297,7 @@ public void ShouldFindElementByClassWhenItIsInTheMiddleAmongMany()
{
driver.Url = xhtmlTestPage;
IWebElement element = driver.FindElement(By.ClassName("nameBnoise"));
- Assert.AreEqual("An H2 title", element.Text);
+ Assert.That(element.Text, Is.EqualTo("An H2 title"));
}
[Test]
@@ -305,7 +305,7 @@ public void ShouldFindElementByClassWhenItsNameIsSurroundedByWhitespace()
{
driver.Url = xhtmlTestPage;
IWebElement element = driver.FindElement(By.ClassName("spaceAround"));
- Assert.AreEqual("Spaced out", element.Text);
+ Assert.That(element.Text, Is.EqualTo("Spaced out"));
}
[Test]
@@ -313,8 +313,8 @@ public void ShouldFindElementsByClassWhenItsNameIsSurroundedByWhitespace()
{
driver.Url = xhtmlTestPage;
ReadOnlyCollection elements = driver.FindElements(By.ClassName("spaceAround"));
- Assert.AreEqual(1, elements.Count);
- Assert.AreEqual("Spaced out", elements[0].Text);
+ Assert.That(elements, Has.Exactly(1).Items);
+ Assert.That(elements[0].Text, Is.EqualTo("Spaced out"));
}
// By.ClassName negative
@@ -360,7 +360,7 @@ public void FindingASingleElementByAWeirdLookingClassName()
driver.Url = xhtmlTestPage;
String weird = "cls-!@#$%^&*";
IWebElement element = driver.FindElement(By.ClassName(weird));
- Assert.AreEqual(weird, element.GetAttribute("class"));
+ Assert.That(element.GetAttribute("class"), Is.EqualTo(weird));
}
[Test]
@@ -369,8 +369,8 @@ public void FindingMultipleElementsByAWeirdLookingClassName()
driver.Url = xhtmlTestPage;
String weird = "cls-!@#$%^&*";
ReadOnlyCollection elements = driver.FindElements(By.ClassName(weird));
- Assert.AreEqual(1, elements.Count);
- Assert.AreEqual(weird, elements[0].GetAttribute("class"));
+ Assert.That(elements, Has.Count.EqualTo(1));
+ Assert.That(elements[0].GetAttribute("class"), Is.EqualTo(weird));
}
// By.XPath positive
@@ -380,7 +380,7 @@ public void ShouldBeAbleToFindASingleElementByXPath()
{
driver.Url = xhtmlTestPage;
IWebElement element = driver.FindElement(By.XPath("//h1"));
- Assert.AreEqual("XHTML Might Be The Future", element.Text);
+ Assert.That(element.Text, Is.EqualTo("XHTML Might Be The Future"));
}
[Test]
@@ -388,7 +388,7 @@ public void ShouldBeAbleToFindMultipleElementsByXPath()
{
driver.Url = xhtmlTestPage;
ReadOnlyCollection elements = driver.FindElements(By.XPath("//div"));
- Assert.AreEqual(13, elements.Count);
+ Assert.That(elements, Has.Count.EqualTo(13));
}
[Test]
@@ -396,10 +396,10 @@ public void ShouldBeAbleToFindManyElementsRepeatedlyByXPath()
{
driver.Url = xhtmlTestPage;
String xpathString = "//node()[contains(@id,'id')]";
- Assert.AreEqual(3, driver.FindElements(By.XPath(xpathString)).Count);
+ Assert.That(driver.FindElements(By.XPath(xpathString)), Has.Exactly(3).Items);
xpathString = "//node()[contains(@id,'nope')]";
- Assert.AreEqual(0, driver.FindElements(By.XPath(xpathString)).Count);
+ Assert.That(driver.FindElements(By.XPath(xpathString)), Is.Empty);
}
[Test]
@@ -407,7 +407,7 @@ public void ShouldBeAbleToIdentifyElementsByClass()
{
driver.Url = xhtmlTestPage;
IWebElement header = driver.FindElement(By.XPath("//h1[@class='header']"));
- Assert.AreEqual("XHTML Might Be The Future", header.Text);
+ Assert.That(header.Text, Is.EqualTo("XHTML Might Be The Future"));
}
[Test]
@@ -416,8 +416,8 @@ public void ShouldBeAbleToFindAnElementByXPathWithMultipleAttributes()
driver.Url = formsPage;
IWebElement element = driver.FindElement(
By.XPath("//form[@name='optional']/input[@type='submit' and @value='Click!']"));
- Assert.AreEqual("input", element.TagName.ToLower());
- Assert.AreEqual("Click!", element.GetAttribute("value"));
+ Assert.That(element.TagName.ToLower(), Is.EqualTo("input"));
+ Assert.That(element.GetAttribute("value"), Is.EqualTo("Click!"));
}
[Test]
@@ -425,7 +425,7 @@ public void FindingALinkByXpathShouldLocateAnElementWithTheGivenText()
{
driver.Url = xhtmlTestPage;
IWebElement element = driver.FindElement(By.XPath("//a[text()='click me']"));
- Assert.AreEqual("click me", element.Text);
+ Assert.That(element.Text, Is.EqualTo("click me"));
}
[Test]
@@ -558,8 +558,8 @@ public void ShouldBeAbleToFindASingleElementByCssSelector()
{
driver.Url = xhtmlTestPage;
IWebElement element = driver.FindElement(By.CssSelector("div.content"));
- Assert.AreEqual("div", element.TagName.ToLower());
- Assert.AreEqual("content", element.GetAttribute("class"));
+ Assert.That(element.TagName.ToLower(), Is.EqualTo("div"));
+ Assert.That(element.GetAttribute("class"), Is.EqualTo("content"));
}
[Test]
@@ -575,8 +575,8 @@ public void ShouldBeAbleToFindASingleElementByCompoundCssSelector()
{
driver.Url = xhtmlTestPage;
IWebElement element = driver.FindElement(By.CssSelector("div.extraDiv, div.content"));
- Assert.AreEqual("div", element.TagName.ToLower());
- Assert.AreEqual("content", element.GetAttribute("class"));
+ Assert.That(element.TagName.ToLower(), Is.EqualTo("div"));
+ Assert.That(element.GetAttribute("class"), Is.EqualTo("content"));
}
[Test]
@@ -594,7 +594,7 @@ public void ShouldBeAbleToFindAnElementByBooleanAttributeUsingCssSelector()
{
driver.Url = (EnvironmentManager.Instance.UrlBuilder.WhereIs("locators_tests/boolean_attribute_selected.html"));
IWebElement element = driver.FindElement(By.CssSelector("option[selected='selected']"));
- Assert.AreEqual("two", element.GetAttribute("value"));
+ Assert.That(element.GetAttribute("value"), Is.EqualTo("two"));
}
[Test]
@@ -602,7 +602,7 @@ public void ShouldBeAbleToFindAnElementByBooleanAttributeUsingShortCssSelector()
{
driver.Url = (EnvironmentManager.Instance.UrlBuilder.WhereIs("locators_tests/boolean_attribute_selected.html"));
IWebElement element = driver.FindElement(By.CssSelector("option[selected]"));
- Assert.AreEqual("two", element.GetAttribute("value"));
+ Assert.That(element.GetAttribute("value"), Is.EqualTo("two"));
}
[Test]
@@ -610,7 +610,7 @@ public void ShouldBeAbleToFindAnElementByBooleanAttributeUsingShortCssSelectorOn
{
driver.Url = (EnvironmentManager.Instance.UrlBuilder.WhereIs("locators_tests/boolean_attribute_selected_html4.html"));
IWebElement element = driver.FindElement(By.CssSelector("option[selected]"));
- Assert.AreEqual("two", element.GetAttribute("value"));
+ Assert.That(element.GetAttribute("value"), Is.EqualTo("two"));
}
// By.CssSelector negative
@@ -627,7 +627,7 @@ public void ShouldNotFindElementsByCssSelectorWhenThereIsNoSuchElement()
{
driver.Url = xhtmlTestPage;
ReadOnlyCollection elements = driver.FindElements(By.CssSelector(".there-is-no-such-class"));
- Assert.AreEqual(0, elements.Count);
+ Assert.That(elements, Is.Empty);
}
[Test]
@@ -665,7 +665,7 @@ public void ShouldBeAbleToFindALinkByText()
{
driver.Url = xhtmlTestPage;
IWebElement link = driver.FindElement(By.LinkText("click me"));
- Assert.AreEqual("click me", link.Text);
+ Assert.That(link.Text, Is.EqualTo("click me"));
}
[Test]
@@ -673,7 +673,7 @@ public void ShouldBeAbleToFindMultipleLinksByText()
{
driver.Url = xhtmlTestPage;
ReadOnlyCollection elements = driver.FindElements(By.LinkText("click me"));
- Assert.AreEqual(2, elements.Count, "Expected 2 links, got " + elements.Count);
+ Assert.That(elements, Has.Count.EqualTo(2), "Expected 2 links, got " + elements.Count);
}
[Test]
@@ -681,7 +681,7 @@ public void ShouldFindElementByLinkTextContainingEqualsSign()
{
driver.Url = xhtmlTestPage;
IWebElement element = driver.FindElement(By.LinkText("Link=equalssign"));
- Assert.AreEqual("linkWithEqualsSign", element.GetAttribute("id"));
+ Assert.That(element.GetAttribute("id"), Is.EqualTo("linkWithEqualsSign"));
}
[Test]
@@ -689,8 +689,8 @@ public void ShouldFindMultipleElementsByLinkTextContainingEqualsSign()
{
driver.Url = xhtmlTestPage;
ReadOnlyCollection elements = driver.FindElements(By.LinkText("Link=equalssign"));
- Assert.AreEqual(1, elements.Count);
- Assert.AreEqual("linkWithEqualsSign", elements[0].GetAttribute("id"));
+ Assert.That(elements, Has.Count.EqualTo(1));
+ Assert.That(elements[0].GetAttribute("id"), Is.EqualTo("linkWithEqualsSign"));
}
[Test]
@@ -705,7 +705,7 @@ public void FindsByLinkTextOnXhtmlPage()
driver.Url = (EnvironmentManager.Instance.UrlBuilder.WhereIs("actualXhtmlPage.xhtml"));
string linkText = "Foo";
IWebElement element = driver.FindElement(By.LinkText(linkText));
- Assert.AreEqual(linkText, element.Text);
+ Assert.That(element.Text, Is.EqualTo(linkText));
}
[Test]
@@ -716,7 +716,7 @@ public void LinkWithFormattingTags()
IWebElement elem = driver.FindElement(By.Id("links"));
IWebElement res = elem.FindElement(By.PartialLinkText("link with formatting tags"));
- Assert.AreEqual("link with formatting tags", res.Text);
+ Assert.That(res.Text, Is.EqualTo("link with formatting tags"));
}
[Test]
@@ -724,8 +724,8 @@ public void DriverCanGetLinkByLinkTestIgnoringTrailingWhitespace()
{
driver.Url = simpleTestPage;
IWebElement link = driver.FindElement(By.LinkText("link with trailing space"));
- Assert.AreEqual("linkWithTrailingSpace", link.GetAttribute("id"));
- Assert.AreEqual("link with trailing space", link.Text);
+ Assert.That(link.GetAttribute("id"), Is.EqualTo("linkWithTrailingSpace"));
+ Assert.That(link.Text, Is.EqualTo("link with trailing space"));
}
// By.linkText negative
@@ -742,7 +742,7 @@ public void ShouldNotBeAbleToLocateByLinkTextMultipleElementsThatDoNotExist()
{
driver.Url = xhtmlTestPage;
ReadOnlyCollection elements = driver.FindElements(By.LinkText("Not here either"));
- Assert.AreEqual(0, elements.Count);
+ Assert.That(elements, Is.Empty);
}
// By.partialLinkText positive
@@ -752,7 +752,7 @@ public void ShouldBeAbleToFindMultipleElementsByPartialLinkText()
{
driver.Url = xhtmlTestPage;
ReadOnlyCollection elements = driver.FindElements(By.PartialLinkText("ick me"));
- Assert.AreEqual(2, elements.Count);
+ Assert.That(elements, Has.Exactly(2).Items);
}
[Test]
@@ -768,7 +768,7 @@ public void ShouldFindElementByPartialLinkTextContainingEqualsSign()
{
driver.Url = xhtmlTestPage;
IWebElement element = driver.FindElement(By.PartialLinkText("Link="));
- Assert.AreEqual("linkWithEqualsSign", element.GetAttribute("id"));
+ Assert.That(element.GetAttribute("id"), Is.EqualTo("linkWithEqualsSign"));
}
[Test]
@@ -776,8 +776,8 @@ public void ShouldFindMultipleElementsByPartialLinkTextContainingEqualsSign()
{
driver.Url = xhtmlTestPage;
ReadOnlyCollection elements = driver.FindElements(By.PartialLinkText("Link="));
- Assert.AreEqual(1, elements.Count);
- Assert.AreEqual("linkWithEqualsSign", elements[0].GetAttribute("id"));
+ Assert.That(elements, Has.Count.EqualTo(1));
+ Assert.That(elements[0].GetAttribute("id"), Is.EqualTo("linkWithEqualsSign"));
}
// Misc tests
@@ -788,7 +788,7 @@ public void DriverShouldBeAbleToFindElementsAfterLoadingMoreThanOnePageAtATime()
driver.Url = formsPage;
driver.Url = xhtmlTestPage;
IWebElement link = driver.FindElement(By.LinkText("click me"));
- Assert.AreEqual("click me", link.Text);
+ Assert.That(link.Text, Is.EqualTo("click me"));
}
// You don't want to ask why this is here
@@ -798,16 +798,16 @@ public void WhenFindingByNameShouldNotReturnById()
driver.Url = formsPage;
IWebElement element = driver.FindElement(By.Name("id-name1"));
- Assert.AreEqual("name", element.GetAttribute("value"));
+ Assert.That(element.GetAttribute("value"), Is.EqualTo("name"));
element = driver.FindElement(By.Id("id-name1"));
- Assert.AreEqual("id", element.GetAttribute("value"));
+ Assert.That(element.GetAttribute("value"), Is.EqualTo("id"));
element = driver.FindElement(By.Name("id-name2"));
- Assert.AreEqual("name", element.GetAttribute("value"));
+ Assert.That(element.GetAttribute("value"), Is.EqualTo("name"));
element = driver.FindElement(By.Id("id-name2"));
- Assert.AreEqual("id", element.GetAttribute("value"));
+ Assert.That(element.GetAttribute("value"), Is.EqualTo("id"));
}
[Test]
@@ -815,7 +815,7 @@ public void ShouldBeAbleToFindAHiddenElementsByName()
{
driver.Url = formsPage;
IWebElement element = driver.FindElement(By.Name("hidden"));
- Assert.AreEqual("hidden", element.GetAttribute("name"));
+ Assert.That(element.GetAttribute("name"), Is.EqualTo("hidden"));
}
[Test]
@@ -851,10 +851,10 @@ public void AnElementFoundInADifferentFrameIsStale()
public void ShouldReturnTitleOfPageIfSet()
{
driver.Url = xhtmlTestPage;
- Assert.AreEqual(driver.Title, "XHTML Test Page");
+ Assert.That(driver.Title, Is.EqualTo("XHTML Test Page"));
driver.Url = simpleTestPage;
- Assert.AreEqual(driver.Title, "Hello WebDriver");
+ Assert.That(driver.Title, Is.EqualTo("Hello WebDriver"));
}
[Test]
@@ -863,7 +863,7 @@ public void ShouldBeAbleToClickOnLinkIdentifiedByText()
driver.Url = xhtmlTestPage;
driver.FindElement(By.LinkText("click me")).Click();
WaitFor(() => { return driver.Title == "We Arrive Here"; }, "Browser title is not 'We Arrive Here'");
- Assert.AreEqual(driver.Title, "We Arrive Here");
+ Assert.That(driver.Title, Is.EqualTo("We Arrive Here"));
}
[Test]
@@ -872,7 +872,7 @@ public void ShouldBeAbleToClickOnLinkIdentifiedById()
driver.Url = xhtmlTestPage;
driver.FindElement(By.Id("linkId")).Click();
WaitFor(() => { return driver.Title == "We Arrive Here"; }, "Browser title is not 'We Arrive Here'");
- Assert.AreEqual(driver.Title, "We Arrive Here");
+ Assert.That(driver.Title, Is.EqualTo("We Arrive Here"));
}
[Test]
@@ -892,7 +892,7 @@ public void ShouldBeAbleToFindChildrenOfANode()
ReadOnlyCollection elements = driver.FindElements(By.XPath("/html/head"));
IWebElement head = elements[0];
ReadOnlyCollection importedScripts = head.FindElements(By.TagName("script"));
- Assert.AreEqual(importedScripts.Count, 3);
+ Assert.That(importedScripts, Has.Exactly(3).Items);
}
[Test]
@@ -902,7 +902,7 @@ public void ReturnAnEmptyListWhenThereAreNoChildrenOfANode()
IWebElement table = driver.FindElement(By.Id("table"));
ReadOnlyCollection rows = table.FindElements(By.TagName("tr"));
- Assert.AreEqual(rows.Count, 0);
+ Assert.That(rows, Is.Empty);
}
[Test]
@@ -912,7 +912,7 @@ public void ShouldFindElementsByName()
IWebElement element = driver.FindElement(By.Name("checky"));
- Assert.AreEqual(element.GetAttribute("value"), "furrfu");
+ Assert.That(element.GetAttribute("value"), Is.EqualTo("furrfu"));
}
[Test]
@@ -921,7 +921,7 @@ public void ShouldFindElementsByClassWhenItIsTheFirstNameAmongMany()
driver.Url = xhtmlTestPage;
IWebElement element = driver.FindElement(By.ClassName("nameA"));
- Assert.AreEqual(element.Text, "An H2 title");
+ Assert.That(element.Text, Is.EqualTo("An H2 title"));
}
[Test]
@@ -930,7 +930,7 @@ public void ShouldFindElementsByClassWhenItIsTheLastNameAmongMany()
driver.Url = xhtmlTestPage;
IWebElement element = driver.FindElement(By.ClassName("nameC"));
- Assert.AreEqual(element.Text, "An H2 title");
+ Assert.That(element.Text, Is.EqualTo("An H2 title"));
}
[Test]
@@ -939,7 +939,7 @@ public void ShouldFindElementsByClassWhenItIsInTheMiddleAmongMany()
driver.Url = xhtmlTestPage;
IWebElement element = driver.FindElement(By.ClassName("nameBnoise"));
- Assert.AreEqual(element.Text, "An H2 title");
+ Assert.That(element.Text, Is.EqualTo("An H2 title"));
}
[Test]
@@ -976,7 +976,7 @@ public void ShouldBeAbleToClickOnLinksWithNoHrefAttribute()
element.Click();
// if any exception is thrown, we won't get this far. Sanity check
- Assert.AreEqual("Changed", driver.Title);
+ Assert.That(driver.Title, Is.EqualTo("Changed"));
}
[Test]
@@ -985,8 +985,8 @@ public void FindingByTagNameShouldNotIncludeParentElementIfSameTagType()
driver.Url = xhtmlTestPage;
IWebElement parent = driver.FindElement(By.Id("my_span"));
- Assert.AreEqual(2, parent.FindElements(By.TagName("div")).Count);
- Assert.AreEqual(2, parent.FindElements(By.TagName("span")).Count);
+ Assert.That(parent.FindElements(By.TagName("div")), Has.Count.EqualTo(2));
+ Assert.That(parent.FindElements(By.TagName("span")), Has.Count.EqualTo(2));
}
[Test]
@@ -996,7 +996,7 @@ public void FindingByCssShouldNotIncludeParentElementIfSameTagType()
IWebElement parent = driver.FindElement(By.CssSelector("div#parent"));
IWebElement child = parent.FindElement(By.CssSelector("div"));
- Assert.AreEqual("child", child.GetAttribute("id"));
+ Assert.That(child.GetAttribute("id"), Is.EqualTo("child"));
}
[Test]
@@ -1005,8 +1005,8 @@ public void FindingByXPathShouldNotIncludeParentElementIfSameTagType()
driver.Url = xhtmlTestPage;
IWebElement parent = driver.FindElement(By.Id("my_span"));
- Assert.AreEqual(2, parent.FindElements(By.TagName("div")).Count);
- Assert.AreEqual(2, parent.FindElements(By.TagName("span")).Count);
+ Assert.That(parent.FindElements(By.TagName("div")), Has.Count.EqualTo(2));
+ Assert.That(parent.FindElements(By.TagName("span")), Has.Count.EqualTo(2));
}
[Test]
@@ -1025,7 +1025,7 @@ public void ShouldFindElementByLinkTextContainingDoubleQuote()
{
driver.Url = simpleTestPage;
IWebElement element = driver.FindElement(By.LinkText("link with \" (double quote)"));
- Assert.AreEqual("quote", element.GetAttribute("id"));
+ Assert.That(element.GetAttribute("id"), Is.EqualTo("quote"));
}
[Test]
@@ -1033,7 +1033,7 @@ public void ShouldFindElementByLinkTextContainingBackslash()
{
driver.Url = simpleTestPage;
IWebElement element = driver.FindElement(By.LinkText("link with \\ (backslash)"));
- Assert.AreEqual("backslash", element.GetAttribute("id"));
+ Assert.That(element.GetAttribute("id"), Is.EqualTo("backslash"));
}
}
}
diff --git a/dotnet/test/common/ElementPropertyTest.cs b/dotnet/test/common/ElementPropertyTest.cs
index fd93089262c2a..2f3b98c80bfe1 100644
--- a/dotnet/test/common/ElementPropertyTest.cs
+++ b/dotnet/test/common/ElementPropertyTest.cs
@@ -40,9 +40,10 @@ public void CanRetrieveTheCurrentValueOfAProperty()
{
driver.Url = formsPage;
IWebElement element = driver.FindElement(By.Id("working"));
- Assert.AreEqual(string.Empty, element.GetDomProperty("value"));
+
+ Assert.That(element.GetDomProperty("value"), Is.Empty);
element.SendKeys("hello world");
- Assert.AreEqual("hello world", element.GetDomProperty("value"));
+ Assert.That(element.GetDomProperty("value"), Is.EqualTo("hello world"));
}
}
}
diff --git a/dotnet/test/common/ElementSelectingTest.cs b/dotnet/test/common/ElementSelectingTest.cs
index 0fc8013784878..6d9bb1a7125ac 100644
--- a/dotnet/test/common/ElementSelectingTest.cs
+++ b/dotnet/test/common/ElementSelectingTest.cs
@@ -204,14 +204,14 @@ private static void AssertSelected(IWebElement element)
private static void AssertSelected(IWebElement element, bool isSelected)
{
- Assert.AreEqual(isSelected, element.Selected, string.Format("Expected element {0} to be {1} but was {2}", Describe(element), SelectedToString(isSelected), SelectedToString(!isSelected)));
+ Assert.That(element.Selected, Is.EqualTo(isSelected), string.Format("Expected element {0} to be {1} but was {2}", Describe(element), SelectedToString(isSelected), SelectedToString(!isSelected)));
}
private static void AssertCannotSelect(IWebElement element)
{
bool previous = element.Selected;
element.Click();
- Assert.AreEqual(previous, element.Selected);
+ Assert.That(element.Selected, Is.EqualTo(previous));
}
private static void AssertCanSelect(IWebElement element)
@@ -261,7 +261,7 @@ private static void AssertTogglingSwapsSelectedStateFrom(IWebElement element, bo
{
element.Click();
bool isNowSelected = element.Selected;
- Assert.AreNotEqual(isNowSelected, originalState, string.Format("Expected element {0} to have been toggled to {1} but was {2}", Describe(element), SelectedToString(!originalState), SelectedToString(originalState)));
+ Assert.That(originalState, Is.Not.EqualTo(isNowSelected), string.Format("Expected element {0} to have been toggled to {1} but was {2}", Describe(element), SelectedToString(!originalState), SelectedToString(originalState)));
AssertSelected(element, !originalState);
}
diff --git a/dotnet/test/common/ErrorsTest.cs b/dotnet/test/common/ErrorsTest.cs
index f01894020c3f3..ad5ea3a120833 100644
--- a/dotnet/test/common/ErrorsTest.cs
+++ b/dotnet/test/common/ErrorsTest.cs
@@ -35,7 +35,7 @@ public void ShouldNotGenerateErrorsWhenOpeningANewPage()
{
driver.Url = errorsPage;
object result = ((IJavaScriptExecutor)driver).ExecuteScript("return window.ERRORS.join('\\n');");
- Assert.AreEqual("", result, "Should have no errors");
+ Assert.That(result, Is.Empty, "Should have no errors");
}
}
diff --git a/dotnet/test/common/ExecutingAsyncJavascriptTest.cs b/dotnet/test/common/ExecutingAsyncJavascriptTest.cs
index 077bcd721c0fa..ef0711453b6dc 100644
--- a/dotnet/test/common/ExecutingAsyncJavascriptTest.cs
+++ b/dotnet/test/common/ExecutingAsyncJavascriptTest.cs
@@ -118,7 +118,7 @@ public void ShouldBeAbleToReturnArraysOfPrimitivesFromAsyncScripts()
Assert.That(result, Is.Not.Null);
Assert.That(result, Is.InstanceOf>());
ReadOnlyCollection resultList = result as ReadOnlyCollection;
- Assert.That(resultList.Count, Is.EqualTo(5));
+ Assert.That(resultList, Has.Count.EqualTo(5));
Assert.That(resultList[0], Is.Null);
Assert.That((long)resultList[1], Is.EqualTo(123));
Assert.That(resultList[2].ToString(), Is.EqualTo("abc"));
@@ -221,10 +221,12 @@ public void ShouldCatchErrorsWithMessageAndStacktraceWhenExecutingInitialScript(
string js = "function functionB() { throw Error('errormessage'); };"
+ "function functionA() { functionB(); };"
+ "functionA();";
- Exception ex = Assert.Catch(() => executor.ExecuteAsyncScript(js));
- Assert.That(ex, Is.InstanceOf());
- Assert.That(ex.Message.Contains("errormessage"));
- Assert.That(ex.StackTrace.Contains("functionB"));
+
+ Assert.That(
+ () => executor.ExecuteAsyncScript(js),
+ Throws.InstanceOf()
+ .With.Message.Contains("errormessage")
+ .And.Property(nameof(WebDriverException.StackTrace)).Contains("functionB"));
}
[Test]
@@ -236,21 +238,21 @@ public void ShouldBeAbleToExecuteAsynchronousScripts()
IWebElement typer = driver.FindElement(By.Name("typer"));
typer.SendKeys("bob");
- Assert.AreEqual("bob", typer.GetAttribute("value"));
+ Assert.That(typer.GetAttribute("value"), Is.EqualTo("bob"));
driver.FindElement(By.Id("red")).Click();
driver.FindElement(By.Name("submit")).Click();
- Assert.AreEqual(1, GetNumberOfDivElements(), "There should only be 1 DIV at this point, which is used for the butter message");
+ Assert.That(GetNumberOfDivElements(), Is.EqualTo(1), "There should only be 1 DIV at this point, which is used for the butter message");
driver.Manage().Timeouts().AsynchronousJavaScript = TimeSpan.FromSeconds(10);
string text = (string)executor.ExecuteAsyncScript(
"var callback = arguments[arguments.length - 1];"
+ "window.registerListener(arguments[arguments.length - 1]);");
- Assert.AreEqual("bob", text);
- Assert.AreEqual("", typer.GetAttribute("value"));
+ Assert.That(text, Is.EqualTo("bob"));
+ Assert.That(typer.GetAttribute("value"), Is.Empty);
- Assert.AreEqual(2, GetNumberOfDivElements(), "There should be 1 DIV (for the butter message) + 1 DIV (for the new label)");
+ Assert.That(GetNumberOfDivElements(), Is.EqualTo(2), "There should be 1 DIV (for the butter message) + 1 DIV (for the new label)");
}
[Test]
@@ -258,7 +260,7 @@ public void ShouldBeAbleToPassMultipleArgumentsToAsyncScripts()
{
driver.Url = ajaxyPage;
long result = (long)executor.ExecuteAsyncScript("arguments[arguments.length - 1](arguments[0] + arguments[1]);", 1, 2);
- Assert.AreEqual(3, result);
+ Assert.That(result, Is.EqualTo(3));
}
[Test]
@@ -290,7 +292,7 @@ public void ShouldBeAbleToMakeXMLHttpRequestsAndWaitForTheResponse()
driver.Url = ajaxyPage;
driver.Manage().Timeouts().AsynchronousJavaScript = TimeSpan.FromSeconds(3);
string response = (string)executor.ExecuteAsyncScript(script, sleepingPage + "?time=2");
- Assert.AreEqual("Done Slept for 2s", response.Trim());
+ Assert.That(response.Trim(), Is.EqualTo("Done Slept for 2s"));
}
[Test]
diff --git a/dotnet/test/common/ExecutingJavascriptTest.cs b/dotnet/test/common/ExecutingJavascriptTest.cs
index 34a567a7a92c2..d5b239a9cf206 100644
--- a/dotnet/test/common/ExecutingJavascriptTest.cs
+++ b/dotnet/test/common/ExecutingJavascriptTest.cs
@@ -143,7 +143,7 @@ public void ShouldBeAbleToExecuteJavascriptAndReturnABasicObjectLiteral()
expected.Add("abc", "123");
expected.Add("tired", false);
- Assert.AreEqual(expected.Count, map.Count, "Expected:<" + expected.Count + ">, but was:<" + map.Count + ">");
+ Assert.That(map, Has.Count.EqualTo(expected.Count), "Expected:<" + expected.Count + ">, but was:<" + map.Count + ">");
foreach (string expectedKey in expected.Keys)
{
Assert.That(map, Does.ContainKey(expectedKey));
@@ -200,8 +200,8 @@ public void ShouldBeAbleToExecuteSimpleJavascriptAndReturnAComplexObject()
Assert.That(result, Is.InstanceOf>());
Dictionary map = (Dictionary)result;
- Assert.AreEqual("http:", map["protocol"]);
- Assert.AreEqual(javascriptPage, map["href"]);
+ Assert.That(map["protocol"], Is.EqualTo("http:"));
+ Assert.That(map["href"], Is.EqualTo(javascriptPage));
}
[Test]
@@ -256,10 +256,12 @@ public void ShouldThrowAnExceptionWithMessageAndStacktraceWhenTheJavascriptIsBad
string js = "function functionB() { throw Error('errormessage'); };"
+ "function functionA() { functionB(); };"
+ "functionA();";
- Exception ex = Assert.Catch(() => ExecuteScript(js));
- Assert.That(ex, Is.InstanceOf());
- Assert.That(ex.Message.Contains("errormessage"), "Exception message does not contain 'errormessage'");
- Assert.That(ex.StackTrace.Contains("functionB"), "Exception message does not contain 'functionB'");
+
+ Assert.That(
+ () => ExecuteScript(js),
+ Throws.InstanceOf()
+ .With.Message.Contains("errormessage")
+ .And.Property(nameof(WebDriverException.StackTrace)).Contains("functionB"));
}
[Test]
@@ -272,7 +274,7 @@ public void ShouldBeAbleToCallFunctionsDefinedOnThePage()
ExecuteScript("displayMessage('I like cheese');");
string text = driver.FindElement(By.Id("result")).Text;
- Assert.AreEqual("I like cheese", text.Trim());
+ Assert.That(text.Trim(), Is.EqualTo("I like cheese"));
}
[Test]
@@ -284,7 +286,7 @@ public void ShouldBeAbleToPassAStringAsAnArgument()
driver.Url = javascriptPage;
string text = (string)ExecuteScript("return arguments[0] == 'Hello!' ? 'Hello!' : 'Goodbye!';", "Hello!");
- Assert.AreEqual("Hello!", text);
+ Assert.That(text, Is.EqualTo("Hello!"));
}
[Test]
@@ -317,19 +319,19 @@ public void ShouldBeAbleToPassANumberAsAnArgument()
string function = string.Format(functionTemplate, 3);
long result = (long)ExecuteScript(function, 3);
- Assert.AreEqual(3, result);
+ Assert.That(result, Is.EqualTo(3));
function = string.Format(functionTemplate, -3);
result = (long)ExecuteScript(function, -3);
- Assert.AreEqual(-3, result);
+ Assert.That(result, Is.EqualTo(-3));
function = string.Format(functionTemplate, 2147483647);
result = (long)ExecuteScript(function, 2147483647);
- Assert.AreEqual(2147483647, result);
+ Assert.That(result, Is.EqualTo(2147483647));
function = string.Format(functionTemplate, -2147483647);
result = (long)ExecuteScript(function, -2147483647);
- Assert.AreEqual(-2147483647, result);
+ Assert.That(result, Is.EqualTo(-2147483647));
}
[Test]
@@ -343,7 +345,7 @@ public void ShouldBeAbleToPassAWebElementAsArgument()
IWebElement button = driver.FindElement(By.Id("plainButton"));
string value = (string)ExecuteScript("arguments[0]['flibble'] = arguments[0].getAttribute('id'); return arguments[0]['flibble'];", button);
- Assert.AreEqual("plainButton", value);
+ Assert.That(value, Is.EqualTo("plainButton"));
}
[Test]
@@ -357,7 +359,7 @@ public void PassingArrayAsOnlyArgumentShouldFlattenArray()
driver.Url = javascriptPage;
object[] array = new object[] { "zero", 1, true, 3.14159 };
long length = (long)ExecuteScript("return arguments[0].length", array);
- Assert.AreEqual(array.Length, length);
+ Assert.That(length, Is.EqualTo(array.Length));
}
[Test]
@@ -371,7 +373,7 @@ public void ShouldBeAbleToPassAnArrayAsAdditionalArgument()
driver.Url = javascriptPage;
object[] array = new object[] { "zero", 1, true, 3.14159, false };
long length = (long)ExecuteScript("return arguments[1].length", "string", array);
- Assert.AreEqual(array.Length, length);
+ Assert.That(length, Is.EqualTo(array.Length));
}
[Test]
@@ -388,7 +390,7 @@ public void ShouldBeAbleToPassACollectionAsArgument()
collection.Add("Brie");
collection.Add(7);
long length = (long)ExecuteScript("return arguments[0].length", collection);
- Assert.AreEqual(collection.Count, length);
+ Assert.That(length, Is.EqualTo(collection.Count));
}
[Test]
@@ -415,7 +417,7 @@ public void ShouldBeAbleToPassInMoreThanOneArgument()
driver.Url = javascriptPage;
string result = (string)ExecuteScript("return arguments[0] + arguments[1];", "one", "two");
- Assert.AreEqual("onetwo", result);
+ Assert.That(result, Is.EqualTo("onetwo"));
}
[Test]
@@ -426,7 +428,7 @@ public void ShouldBeAbleToGrabTheBodyOfFrameOnceSwitchedTo()
driver.SwitchTo().Frame("editFrame");
IWebElement body = (IWebElement)((IJavaScriptExecutor)driver).ExecuteScript("return document.body");
- Assert.AreEqual("", body.Text);
+ Assert.That(body.Text, Is.Empty);
}
// This is a duplicate test of ShouldBeAbleToExecuteScriptAndReturnElementsList.
@@ -449,13 +451,13 @@ public void JavascriptStringHandlingShouldWorkAsExpected()
driver.Url = javascriptPage;
string value = (string)ExecuteScript("return '';");
- Assert.AreEqual("", value);
+ Assert.That(value, Is.Empty);
value = (string)ExecuteScript("return undefined;");
Assert.That(value, Is.Null);
value = (string)ExecuteScript("return ' '");
- Assert.AreEqual(" ", value);
+ Assert.That(value, Is.EqualTo(" "));
}
[Test]
@@ -467,7 +469,7 @@ public void ShouldBeAbleToExecuteABigChunkOfJavascriptCode()
if (fileList.Length > 0)
{
string jquery = System.IO.File.ReadAllText(fileList[0]);
- Assert.That(jquery.Length, Is.GreaterThan(50000));
+ Assert.That(jquery, Has.Length.GreaterThan(50000));
ExecuteScript(jquery, null);
}
}
@@ -508,7 +510,7 @@ public void ShouldBeAbleToExecuteScriptAndReturnElementsList()
ReadOnlyCollection resultsList = (ReadOnlyCollection)resultObject;
- Assert.That(resultsList.Count, Is.GreaterThan(0));
+ Assert.That(resultsList, Is.Not.Empty);
}
[Test]
@@ -520,7 +522,7 @@ public void ShouldBeAbleToCreateAPersistentValue()
ExecuteScript("document.alerts.push('hello world');");
string text = (string)ExecuteScript("return document.alerts.shift()");
- Assert.AreEqual("hello world", text);
+ Assert.That(text, Is.EqualTo("hello world"));
}
[Test]
@@ -533,7 +535,7 @@ public void ShouldBeAbleToHandleAnArrayOfElementsAsAnObjectArray()
string name = (string)((IJavaScriptExecutor)driver).ExecuteScript("return arguments[0][0].tagName", args);
- Assert.AreEqual("form", name.ToLower());
+ Assert.That(name, Is.EqualTo("form").IgnoreCase);
}
[Test]
@@ -548,7 +550,7 @@ public void ShouldBeAbleToPassADictionaryAsAParameter()
object res = ((IJavaScriptExecutor)driver).ExecuteScript("return arguments[0]['foo'][1]", args);
- Assert.AreEqual(2, (long)res);
+ Assert.That((long)res, Is.EqualTo(2));
}
[Test]
@@ -713,7 +715,7 @@ public void ShouldBeAbleToPassMoreThanOneStringAsArguments()
driver.Url = javascriptPage;
string text = (string)ExecuteScript("return arguments[0] + arguments[1] + arguments[2] + arguments[3];", "Hello,", " ", "world", "!");
- Assert.AreEqual("Hello, world!", text);
+ Assert.That(text, Is.EqualTo("Hello, world!"));
}
[Test]
@@ -728,16 +730,16 @@ public void ShouldBeAbleToPassMoreThanOneBooleanAsArguments()
driver.Url = javascriptPage;
string text = (string)ExecuteScript(function, true, true);
- Assert.AreEqual("TrueTrue", text);
+ Assert.That(text, Is.EqualTo("TrueTrue"));
text = (string)ExecuteScript(function, false, true);
- Assert.AreEqual("FalseTrue", text);
+ Assert.That(text, Is.EqualTo("FalseTrue"));
text = (string)ExecuteScript(function, true, false);
- Assert.AreEqual("TrueFalse", text);
+ Assert.That(text, Is.EqualTo("TrueFalse"));
text = (string)ExecuteScript(function, false, false);
- Assert.AreEqual("FalseFalse", text);
+ Assert.That(text, Is.EqualTo("FalseFalse"));
}
[Test]
@@ -751,16 +753,16 @@ public void ShouldBeAbleToPassMoreThanOneNumberAsArguments()
driver.Url = javascriptPage;
long result = (long)ExecuteScript(function, 30, 12);
- Assert.AreEqual(42, result);
+ Assert.That(result, Is.EqualTo(42));
result = (long)ExecuteScript(function, -30, -12);
- Assert.AreEqual(-42, result);
+ Assert.That(result, Is.EqualTo(-42));
result = (long)ExecuteScript(function, 2147483646, 1);
- Assert.AreEqual(2147483647, result);
+ Assert.That(result, Is.EqualTo(2147483647));
result = (long)ExecuteScript(function, -2147483646, -1);
- Assert.AreEqual(-2147483647, result);
+ Assert.That(result, Is.EqualTo(-2147483647));
}
@@ -775,22 +777,22 @@ public void ShouldBeAbleToPassADoubleAsAnArgument()
driver.Url = javascriptPage;
double result = (double)ExecuteScript(function, (double)4.2);
- Assert.AreEqual(4.2, result);
+ Assert.That(result, Is.EqualTo(4.2));
result = (double)ExecuteScript(function, (double)-4.2);
- Assert.AreEqual(-4.2, result);
+ Assert.That(result, Is.EqualTo(-4.2));
result = (double)ExecuteScript(function, (float)4.2);
- Assert.AreEqual(4.2, result);
+ Assert.That(result, Is.EqualTo(4.2));
result = (double)ExecuteScript(function, (float)-4.2);
- Assert.AreEqual(-4.2, result);
+ Assert.That(result, Is.EqualTo(-4.2));
result = (long)ExecuteScript(function, (double)4.0);
- Assert.AreEqual(4, result);
+ Assert.That(result, Is.EqualTo(4));
result = (long)ExecuteScript(function, (double)-4.0);
- Assert.AreEqual(-4, result);
+ Assert.That(result, Is.EqualTo(-4));
}
[Test]
@@ -804,16 +806,16 @@ public void ShouldBeAbleToPassMoreThanOneDoubleAsArguments()
driver.Url = javascriptPage;
double result = (double)ExecuteScript(function, 30.1, 12.1);
- Assert.AreEqual(42.2, result);
+ Assert.That(result, Is.EqualTo(42.2));
result = (double)ExecuteScript(function, -30.1, -12.1);
- Assert.AreEqual(-42.2, result);
+ Assert.That(result, Is.EqualTo(-42.2));
result = (double)ExecuteScript(function, 2147483646.1, 1.0);
- Assert.AreEqual(2147483647.1, result);
+ Assert.That(result, Is.EqualTo(2147483647.1));
result = (double)ExecuteScript(function, -2147483646.1, -1.0);
- Assert.AreEqual(-2147483647.1, result);
+ Assert.That(result, Is.EqualTo(-2147483647.1));
}
@@ -828,7 +830,7 @@ public void ShouldBeAbleToPassMoreThanOneWebElementAsArguments()
IWebElement dynamo = driver.FindElement(By.Id("dynamo"));
string value = (string)ExecuteScript("arguments[0]['flibble'] = arguments[0].getAttribute('id'); return arguments[0]['flibble'] + arguments[1].innerHTML;", button, dynamo);
- Assert.AreEqual("plainButtonWhat's for dinner?", value);
+ Assert.That(value, Is.EqualTo("plainButtonWhat's for dinner?"));
}
[Test]
@@ -847,7 +849,7 @@ public void ShouldBeAbleToPassInMixedArguments()
"Hello, World!",
true);
- Assert.AreEqual("What's for dinner?424.2Hello, World!true", result);
+ Assert.That(result, Is.EqualTo("What's for dinner?424.2Hello, World!true"));
}
@@ -864,7 +866,7 @@ public void ShouldBeAbleToPassInAndRetrieveDates()
ExecuteScript(function, "2014-05-20T20:00:00+08:00");
IWebElement element = driver.FindElement(By.Id("result"));
string text = element.Text;
- Assert.AreEqual("2014-05-20T20:00:00+08:00", text);
+ Assert.That(text, Is.EqualTo("2014-05-20T20:00:00+08:00"));
}
private object ExecuteScript(String script, params Object[] args)
diff --git a/dotnet/test/common/FormHandlingTests.cs b/dotnet/test/common/FormHandlingTests.cs
index 736b77a610f25..47382b7ebf8e1 100644
--- a/dotnet/test/common/FormHandlingTests.cs
+++ b/dotnet/test/common/FormHandlingTests.cs
@@ -32,7 +32,7 @@ public void ShouldClickOnSubmitInputElements()
driver.Url = formsPage;
driver.FindElement(By.Id("submitButton")).Click();
WaitFor(TitleToBe("We Arrive Here"), "Browser title is not 'We Arrive Here'");
- Assert.AreEqual(driver.Title, "We Arrive Here");
+ Assert.That(driver.Title, Is.EqualTo("We Arrive Here"));
}
[Test]
@@ -48,7 +48,7 @@ public void ShouldBeAbleToClickImageButtons()
driver.Url = formsPage;
driver.FindElement(By.Id("imageButton")).Click();
WaitFor(TitleToBe("We Arrive Here"), "Browser title is not 'We Arrive Here'");
- Assert.AreEqual(driver.Title, "We Arrive Here");
+ Assert.That(driver.Title, Is.EqualTo("We Arrive Here"));
}
[Test]
@@ -57,7 +57,7 @@ public void ShouldBeAbleToSubmitForms()
driver.Url = formsPage;
driver.FindElement(By.Name("login")).Submit();
WaitFor(TitleToBe("We Arrive Here"), "Browser title is not 'We Arrive Here'");
- Assert.AreEqual(driver.Title, "We Arrive Here");
+ Assert.That(driver.Title, Is.EqualTo("We Arrive Here"));
}
[Test]
@@ -66,7 +66,7 @@ public void ShouldSubmitAFormWhenAnyInputElementWithinThatFormIsSubmitted()
driver.Url = formsPage;
driver.FindElement(By.Id("checky")).Submit();
WaitFor(TitleToBe("We Arrive Here"), "Browser title is not 'We Arrive Here'");
- Assert.AreEqual(driver.Title, "We Arrive Here");
+ Assert.That(driver.Title, Is.EqualTo("We Arrive Here"));
}
[Test]
@@ -75,7 +75,7 @@ public void ShouldSubmitAFormWhenAnyElementWithinThatFormIsSubmitted()
driver.Url = formsPage;
driver.FindElement(By.XPath("//form/p")).Submit();
WaitFor(TitleToBe("We Arrive Here"), "Browser title is not 'We Arrive Here'");
- Assert.AreEqual(driver.Title, "We Arrive Here");
+ Assert.That(driver.Title, Is.EqualTo("We Arrive Here"));
}
[Test]
@@ -84,7 +84,7 @@ public void ShouldSubmitAFormWithIdSubmit()
driver.Url = formsPage;
driver.FindElement(By.Id("submit")).Submit();
WaitFor(TitleToBe("We Arrive Here"), "Browser title is not 'We Arrive Here'");
- Assert.AreEqual(driver.Title, "We Arrive Here");
+ Assert.That(driver.Title, Is.EqualTo("We Arrive Here"));
}
[Test]
@@ -94,7 +94,7 @@ public void ShouldSubmitAFormWithNameSubmit()
driver.Url = formsPage;
driver.FindElement(By.Name("submit")).Submit();
WaitFor(TitleToBe("We Arrive Here"), "Browser title is not 'We Arrive Here'");
- Assert.AreEqual(driver.Title, "We Arrive Here");
+ Assert.That(driver.Title, Is.EqualTo("We Arrive Here"));
}
[Test]
@@ -111,7 +111,7 @@ public void ShouldBeAbleToEnterTextIntoATextAreaBySettingItsValue()
IWebElement textarea = driver.FindElement(By.Id("keyUpArea"));
string cheesey = "Brie and cheddar";
textarea.SendKeys(cheesey);
- Assert.AreEqual(textarea.GetAttribute("value"), cheesey);
+ Assert.That(textarea.GetAttribute("value"), Is.EqualTo(cheesey));
}
[Test]
@@ -121,7 +121,7 @@ public void SendKeysKeepsCapitalization()
IWebElement textarea = driver.FindElement(By.Id("keyUpArea"));
string cheesey = "BrIe And CheDdar";
textarea.SendKeys(cheesey);
- Assert.AreEqual(textarea.GetAttribute("value"), cheesey);
+ Assert.That(textarea.GetAttribute("value"), Is.EqualTo(cheesey));
}
[Test]
@@ -134,7 +134,7 @@ public void ShouldSubmitAFormUsingTheNewlineLiteral()
input.SendKeys("\n");
WaitFor(TitleToBe("We Arrive Here"), "Browser title is not 'We Arrive Here'");
- Assert.AreEqual("We Arrive Here", driver.Title);
+ Assert.That(driver.Title, Is.EqualTo("We Arrive Here"));
Assert.That(driver.Url, Does.EndWith("?x=name"));
}
@@ -147,7 +147,7 @@ public void ShouldSubmitAFormUsingTheEnterKey()
input.SendKeys(Keys.Enter);
WaitFor(TitleToBe("We Arrive Here"), "Browser title is not 'We Arrive Here'");
- Assert.AreEqual("We Arrive Here", driver.Title);
+ Assert.That(driver.Title, Is.EqualTo("We Arrive Here"));
Assert.That(driver.Url, Does.EndWith("?x=name"));
}
@@ -157,14 +157,14 @@ public void ShouldEnterDataIntoFormFields()
driver.Url = xhtmlTestPage;
IWebElement element = driver.FindElement(By.XPath("//form[@name='someForm']/input[@id='username']"));
String originalValue = element.GetAttribute("value");
- Assert.AreEqual(originalValue, "change");
+ Assert.That(originalValue, Is.EqualTo("change"));
element.Clear();
element.SendKeys("some text");
element = driver.FindElement(By.XPath("//form[@name='someForm']/input[@id='username']"));
String newFormValue = element.GetAttribute("value");
- Assert.AreEqual(newFormValue, "some text");
+ Assert.That(newFormValue, Is.EqualTo("some text"));
}
[Test]
@@ -173,7 +173,7 @@ public void ShouldBeAbleToAlterTheContentsOfAFileUploadInputElement()
string testFileName = string.Format("test-{0}.txt", Guid.NewGuid().ToString("D"));
driver.Url = formsPage;
IWebElement uploadElement = driver.FindElement(By.Id("upload"));
- Assert.That(uploadElement.GetAttribute("value"), Is.Null.Or.EqualTo(string.Empty));
+ Assert.That(uploadElement.GetAttribute("value"), Is.Null.Or.Empty);
string filePath = System.IO.Path.Combine(EnvironmentManager.Instance.CurrentDirectory, testFileName);
System.IO.FileInfo inputFile = new System.IO.FileInfo(filePath);
@@ -201,7 +201,7 @@ public void ShouldBeAbleToSendKeysToAFileUploadInputElementInAnXhtmlDocument()
driver.Url = xhtmlFormPage;
IWebElement uploadElement = driver.FindElement(By.Id("file"));
- Assert.AreEqual(string.Empty, uploadElement.GetAttribute("value"));
+ Assert.That(uploadElement.GetAttribute("value"), Is.Empty);
string testFileName = string.Format("test-{0}.txt", Guid.NewGuid().ToString("D"));
string filePath = System.IO.Path.Combine(EnvironmentManager.Instance.CurrentDirectory, testFileName);
@@ -214,7 +214,7 @@ public void ShouldBeAbleToSendKeysToAFileUploadInputElementInAnXhtmlDocument()
string uploadElementValue = uploadElement.GetAttribute("value");
System.IO.FileInfo outputFile = new System.IO.FileInfo(uploadElementValue.Replace('\\', System.IO.Path.DirectorySeparatorChar));
- Assert.AreEqual(inputFile.Name, outputFile.Name);
+ Assert.That(outputFile.Name, Is.EqualTo(inputFile.Name));
inputFile.Delete();
}
@@ -253,11 +253,11 @@ public void SendingKeyboardEventsShouldAppendTextInInputs()
IWebElement element = driver.FindElement(By.Id("working"));
element.SendKeys("Some");
String value = element.GetAttribute("value");
- Assert.AreEqual(value, "Some");
+ Assert.That(value, Is.EqualTo("Some"));
element.SendKeys(" text");
value = element.GetAttribute("value");
- Assert.AreEqual(value, "Some text");
+ Assert.That(value, Is.EqualTo("Some text"));
}
[Test]
@@ -268,7 +268,7 @@ public void SendingKeyboardEventsShouldAppendTextInInputsWithExistingValue()
element.SendKeys(". Some text");
string value = element.GetAttribute("value");
- Assert.AreEqual("Example text. Some text", value);
+ Assert.That(value, Is.EqualTo("Example text. Some text"));
}
[Test]
@@ -280,7 +280,7 @@ public void SendingKeyboardEventsShouldAppendTextInTextAreas()
element.SendKeys(". Some text");
String value = element.GetAttribute("value");
- Assert.AreEqual(value, "Example text. Some text");
+ Assert.That(value, Is.EqualTo("Example text. Some text"));
}
[Test]
@@ -288,10 +288,10 @@ public void EmptyTextBoxesShouldReturnAnEmptyStringNotNull()
{
driver.Url = formsPage;
IWebElement emptyTextBox = driver.FindElement(By.Id("working"));
- Assert.AreEqual(emptyTextBox.GetAttribute("value"), "");
+ Assert.That(emptyTextBox.GetAttribute("value"), Is.Empty);
IWebElement emptyTextArea = driver.FindElement(By.Id("emptyTextArea"));
- Assert.AreEqual(emptyTextBox.GetAttribute("value"), "");
+ Assert.That(emptyTextBox.GetAttribute("value"), Is.Empty);
}
[Test]
@@ -316,7 +316,7 @@ public void HandleFormWithJavascriptAction()
string text = alert.Text;
alert.Dismiss();
- Assert.AreEqual("Tasty cheese", text);
+ Assert.That(text, Is.EqualTo("Tasty cheese"));
}
[Test]
@@ -391,12 +391,12 @@ public void ShouldBeAbleToClearTextFromInputElements()
IWebElement element = driver.FindElement(By.Id("working"));
element.SendKeys("Some text");
String value = element.GetAttribute("value");
- Assert.That(value.Length, Is.GreaterThan(0));
+ Assert.That(value, Is.Not.Empty);
element.Clear();
value = element.GetAttribute("value");
- Assert.That(value.Length, Is.EqualTo(0));
+ Assert.That(value, Is.Empty);
}
[Test]
@@ -406,12 +406,12 @@ public void ShouldBeAbleToClearTextFromTextAreas()
IWebElement element = driver.FindElement(By.Id("withText"));
element.SendKeys("Some text");
String value = element.GetAttribute("value");
- Assert.That(value.Length, Is.GreaterThan(0));
+ Assert.That(value, Is.Not.Empty);
element.Clear();
value = element.GetAttribute("value");
- Assert.That(value.Length, Is.EqualTo(0));
+ Assert.That(value, Is.Empty);
}
private void CheckSubmitButton(string buttonId)
@@ -424,7 +424,7 @@ private void CheckSubmitButton(string buttonId)
WaitFor(TitleToBe("Submitted Successfully!"), "Browser title is not 'Submitted Successfully!'");
- Assert.That(driver.Url.Contains("name=" + name), "URL does not contain 'name=" + name + "'. Actual URL:" + driver.Url);
+ Assert.That(driver.Url, Does.Contain("name=" + name), "URL does not contain 'name=" + name + "'. Actual URL:" + driver.Url);
}
private Func TitleToBe(string desiredTitle)
diff --git a/dotnet/test/common/FrameSwitchingTest.cs b/dotnet/test/common/FrameSwitchingTest.cs
index a5e9777e2f48a..cd23b0c0bbbed 100644
--- a/dotnet/test/common/FrameSwitchingTest.cs
+++ b/dotnet/test/common/FrameSwitchingTest.cs
@@ -84,7 +84,7 @@ public void ShouldBeAbleToSwitchToAFrameByItsIndex()
driver.Url = framesetPage;
driver.SwitchTo().Frame(1);
- Assert.AreEqual("2", driver.FindElement(By.Id("pageNumber")).Text);
+ Assert.That(driver.FindElement(By.Id("pageNumber")).Text, Is.EqualTo("2"));
}
[Test]
@@ -93,7 +93,7 @@ public void ShouldBeAbleToSwitchToAnIframeByItsIndex()
driver.Url = iframePage;
driver.SwitchTo().Frame(0);
- Assert.AreEqual("name", driver.FindElement(By.Name("id-name1")).GetAttribute("value"));
+ Assert.That(driver.FindElement(By.Name("id-name1")).GetAttribute("value"), Is.EqualTo("name"));
}
[Test]
@@ -101,7 +101,7 @@ public void ShouldBeAbleToSwitchToAFrameByItsName()
{
driver.Url = framesetPage;
driver.SwitchTo().Frame("fourth");
- Assert.AreEqual("child1", driver.FindElement(By.TagName("frame")).GetAttribute("name"));
+ Assert.That(driver.FindElement(By.TagName("frame")).GetAttribute("name"), Is.EqualTo("child1"));
}
@@ -110,7 +110,7 @@ public void ShouldBeAbleToSwitchToAnIframeByItsName()
{
driver.Url = iframePage;
driver.SwitchTo().Frame("iframe1-name");
- Assert.AreEqual("name", driver.FindElement(By.Name("id-name1")).GetAttribute("value"));
+ Assert.That(driver.FindElement(By.Name("id-name1")).GetAttribute("value"), Is.EqualTo("name"));
}
@@ -119,7 +119,7 @@ public void ShouldBeAbleToSwitchToAFrameByItsID()
{
driver.Url = framesetPage;
driver.SwitchTo().Frame("fifth");
- Assert.AreEqual("Open new window", driver.FindElement(By.Name("windowOne")).Text);
+ Assert.That(driver.FindElement(By.Name("windowOne")).Text, Is.EqualTo("Open new window"));
}
@@ -128,7 +128,7 @@ public void ShouldBeAbleToSwitchToAnIframeByItsID()
{
driver.Url = iframePage;
driver.SwitchTo().Frame("iframe1");
- Assert.AreEqual("name", driver.FindElement(By.Name("id-name1")).GetAttribute("value"));
+ Assert.That(driver.FindElement(By.Name("id-name1")).GetAttribute("value"), Is.EqualTo("name"));
}
[Test]
@@ -145,7 +145,7 @@ public void ShouldBeAbleToSwitchToAFrameUsingAPreviouslyLocatedWebElement()
driver.Url = framesetPage;
IWebElement frame = driver.FindElement(By.TagName("frame"));
driver.SwitchTo().Frame(frame);
- Assert.AreEqual("1", driver.FindElement(By.Id("pageNumber")).Text);
+ Assert.That(driver.FindElement(By.Id("pageNumber")).Text, Is.EqualTo("1"));
}
[Test]
@@ -154,7 +154,7 @@ public void ShouldBeAbleToSwitchToAnIFrameUsingAPreviouslyLocatedWebElement()
driver.Url = iframePage;
IWebElement frame = driver.FindElement(By.TagName("iframe"));
driver.SwitchTo().Frame(frame);
- Assert.AreEqual("name", driver.FindElement(By.Name("id-name1")).GetAttribute("value"));
+ Assert.That(driver.FindElement(By.Name("id-name1")).GetAttribute("value"), Is.EqualTo("name"));
}
@@ -173,7 +173,7 @@ public void FrameSearchesShouldBeRelativeToTheCurrentlySelectedFrame()
IWebElement frameElement = WaitFor(() => driver.FindElement(By.Name("second")), "did not find frame");
driver.SwitchTo().Frame(frameElement);
- Assert.AreEqual("2", driver.FindElement(By.Id("pageNumber")).Text);
+ Assert.That(driver.FindElement(By.Id("pageNumber")).Text, Is.EqualTo("2"));
Assert.That(
() => driver.SwitchTo().Frame("third"),
@@ -188,7 +188,7 @@ public void FrameSearchesShouldBeRelativeToTheCurrentlySelectedFrame()
driver.SwitchTo().DefaultContent();
driver.SwitchTo().Frame("second");
- Assert.AreEqual("2", driver.FindElement(By.Id("pageNumber")).Text);
+ Assert.That(driver.FindElement(By.Id("pageNumber")).Text, Is.EqualTo("2"));
}
[Test]
@@ -196,7 +196,7 @@ public void ShouldSelectChildFramesByChainedCalls()
{
driver.Url = framesetPage;
driver.SwitchTo().Frame("fourth").SwitchTo().Frame("child2");
- Assert.AreEqual("11", driver.FindElement(By.Id("pageNumber")).Text);
+ Assert.That(driver.FindElement(By.Id("pageNumber")).Text, Is.EqualTo("11"));
}
[Test]
@@ -235,7 +235,7 @@ public void ShouldBeAbleToSwitchToParentFrame()
{
driver.Url = framesetPage;
driver.SwitchTo().Frame("fourth").SwitchTo().ParentFrame().SwitchTo().Frame("first");
- Assert.AreEqual("1", driver.FindElement(By.Id("pageNumber")).Text);
+ Assert.That(driver.FindElement(By.Id("pageNumber")).Text, Is.EqualTo("1"));
}
[Test]
@@ -244,7 +244,7 @@ public void ShouldBeAbleToSwitchToParentFrameFromASecondLevelFrame()
driver.Url = framesetPage;
driver.SwitchTo().Frame("fourth").SwitchTo().Frame("child1").SwitchTo().ParentFrame().SwitchTo().Frame("child2");
- Assert.AreEqual("11", driver.FindElement(By.Id("pageNumber")).Text);
+ Assert.That(driver.FindElement(By.Id("pageNumber")).Text, Is.EqualTo("11"));
}
[Test]
@@ -252,7 +252,7 @@ public void SwitchingToParentFrameFromDefaultContextIsNoOp()
{
driver.Url = xhtmlTestPage;
driver.SwitchTo().ParentFrame();
- Assert.AreEqual("XHTML Test Page", driver.Title);
+ Assert.That(driver.Title, Is.EqualTo("XHTML Test Page"));
}
[Test]
@@ -291,7 +291,7 @@ public void ShouldFocusOnTheReplacementWhenAFrameFollowsALinkToA_TopTargettedPag
driver.FindElement(By.LinkText("top")).Click();
WaitFor(() => { return driver.Title == "XHTML Test Page"; }, "Browser title was not 'XHTML Test Page'");
- Assert.AreEqual("XHTML Test Page", driver.Title);
+ Assert.That(driver.Title, Is.EqualTo("XHTML Test Page"));
}
[Test]
@@ -314,7 +314,7 @@ public void ShouldAllowTheUserToSwitchToAnIFrameAndRemainFocusedOnIt()
driver.FindElement(By.Id("submitButton")).Click();
string hello = GetTextOfGreetingElement();
- Assert.AreEqual(hello, "Success!");
+ Assert.That(hello, Is.EqualTo("Success!"));
}
[Test]
@@ -327,11 +327,11 @@ public void ShouldBeAbleToClickInAFrame()
driver.FindElement(By.Id("submitButton")).Click();
// driver should still be focused on frame "third" ...
- Assert.AreEqual("Success!", GetTextOfGreetingElement());
+ Assert.That(GetTextOfGreetingElement(), Is.EqualTo("Success!"));
// Make sure it was really frame "third" which was replaced ...
driver.SwitchTo().DefaultContent().SwitchTo().Frame("third");
- Assert.AreEqual("Success!", GetTextOfGreetingElement());
+ Assert.That(GetTextOfGreetingElement(), Is.EqualTo("Success!"));
}
[Test]
@@ -354,11 +354,11 @@ public void ShouldBeAbleToClickInASubFrame()
driver.FindElement(By.Id("submitButton")).Click();
// driver should still be focused on frame "iframe1" inside frame "sixth" ...
- Assert.AreEqual("Success!", GetTextOfGreetingElement());
+ Assert.That(GetTextOfGreetingElement(), Is.EqualTo("Success!"));
// Make sure it was really frame "iframe1" inside frame "sixth" which was replaced ...
driver.SwitchTo().DefaultContent().SwitchTo().Frame("sixth").SwitchTo().Frame("iframe1");
- Assert.AreEqual("Success!", driver.FindElement(By.Id("greeting")).Text);
+ Assert.That(driver.FindElement(By.Id("greeting")).Text, Is.EqualTo("Success!"));
}
[Test]
@@ -377,21 +377,21 @@ public void ShouldBeAbleToFindElementsInIframesByXPath()
public void GetCurrentUrlShouldReturnTopLevelBrowsingContextUrl()
{
driver.Url = framesetPage;
- Assert.AreEqual(framesetPage, driver.Url);
+ Assert.That(driver.Url, Is.EqualTo(framesetPage));
driver.SwitchTo().Frame("second");
- Assert.AreEqual(framesetPage, driver.Url);
+ Assert.That(driver.Url, Is.EqualTo(framesetPage));
}
[Test]
public void GetCurrentUrlShouldReturnTopLevelBrowsingContextUrlForIframes()
{
driver.Url = iframePage;
- Assert.AreEqual(iframePage, driver.Url);
+ Assert.That(driver.Url, Is.EqualTo(iframePage));
driver.SwitchTo().Frame("iframe1");
- Assert.AreEqual(iframePage, driver.Url);
+ Assert.That(driver.Url, Is.EqualTo(iframePage));
}
[Test]
@@ -476,7 +476,7 @@ public void ShouldReturnWindowTitleInAFrameset()
{
driver.Url = framesetPage;
driver.SwitchTo().Frame("third");
- Assert.AreEqual("Unique title", driver.Title);
+ Assert.That(driver.Title, Is.EqualTo("Unique title"));
}
[Test]
@@ -518,7 +518,7 @@ public void ShouldNotSwitchMagicallyToTheTopWindow()
{
url = url.Substring(0, url.Length - 1);
}
- Assert.AreEqual(baseUrl + "bug4876_iframe.html", url);
+ Assert.That(url, Is.EqualTo(baseUrl + "bug4876_iframe.html"));
}
}
}
@@ -557,13 +557,13 @@ public void ShouldBeAbleToSelectAFrameByName()
driver.Url = framesetPage;
driver.SwitchTo().Frame("second");
- Assert.AreEqual(driver.FindElement(By.Id("pageNumber")).Text, "2");
+ Assert.That(driver.FindElement(By.Id("pageNumber")).Text, Is.EqualTo("2"));
driver.SwitchTo().DefaultContent().SwitchTo().Frame("third");
driver.FindElement(By.Id("changeme")).Click();
driver.SwitchTo().DefaultContent().SwitchTo().Frame("second");
- Assert.AreEqual(driver.FindElement(By.Id("pageNumber")).Text, "2");
+ Assert.That(driver.FindElement(By.Id("pageNumber")).Text, Is.EqualTo("2"));
}
[Test]
diff --git a/dotnet/test/common/GetLogsTest.cs b/dotnet/test/common/GetLogsTest.cs
index 59e28ba091aa3..79524819f2e7e 100644
--- a/dotnet/test/common/GetLogsTest.cs
+++ b/dotnet/test/common/GetLogsTest.cs
@@ -89,7 +89,7 @@ public void TurningOffLogShouldMeanNoLogMessages()
{
CreateWebDriverWithLogging(logType, LogLevel.Off);
ReadOnlyCollection entries = localDriver.Manage().Logs.GetLog(logType);
- Assert.AreEqual(0, entries.Count, string.Format("There should be no log entries for log type {0} when logging is turned off.", logType));
+ Assert.That(entries, Is.Empty, string.Format("There should be no log entries for log type {0} when logging is turned off.", logType));
QuitDriver();
}
}
diff --git a/dotnet/test/common/GetMultipleAttributeTest.cs b/dotnet/test/common/GetMultipleAttributeTest.cs
index 48e441b50d4e5..26cf57d4813c1 100644
--- a/dotnet/test/common/GetMultipleAttributeTest.cs
+++ b/dotnet/test/common/GetMultipleAttributeTest.cs
@@ -37,7 +37,7 @@ public void MultipleAttributeShouldBeTrueWhenSet()
{
driver.Url = selectPage;
IWebElement element = driver.FindElement(By.Id("selectWithMultipleEqualsMultiple"));
- Assert.AreEqual("true", element.GetAttribute("multiple"));
+ Assert.That(element.GetAttribute("multiple"), Is.EqualTo("true"));
}
[Test]
@@ -45,7 +45,7 @@ public void MultipleAttributeShouldBeTrueWhenSelectHasMutilpeWithValueAsBlank()
{
driver.Url = selectPage;
IWebElement element = driver.FindElement(By.Id("selectWithEmptyStringMultiple"));
- Assert.AreEqual("true", element.GetAttribute("multiple"));
+ Assert.That(element.GetAttribute("multiple"), Is.EqualTo("true"));
}
[Test]
@@ -53,7 +53,7 @@ public void MultipleAttributeShouldBeTrueWhenSelectHasMutilpeWithoutAValue()
{
driver.Url = selectPage;
IWebElement element = driver.FindElement(By.Id("selectWithMultipleWithoutValue"));
- Assert.AreEqual("true", element.GetAttribute("multiple"));
+ Assert.That(element.GetAttribute("multiple"), Is.EqualTo("true"));
}
[Test]
@@ -61,7 +61,7 @@ public void MultipleAttributeShouldBeTrueWhenSelectHasMutilpeWithValueAsSomethin
{
driver.Url = selectPage;
IWebElement element = driver.FindElement(By.Id("selectWithRandomMultipleValue"));
- Assert.AreEqual("true", element.GetAttribute("multiple"));
+ Assert.That(element.GetAttribute("multiple"), Is.EqualTo("true"));
}
}
}
diff --git a/dotnet/test/common/I18Test.cs b/dotnet/test/common/I18Test.cs
index 9c115b89b6dd9..eeed6e357e5c8 100644
--- a/dotnet/test/common/I18Test.cs
+++ b/dotnet/test/common/I18Test.cs
@@ -49,7 +49,7 @@ public void ShouldBeAbleToEnterHebrewTextFromLeftToRight()
input.SendKeys(shalom);
- Assert.AreEqual(shalom, input.GetAttribute("value"));
+ Assert.That(input.GetAttribute("value"), Is.EqualTo(shalom));
}
[Test]
@@ -60,7 +60,7 @@ public void ShouldBeAbleToEnterHebrewTextFromRightToLeft()
input.SendKeys(tmunot);
- Assert.AreEqual(tmunot, input.GetAttribute("value"));
+ Assert.That(input.GetAttribute("value"), Is.EqualTo(tmunot));
}
[Test]
@@ -86,7 +86,7 @@ public void ShouldBeAbleToEnterSupplementaryCharacters()
IWebElement el = driver.FindElement(By.Name("i18n"));
el.SendKeys(input);
- Assert.AreEqual(input, el.GetAttribute("value"));
+ Assert.That(el.GetAttribute("value"), Is.EqualTo(input));
}
[Test]
@@ -98,7 +98,7 @@ public void ShouldBeAbleToReturnTheTextInAPage()
string text = driver.FindElement(By.TagName("body")).Text;
- Assert.AreEqual(shalom, text);
+ Assert.That(text, Is.EqualTo(shalom));
}
}
}
diff --git a/dotnet/test/common/ImplicitWaitTest.cs b/dotnet/test/common/ImplicitWaitTest.cs
index fc55cb7fbd153..4c6f6592abd54 100644
--- a/dotnet/test/common/ImplicitWaitTest.cs
+++ b/dotnet/test/common/ImplicitWaitTest.cs
@@ -86,7 +86,7 @@ public void ShouldStillFailToFindElementsWhenImplicitWaitsAreEnabled()
driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromMilliseconds(500);
ReadOnlyCollection elements = driver.FindElements(By.ClassName("redbox"));
- Assert.AreEqual(0, elements.Count);
+ Assert.That(elements, Is.Empty);
}
[Test]
@@ -99,7 +99,7 @@ public void ShouldReturnAfterFirstAttemptToFindManyAfterDisablingImplicitWaits()
driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromMilliseconds(0);
add.Click();
ReadOnlyCollection elements = driver.FindElements(By.ClassName("redbox"));
- Assert.AreEqual(0, elements.Count);
+ Assert.That(elements, Is.Empty);
}
[Test]
diff --git a/dotnet/test/common/Interactions/ActionBuilderTest.cs b/dotnet/test/common/Interactions/ActionBuilderTest.cs
index a762bc92639d2..d7acb6a95888f 100644
--- a/dotnet/test/common/Interactions/ActionBuilderTest.cs
+++ b/dotnet/test/common/Interactions/ActionBuilderTest.cs
@@ -19,7 +19,6 @@
using NUnit.Framework;
using System;
-using System.Collections;
using System.Collections.Generic;
namespace OpenQA.Selenium.Interactions
@@ -52,11 +51,12 @@ public void OutputsPointerEventsToDictionary()
var dictionary = sequence[0].ToDictionary();
Console.WriteLine(dictionary);
- Assert.AreEqual("pointer", dictionary["type"]);
- Assert.NotNull(dictionary["id"]);
- Assert.NotNull(dictionary["parameters"]);
+ Assert.That(dictionary, Does.ContainKey("type").WithValue("pointer"));
+ Assert.That(dictionary["id"], Is.Not.Null);
+ Assert.That(dictionary["parameters"], Is.Not.Null);
+
var parameters = new Dictionary { { "pointerType", "pen" } };
- CollectionAssert.AreEquivalent(parameters, (IEnumerable)dictionary["parameters"]);
+ Assert.That(dictionary["parameters"], Is.EquivalentTo(parameters));
var events = new Dictionary
{
@@ -72,8 +72,8 @@ public void OutputsPointerEventsToDictionary()
{"type", "pointerDown"},
{"button", 0}
};
- var actions = (IList)dictionary["actions"];
- CollectionAssert.AreEquivalent(events, (IEnumerable)actions[0]);
+ var actions = (IList)dictionary["actions"];
+ Assert.That(actions[0], Is.EquivalentTo(events));
}
}
}
diff --git a/dotnet/test/common/Interactions/BasicKeyboardInterfaceTest.cs b/dotnet/test/common/Interactions/BasicKeyboardInterfaceTest.cs
index 88f148ca1cf3d..88c235a5a19b8 100644
--- a/dotnet/test/common/Interactions/BasicKeyboardInterfaceTest.cs
+++ b/dotnet/test/common/Interactions/BasicKeyboardInterfaceTest.cs
@@ -58,7 +58,7 @@ public void ShouldSetActiveKeyboard()
KeyInputDevice device = actionProvider.GetActiveKeyboard();
- Assert.AreEqual("test keyboard", device.DeviceName);
+ Assert.That(device.DeviceName, Is.EqualTo("test keyboard"));
}
[Test]
@@ -77,7 +77,7 @@ public void ShouldAllowBasicKeyboardInput()
sendLowercase.Perform();
- Assert.AreEqual("abc def", keyReporter.GetAttribute("value"));
+ Assert.That(keyReporter.GetAttribute("value"), Is.EqualTo("abc def"));
}
@@ -154,7 +154,7 @@ public void ShouldAllowSendingKeysWithShiftPressed()
AssertThatFormEventsFiredAreExactly("focus keydown keydown keypress keyup keydown keypress keyup keyup");
- Assert.AreEqual("AB", keysEventInput.GetAttribute("value"));
+ Assert.That(keysEventInput.GetAttribute("value"), Is.EqualTo("AB"));
}
[Test]
@@ -333,12 +333,12 @@ public void ShouldAllowSendingKeysWithLeftShiftPressed()
AssertThatFormEventsFiredAreExactly("focus keydown keydown keypress keyup keydown keypress keyup keyup");
- Assert.AreEqual("AB", keysEventInput.GetAttribute("value"));
+ Assert.That(keysEventInput.GetAttribute("value"), Is.EqualTo("AB"));
}
private void AssertThatFormEventsFiredAreExactly(string message, string expected)
{
- Assert.AreEqual(expected, driver.FindElement(By.Id("result")).Text.Trim(), message);
+ Assert.That(driver.FindElement(By.Id("result")).Text.Trim(), Is.EqualTo(expected), message);
}
private void AssertThatFormEventsFiredAreExactly(string expected)
@@ -348,7 +348,7 @@ private void AssertThatFormEventsFiredAreExactly(string expected)
private void AssertThatBodyEventsFiredAreExactly(string expected)
{
- Assert.AreEqual(expected, driver.FindElement(By.Id("body_result")).Text.Trim());
+ Assert.That(driver.FindElement(By.Id("body_result")).Text.Trim(), Is.EqualTo(expected));
}
private Func BackgroundColorToChangeFrom(IWebElement element, Color currentColor)
diff --git a/dotnet/test/common/Interactions/BasicMouseInterfaceTest.cs b/dotnet/test/common/Interactions/BasicMouseInterfaceTest.cs
index f88252cc4d1a9..41ffa4812164f 100644
--- a/dotnet/test/common/Interactions/BasicMouseInterfaceTest.cs
+++ b/dotnet/test/common/Interactions/BasicMouseInterfaceTest.cs
@@ -45,7 +45,7 @@ public void ShouldSetActivePointer()
PointerInputDevice device = actionProvider.GetActivePointer();
- Assert.AreEqual("test mouse", device.DeviceName);
+ Assert.That(device.DeviceName, Is.EqualTo("test mouse"));
}
[Test]
@@ -53,7 +53,7 @@ public void ShouldAllowDraggingElementWithMouseMovesItToAnotherList()
{
PerformDragAndDropWithMouse();
IWebElement dragInto = driver.FindElement(By.Id("sortable1"));
- Assert.AreEqual(6, dragInto.FindElements(By.TagName("li")).Count);
+ Assert.That(dragInto.FindElements(By.TagName("li")), Has.Exactly(6).Items);
}
// This test is very similar to DraggingElementWithMouse. The only
@@ -116,7 +116,7 @@ public void ShouldAllowDragAndDrop()
dropInto = driver.FindElement(By.Id("droppable"));
string text = dropInto.FindElement(By.TagName("p")).Text;
- Assert.AreEqual("Dropped!", text);
+ Assert.That(text, Is.EqualTo("Dropped!"));
}
[Test]
@@ -130,7 +130,7 @@ public void ShouldAllowDoubleClick()
IAction dblClick = actionProvider.DoubleClick(toDoubleClick).Build();
dblClick.Perform();
- Assert.AreEqual("DoubleClicked", toDoubleClick.GetAttribute("value"));
+ Assert.That(toDoubleClick.GetAttribute("value"), Is.EqualTo("DoubleClicked"));
}
[Test]
@@ -144,7 +144,7 @@ public void ShouldAllowContextClick()
IAction contextClick = actionProvider.ContextClick(toContextClick).Build();
contextClick.Perform();
- Assert.AreEqual("ContextClicked", toContextClick.GetAttribute("value"));
+ Assert.That(toContextClick.GetAttribute("value"), Is.EqualTo("ContextClicked"));
}
[Test]
@@ -159,7 +159,7 @@ public void ShouldAllowMoveAndClick()
IAction contextClick = actionProvider.MoveToElement(toClick).Click().Build();
contextClick.Perform();
- Assert.AreEqual("Clicked", toClick.GetAttribute("value"), "Value should change to Clicked.");
+ Assert.That(toClick.GetAttribute("value"), Is.EqualTo("Clicked"), "Value should change to Clicked.");
}
[Test]
@@ -175,8 +175,8 @@ public void ShouldMoveToLocation()
IWebElement location = driver.FindElement(By.Id("absolute-location"));
var coordinates = location.Text.Split(',');
- Assert.AreEqual("100", coordinates[0].Trim());
- Assert.AreEqual("200", coordinates[1].Trim());
+ Assert.That(coordinates[0].Trim(), Is.EqualTo("100"));
+ Assert.That(coordinates[1].Trim(), Is.EqualTo("200"));
}
[Test]
@@ -286,14 +286,14 @@ public void ShouldAllowUsersToHoverOverElements()
}
IWebElement item = driver.FindElement(By.Id("item1"));
- Assert.AreEqual("", item.Text);
+ Assert.That(item.Text, Is.EqualTo(""));
((IJavaScriptExecutor)driver).ExecuteScript("arguments[0].style.background = 'green'", element);
Actions actionBuilder = new Actions(driver);
actionBuilder.MoveToElement(element).Perform();
item = driver.FindElement(By.Id("item1"));
- Assert.AreEqual("Item 1", item.Text);
+ Assert.That(item.Text, Is.EqualTo("Item 1"));
}
[Test]
@@ -307,7 +307,7 @@ public void HoverPersists()
IWebElement element = driver.FindElement(By.Id("menu1"));
IWebElement item = driver.FindElement(By.Id("item1"));
- Assert.AreEqual(string.Empty, item.Text);
+ Assert.That(item.Text, Is.Empty);
((IJavaScriptExecutor)driver).ExecuteScript("arguments[0].style.background = 'green'", element);
new Actions(driver).MoveToElement(element).Perform();
@@ -317,7 +317,7 @@ public void HoverPersists()
WaitFor(ElementTextToNotEqual(item, ""), "Element text was empty after timeout");
- Assert.AreEqual("Item 1", item.Text);
+ Assert.That(item.Text, Is.EqualTo("Item 1"));
}
[Test]
@@ -462,7 +462,7 @@ private void PerformDragAndDropWithMouse()
IAction drop = new Actions(driver).Release(dragInto).Build();
- Assert.AreEqual("Nothing happened.", dragReporter.Text);
+ Assert.That(dragReporter.Text, Is.EqualTo("Nothing happened."));
holdItem.Perform();
moveToSpecificItem.Perform();
diff --git a/dotnet/test/common/Interactions/BasicWheelInterfaceTest.cs b/dotnet/test/common/Interactions/BasicWheelInterfaceTest.cs
index f46cb647dc510..38ef28a7a8fcd 100644
--- a/dotnet/test/common/Interactions/BasicWheelInterfaceTest.cs
+++ b/dotnet/test/common/Interactions/BasicWheelInterfaceTest.cs
@@ -46,7 +46,7 @@ public void ShouldSetActiveWheel()
WheelInputDevice device = actionProvider.GetActiveWheel();
- Assert.AreEqual("test wheel", device.DeviceName);
+ Assert.That(device.DeviceName, Is.EqualTo("test wheel"));
}
[Test]
@@ -56,11 +56,11 @@ public void ShouldAllowScrollingToAnElement()
driver.Url = scrollFrameOutOfViewport;
IWebElement iframe = driver.FindElement(By.TagName("iframe"));
- Assert.IsFalse(IsInViewport(iframe));
+ Assert.That(IsInViewport(iframe), Is.False);
new Actions(driver).ScrollToElement(iframe).Build().Perform();
- Assert.IsTrue(IsInViewport(iframe));
+ Assert.That(IsInViewport(iframe), Is.True);
}
[Test]
@@ -78,7 +78,7 @@ public void ShouldScrollFromElementByGivenAmount()
driver.SwitchTo().Frame(iframe);
IWebElement checkbox = driver.FindElement(By.Name("scroll_checkbox"));
- Assert.IsTrue(IsInViewport(checkbox));
+ Assert.That(IsInViewport(checkbox), Is.True);
}
[Test]
@@ -99,7 +99,7 @@ public void ShouldAllowScrollingFromElementByGivenAmountWithOffset()
IWebElement iframe = driver.FindElement(By.TagName("iframe"));
driver.SwitchTo().Frame(iframe);
IWebElement checkbox = driver.FindElement(By.Name("scroll_checkbox"));
- Assert.IsTrue(IsInViewport(checkbox));
+ Assert.That(IsInViewport(checkbox), Is.True);
}
[Test]
@@ -128,7 +128,7 @@ public void ShouldAllowScrollingFromViewportByGivenAmount()
new Actions(driver).ScrollByAmount(0, deltaY).Build().Perform();
- Assert.IsTrue(IsInViewport(footer));
+ Assert.That(IsInViewport(footer), Is.True);
}
[Test]
@@ -147,7 +147,7 @@ public void ShouldAllowScrollingFromViewportByGivenAmountFromOrigin()
IWebElement iframe = driver.FindElement(By.TagName("iframe"));
driver.SwitchTo().Frame(iframe);
IWebElement checkbox = driver.FindElement(By.Name("scroll_checkbox"));
- Assert.IsTrue(IsInViewport(checkbox));
+ Assert.That(IsInViewport(checkbox), Is.True);
}
[Test]
diff --git a/dotnet/test/common/Interactions/CombinedInputActionsTest.cs b/dotnet/test/common/Interactions/CombinedInputActionsTest.cs
index 9133254c209c5..9fcb0d42422c7 100644
--- a/dotnet/test/common/Interactions/CombinedInputActionsTest.cs
+++ b/dotnet/test/common/Interactions/CombinedInputActionsTest.cs
@@ -70,7 +70,7 @@ public void PlainClickingOnMultiSelectionList()
showButton.Click();
IWebElement resultElement = driver.FindElement(By.Id("result"));
- Assert.AreEqual("cheddar", resultElement.Text, "Should have picked the third option only.");
+ Assert.That(resultElement.Text, Is.EqualTo("cheddar"), "Should have picked the third option only.");
}
[Test]
@@ -94,7 +94,7 @@ public void ShouldAllowSettingActivePointerWithKeyBoardActions()
loginAction.Perform();
IAlert alert = driver.SwitchTo().Alert();
- Assert.AreEqual("You have successfully logged in.", alert.Text);
+ Assert.That(alert.Text, Is.EqualTo("You have successfully logged in."));
alert.Accept();
}
@@ -120,7 +120,7 @@ public void ShiftClickingOnMultiSelectionList()
showButton.Click();
IWebElement resultElement = driver.FindElement(By.Id("result"));
- Assert.AreEqual("roquefort parmigiano cheddar", resultElement.Text, "Should have picked the last three options.");
+ Assert.That(resultElement.Text, Is.EqualTo("roquefort parmigiano cheddar"), "Should have picked the last three options.");
}
[Test]
@@ -149,7 +149,7 @@ public void ControlClickingOnMultiSelectionList()
showButton.Click();
IWebElement resultElement = driver.FindElement(By.Id("result"));
- Assert.AreEqual("roquefort cheddar", resultElement.Text, "Should have picked the first and third options.");
+ Assert.That(resultElement.Text, Is.EqualTo("roquefort cheddar"), "Should have picked the first and third options.");
}
[Test]
@@ -165,7 +165,7 @@ public void ControlClickingOnCustomMultiSelectionList()
IWebElement reportingElement = driver.FindElement(By.Id("infodiv"));
- Assert.AreEqual("no info", reportingElement.Text);
+ Assert.That(reportingElement.Text, Is.EqualTo("no info"));
ReadOnlyCollection listItems = driver.FindElements(By.TagName("li"));
@@ -177,11 +177,11 @@ public void ControlClickingOnCustomMultiSelectionList()
selectThreeItems.Perform();
- Assert.AreEqual("#item2 #item4 #item6", reportingElement.Text);
+ Assert.That(reportingElement.Text, Is.EqualTo("#item2 #item4 #item6"));
// Now click on another element, make sure that's the only one selected.
new Actions(driver).Click(listItems[6]).Build().Perform();
- Assert.AreEqual("#item7", reportingElement.Text);
+ Assert.That(reportingElement.Text, Is.EqualTo("#item7"));
}
[Test]
@@ -292,7 +292,7 @@ public void ChordControlCutAndPaste()
.SendKeys(element, "abc def")
.Perform();
- Assert.AreEqual("abc def", element.GetAttribute("value"));
+ Assert.That(element.GetAttribute("value"), Is.EqualTo("abc def"));
//TODO: Figure out why calling sendKey(Key.CONTROL + "a") and then
//sendKeys("x") does not work on Linux.
@@ -303,7 +303,7 @@ public void ChordControlCutAndPaste()
// Release keys before next step.
new Actions(driver).SendKeys(Keys.Null).Perform();
- Assert.AreEqual(string.Empty, element.GetAttribute("value"));
+ Assert.That(element.GetAttribute("value"), Is.Empty);
new Actions(driver).KeyDown(controlModifier)
.SendKeys("v")
@@ -312,7 +312,7 @@ public void ChordControlCutAndPaste()
new Actions(driver).SendKeys(Keys.Null).Perform();
- Assert.AreEqual("abc defabc def", element.GetAttribute("value"));
+ Assert.That(element.GetAttribute("value"), Is.EqualTo("abc defabc def"));
}
[Test]
@@ -331,8 +331,8 @@ public void CombiningShiftAndClickResultsInANewWindow()
.KeyUp(Keys.Shift)
.Perform();
WaitFor(() => { return driver.WindowHandles.Count > 1; }, "Did not receive new window");
- Assert.AreEqual(2, driver.WindowHandles.Count, "Should have opened a new window.");
- Assert.AreEqual(originalTitle, driver.Title, "Should not have navigated away.");
+ Assert.That(driver.WindowHandles, Has.Exactly(2).Items, "Should have opened a new window.");
+ Assert.That(driver.Title, Is.EqualTo(originalTitle), "Should not have navigated away.");
string originalHandle = driver.CurrentWindowHandle;
foreach (string newHandle in driver.WindowHandles)
@@ -358,7 +358,7 @@ public void HoldingDownShiftKeyWhileClicking()
new Actions(driver).MoveToElement(toClick).KeyDown(Keys.Shift).Click().KeyUp(Keys.Shift).Perform();
IWebElement shiftInfo = WaitFor(() => { return driver.FindElement(By.Id("shiftKey")); }, "Could not find element with id 'shiftKey'");
- Assert.AreEqual("true", shiftInfo.Text);
+ Assert.That(shiftInfo.Text, Is.EqualTo("true"));
}
[Test]
@@ -373,7 +373,7 @@ public void CanClickOnSuckerFishStyleMenu()
IWebElement element = driver.FindElement(By.Id("menu1"));
IWebElement target = driver.FindElement(By.Id("item1"));
- Assert.AreEqual(string.Empty, target.Text);
+ Assert.That(target.Text, Is.Empty);
((IJavaScriptExecutor)driver).ExecuteScript("arguments[0].style.background = 'green'", element);
new Actions(driver).MoveToElement(element).Build().Perform();
@@ -413,7 +413,7 @@ public void PerformsPause()
{
DateTime start = DateTime.Now;
new Actions(driver).Pause(TimeSpan.FromMilliseconds(1200)).Build().Perform();
- Assert.IsTrue(DateTime.Now - start > TimeSpan.FromMilliseconds(1200));
+ Assert.That(DateTime.Now - start > TimeSpan.FromMilliseconds(1200), Is.True);
}
[Test]
diff --git a/dotnet/test/common/Interactions/DragAndDropTest.cs b/dotnet/test/common/Interactions/DragAndDropTest.cs
index 87a900aefa86b..0eb0f98c03d5d 100644
--- a/dotnet/test/common/Interactions/DragAndDropTest.cs
+++ b/dotnet/test/common/Interactions/DragAndDropTest.cs
@@ -44,13 +44,13 @@ public void DragAndDropRelative()
driver.Url = dragAndDropPage;
IWebElement img = driver.FindElement(By.Id("test1"));
Point expectedLocation = Drag(img, img.Location, 150, 200);
- Assert.AreEqual(expectedLocation, img.Location);
+ Assert.That(img.Location, Is.EqualTo(expectedLocation));
expectedLocation = Drag(img, img.Location, -50, -25);
- Assert.AreEqual(expectedLocation, img.Location);
+ Assert.That(img.Location, Is.EqualTo(expectedLocation));
expectedLocation = Drag(img, img.Location, 0, 0);
- Assert.AreEqual(expectedLocation, img.Location);
+ Assert.That(img.Location, Is.EqualTo(expectedLocation));
expectedLocation = Drag(img, img.Location, 1, -1);
- Assert.AreEqual(expectedLocation, img.Location);
+ Assert.That(img.Location, Is.EqualTo(expectedLocation));
}
[Test]
@@ -61,7 +61,7 @@ public void DragAndDropToElement()
IWebElement img2 = driver.FindElement(By.Id("test2"));
Actions actionProvider = new Actions(driver);
actionProvider.DragAndDrop(img2, img1).Perform();
- Assert.AreEqual(img1.Location, img2.Location);
+ Assert.That(img2.Location, Is.EqualTo(img1.Location));
}
[Test]
@@ -87,7 +87,7 @@ public void DragAndDropToElementInIframe()
IWebElement img2 = driver.FindElement(By.Id("test2"));
new Actions(driver).DragAndDrop(img2, img1).Perform();
- Assert.AreEqual(img1.Location, img2.Location);
+ Assert.That(img2.Location, Is.EqualTo(img1.Location));
}
[Test]
@@ -103,7 +103,7 @@ public void DragAndDropElementWithOffsetInIframeAtBottom()
new Actions(driver).DragAndDropToOffset(img1, 20, 20).Perform();
initial.Offset(20, 20);
- Assert.AreEqual(initial, img1.Location);
+ Assert.That(img1.Location, Is.EqualTo(initial));
}
[Test]
@@ -126,7 +126,7 @@ public void DragAndDropElementWithOffsetInScrolledDiv()
new Actions(driver).DragAndDropToOffset(el, 3700, 3700).Perform();
initial.Offset(3700, 3700);
- Assert.AreEqual(initial, el.Location);
+ Assert.That(el.Location, Is.EqualTo(initial));
}
[Test]
@@ -137,7 +137,7 @@ public void ElementInDiv()
Point startLocation = img.Location;
Point expectedLocation = Drag(img, startLocation, 100, 100);
Point endLocation = img.Location;
- Assert.AreEqual(expectedLocation, endLocation);
+ Assert.That(endLocation, Is.EqualTo(expectedLocation));
}
[Test]
@@ -172,7 +172,7 @@ public void ShouldAllowUsersToDragAndDropToElementsOffTheCurrentViewPort()
driver.Url = dragAndDropPage;
IWebElement img = driver.FindElement(By.Id("test3"));
Point expectedLocation = Drag(img, img.Location, 100, 100);
- Assert.AreEqual(expectedLocation, img.Location);
+ Assert.That(img.Location, Is.EqualTo(expectedLocation));
}
finally
{
@@ -204,15 +204,15 @@ public void DragAndDropOnJQueryItems()
text = dropInto.FindElement(By.TagName("p")).Text;
}
- Assert.AreEqual("Dropped!", text);
+ Assert.That(text, Is.EqualTo("Dropped!"));
IWebElement reporter = driver.FindElement(By.Id("drop_reports"));
// Assert that only one mouse click took place and the mouse was moved
// during it.
string reporterText = reporter.Text;
Assert.That(reporterText, Does.Match("start( move)* down( move)+ up"));
- Assert.AreEqual(1, Regex.Matches(reporterText, "down").Count, "Reporter text:" + reporterText);
- Assert.AreEqual(1, Regex.Matches(reporterText, "up").Count, "Reporter text:" + reporterText);
+ Assert.That(Regex.Matches(reporterText, "down"), Has.Count.EqualTo(1), "Reporter text:" + reporterText);
+ Assert.That(Regex.Matches(reporterText, "up"), Has.Count.EqualTo(1), "Reporter text:" + reporterText);
Assert.That(reporterText, Does.Contain("move"));
}
@@ -230,11 +230,11 @@ public void CanDragAnElementNotVisibleInTheCurrentViewportDueToAParentOverflow()
Point targetLocation = dragTo.Location;
int yOffset = targetLocation.Y - srcLocation.Y;
- Assert.AreNotEqual(0, yOffset);
+ Assert.That(yOffset, Is.Not.Zero);
new Actions(driver).DragAndDropToOffset(toDrag, 0, yOffset).Perform();
- Assert.AreEqual(dragTo.Location, toDrag.Location);
+ Assert.That(toDrag.Location, Is.EqualTo(dragTo.Location));
}
//------------------------------------------------------------------
@@ -250,7 +250,7 @@ public void DragAndDropRelativeAndToElement()
actionProvider.DragAndDropToOffset(img1, 100, 100).Perform();
actionProvider.Reset();
actionProvider.DragAndDrop(img2, img1).Perform();
- Assert.AreEqual(img1.Location, img2.Location);
+ Assert.That(img2.Location, Is.EqualTo(img1.Location));
}
private Point Drag(IWebElement elem, Point initialLocation, int moveRightBy, int moveDownBy)
diff --git a/dotnet/test/common/Internal/Logging/FileLogHandlerTest.cs b/dotnet/test/common/Internal/Logging/FileLogHandlerTest.cs
index 63deb2bece47b..5c3e3150061dd 100644
--- a/dotnet/test/common/Internal/Logging/FileLogHandlerTest.cs
+++ b/dotnet/test/common/Internal/Logging/FileLogHandlerTest.cs
@@ -72,7 +72,7 @@ public void ShouldCreateFileIfDoesNotExist()
fileLogHandler2.Handle(new LogEvent(typeof(FileLogHandlerTest), DateTimeOffset.Now, LogEventLevel.Info, "test message"));
}
- Assert.That(Regex.Matches(File.ReadAllText(tempFile), "test message").Count, Is.EqualTo(1));
+ Assert.That(Regex.Matches(File.ReadAllText(tempFile), "test message"), Has.Count.EqualTo(1));
}
finally
{
@@ -97,7 +97,7 @@ public void ShouldAppendFileIfExists()
fileLogHandler2.Handle(new LogEvent(typeof(FileLogHandlerTest), DateTimeOffset.Now, LogEventLevel.Info, "test message"));
}
- Assert.That(Regex.Matches(File.ReadAllText(tempFilePath), "test message").Count, Is.EqualTo(2));
+ Assert.That(Regex.Matches(File.ReadAllText(tempFilePath), "test message"), Has.Count.EqualTo(2));
}
finally
{
@@ -117,7 +117,7 @@ public void ShouldOverwriteFileIfExists()
fileLogHandler.Handle(new LogEvent(typeof(FileLogHandlerTest), DateTimeOffset.Now, LogEventLevel.Info, "test message"));
}
- Assert.That(Regex.Matches(File.ReadAllText(tempFile), "test message").Count, Is.EqualTo(1));
+ Assert.That(Regex.Matches(File.ReadAllText(tempFile), "test message"), Has.Count.EqualTo(1));
}
finally
{
@@ -137,7 +137,7 @@ public void ShouldAppendFileIfDoesNotExist()
fileLogHandler.Handle(new LogEvent(typeof(FileLogHandlerTest), DateTimeOffset.Now, LogEventLevel.Info, "test message"));
}
- Assert.That(Regex.Matches(File.ReadAllText(tempFilePath), "test message").Count, Is.EqualTo(1));
+ Assert.That(Regex.Matches(File.ReadAllText(tempFilePath), "test message"), Has.Count.EqualTo(1));
}
finally
{
diff --git a/dotnet/test/common/JavascriptEnabledBrowserTest.cs b/dotnet/test/common/JavascriptEnabledBrowserTest.cs
index 2c87086c89703..ea9d267db29d8 100644
--- a/dotnet/test/common/JavascriptEnabledBrowserTest.cs
+++ b/dotnet/test/common/JavascriptEnabledBrowserTest.cs
@@ -32,9 +32,9 @@ public void DocumentShouldReflectLatestTitle()
{
driver.Url = javascriptPage;
- Assert.AreEqual("Testing Javascript", driver.Title);
+ Assert.That(driver.Title, Is.EqualTo("Testing Javascript"));
driver.FindElement(By.LinkText("Change the page title!")).Click();
- Assert.AreEqual("Changed", driver.Title);
+ Assert.That(driver.Title, Is.EqualTo("Changed"));
}
[Test]
@@ -42,13 +42,13 @@ public void DocumentShouldReflectLatestDom()
{
driver.Url = javascriptPage;
String currentText = driver.FindElement(By.XPath("//div[@id='dynamo']")).Text;
- Assert.AreEqual("What's for dinner?", currentText);
+ Assert.That(currentText, Is.EqualTo("What's for dinner?"));
IWebElement element = driver.FindElement(By.LinkText("Update a div"));
element.Click();
String newText = driver.FindElement(By.XPath("//div[@id='dynamo']")).Text;
- Assert.AreEqual("Fish and chips!", newText);
+ Assert.That(newText, Is.EqualTo("Fish and chips!"));
}
[Test]
@@ -60,7 +60,7 @@ public void ShouldWaitForLoadsToCompleteAfterJavascriptCausesANewPageToLoad()
driver.FindElement(By.Id("changeme")).Click();
WaitFor(() => { return driver.Title == "Page3"; }, "Browser title was not 'Page3'");
- Assert.AreEqual("Page3", driver.Title);
+ Assert.That(driver.Title, Is.EqualTo("Page3"));
}
[Test]
@@ -73,7 +73,7 @@ public void ShouldBeAbleToFindElementAfterJavascriptCausesANewPageToLoad()
driver.FindElement(By.Id("changeme")).Click();
WaitFor(() => { return driver.Title == "Page3"; }, "Browser title was not 'Page3'");
- Assert.AreEqual("3", driver.FindElement(By.Id("pageNumber")).Text);
+ Assert.That(driver.FindElement(By.Id("pageNumber")).Text, Is.EqualTo("3"));
}
[Test]
@@ -83,7 +83,7 @@ public void ShouldFireOnChangeEventWhenSettingAnElementsValue()
driver.FindElement(By.Id("change")).SendKeys("foo");
String result = driver.FindElement(By.Id("result")).Text;
- Assert.AreEqual("change", result);
+ Assert.That(result, Is.EqualTo("change"));
}
[Test]
@@ -94,7 +94,7 @@ public void ShouldBeAbleToSubmitFormsByCausingTheOnClickEventToFire()
element.Click();
WaitFor(() => { return driver.Title == "We Arrive Here"; }, "Browser title was not 'We Arrive Here'");
- Assert.AreEqual("We Arrive Here", driver.Title);
+ Assert.That(driver.Title, Is.EqualTo("We Arrive Here"));
}
[Test]
@@ -105,7 +105,7 @@ public void ShouldBeAbleToClickOnSubmitButtons()
element.Click();
WaitFor(() => { return driver.Title == "We Arrive Here"; }, "Browser title was not 'We Arrive Here'");
- Assert.AreEqual("We Arrive Here", driver.Title);
+ Assert.That(driver.Title, Is.EqualTo("We Arrive Here"));
}
[Test]
@@ -113,11 +113,11 @@ public void Issue80ClickShouldGenerateClickEvent()
{
driver.Url = javascriptPage;
IWebElement element = driver.FindElement(By.Id("clickField"));
- Assert.AreEqual("Hello", element.GetAttribute("value"));
+ Assert.That(element.GetAttribute("value"), Is.EqualTo("Hello"));
element.Click();
- Assert.AreEqual("Clicked", element.GetAttribute("value"));
+ Assert.That(element.GetAttribute("value"), Is.EqualTo("Clicked"));
}
[Test]
@@ -128,7 +128,7 @@ public void ShouldBeAbleToSwitchToFocusedElement()
driver.FindElement(By.Id("switchFocus")).Click();
IWebElement element = driver.SwitchTo().ActiveElement();
- Assert.AreEqual("theworks", element.GetAttribute("id"));
+ Assert.That(element.GetAttribute("id"), Is.EqualTo("theworks"));
}
[Test]
@@ -138,7 +138,7 @@ public void IfNoElementHasFocusTheActiveElementIsTheBody()
IWebElement element = driver.SwitchTo().ActiveElement();
- Assert.AreEqual("body", element.GetAttribute("name"));
+ Assert.That(element.GetAttribute("name"), Is.EqualTo("body"));
}
[Test]
diff --git a/dotnet/test/common/MiscTest.cs b/dotnet/test/common/MiscTest.cs
index a979bd1071d60..dbccd948ed371 100644
--- a/dotnet/test/common/MiscTest.cs
+++ b/dotnet/test/common/MiscTest.cs
@@ -40,13 +40,13 @@ public void ShouldReturnTitleOfPageIfSet()
public void ShouldReportTheCurrentUrlCorrectly()
{
driver.Url = macbethPage;
- Assert.AreEqual(macbethPage, driver.Url);
+ Assert.That(driver.Url, Is.EqualTo(macbethPage));
driver.Url = simpleTestPage;
- Assert.AreEqual(simpleTestPage, driver.Url);
+ Assert.That(driver.Url, Is.EqualTo(simpleTestPage));
driver.Url = javascriptPage;
- Assert.AreEqual(javascriptPage, driver.Url);
+ Assert.That(driver.Url, Is.EqualTo(javascriptPage));
}
[Test]
@@ -82,7 +82,7 @@ public void ShouldBeAbleToGetTheSourceOfAnXmlDocument()
driver.Url = simpleXmlDocument;
string source = driver.PageSource.ToLower();
source = System.Text.RegularExpressions.Regex.Replace(source, "\\s", string.Empty);
- Assert.AreEqual("baz ", source);
+ Assert.That(source, Is.EqualTo("baz "));
}
// Test is ignored for all browsers, but is kept here in the source code for
@@ -108,14 +108,14 @@ public void ClickingShouldNotTrampleWOrHInGlobalScope()
foreach (string val in values)
{
- Assert.AreEqual(val, GetGlobalVar(driver, val));
+ Assert.That(GetGlobalVar(driver, val), Is.EqualTo(val));
}
driver.FindElement(By.Id("toclick")).Click();
foreach (string val in values)
{
- Assert.AreEqual(val, GetGlobalVar(driver, val));
+ Assert.That(GetGlobalVar(driver, val), Is.EqualTo(val));
}
}
diff --git a/dotnet/test/common/NavigationTest.cs b/dotnet/test/common/NavigationTest.cs
index 32a660f7cd57f..6dce194d446d4 100644
--- a/dotnet/test/common/NavigationTest.cs
+++ b/dotnet/test/common/NavigationTest.cs
@@ -48,10 +48,10 @@ public void ShouldGoBackAndForward()
driver.Url = simpleTestPage;
navigation.Back();
- Assert.AreEqual(macbethTitle, driver.Title);
+ Assert.That(driver.Title, Is.EqualTo(macbethTitle));
navigation.Forward();
- Assert.AreEqual(simpleTestTitle, driver.Title);
+ Assert.That(driver.Title, Is.EqualTo(simpleTestTitle));
}
[Test]
@@ -71,12 +71,12 @@ public void ShouldGoToUrlUsingString()
navigation = driver.Navigate();
navigation.GoToUrl(macbethPage);
- Assert.AreEqual(macbethTitle, driver.Title);
+ Assert.That(driver.Title, Is.EqualTo(macbethTitle));
// We go to two pages to ensure that the browser wasn't
// already at the desired page through a previous test.
navigation.GoToUrl(simpleTestPage);
- Assert.AreEqual(simpleTestTitle, driver.Title);
+ Assert.That(driver.Title, Is.EqualTo(simpleTestTitle));
}
[Test]
@@ -88,12 +88,12 @@ public void ShouldGoToUrlUsingUri()
navigation = driver.Navigate();
navigation.GoToUrl(macBeth);
- Assert.AreEqual(driver.Title, macbethTitle);
+ Assert.That(macbethTitle, Is.EqualTo(driver.Title));
// We go to two pages to ensure that the browser wasn't
// already at the desired page through a previous test.
navigation.GoToUrl(simpleTest);
- Assert.AreEqual(simpleTestTitle, driver.Title);
+ Assert.That(driver.Title, Is.EqualTo(simpleTestTitle));
}
[Test]
@@ -103,21 +103,20 @@ public void ShouldRefreshPage()
IWebElement changedDiv = driver.FindElement(By.Id("dynamo"));
driver.FindElement(By.Id("updatediv")).Click();
- Assert.AreEqual("Fish and chips!", changedDiv.Text);
+ Assert.That(changedDiv.Text, Is.EqualTo("Fish and chips!"));
driver.Navigate().Refresh();
changedDiv = driver.FindElement(By.Id("dynamo"));
- Assert.AreEqual("What's for dinner?", changedDiv.Text);
+ Assert.That(changedDiv.Text, Is.EqualTo("What's for dinner?"));
}
[Test]
[NeedsFreshDriver(IsCreatedBeforeTest = true)]
- public Task ShouldNotHaveProblemNavigatingWithNoPagesBrowsedAsync()
+ public void ShouldNotHaveProblemNavigatingWithNoPagesBrowsedAsync()
{
var navigation = driver.Navigate();
- Assert.DoesNotThrowAsync(async () => await navigation.BackAsync());
- Assert.DoesNotThrowAsync(async () => await navigation.ForwardAsync());
- return Task.CompletedTask;
+ Assert.That(async () => await navigation.BackAsync(), Throws.Nothing);
+ Assert.That(async () => await navigation.ForwardAsync(), Throws.Nothing);
}
[Test]
@@ -129,10 +128,10 @@ public async Task ShouldGoBackAndForwardAsync()
await navigation.GoToUrlAsync(simpleTestPage);
await navigation.BackAsync();
- Assert.AreEqual(macbethTitle, driver.Title);
+ Assert.That(driver.Title, Is.EqualTo(macbethTitle));
await navigation.ForwardAsync();
- Assert.AreEqual(simpleTestTitle, driver.Title);
+ Assert.That(driver.Title, Is.EqualTo(simpleTestTitle));
}
[Test]
@@ -148,10 +147,10 @@ public async Task ShouldGoToUrlUsingStringAsync()
var navigation = driver.Navigate();
await navigation.GoToUrlAsync(macbethPage);
- Assert.AreEqual(macbethTitle, driver.Title);
+ Assert.That(driver.Title, Is.EqualTo(macbethTitle));
await navigation.GoToUrlAsync(simpleTestPage);
- Assert.AreEqual(simpleTestTitle, driver.Title);
+ Assert.That(driver.Title, Is.EqualTo(simpleTestTitle));
}
[Test]
@@ -160,9 +159,9 @@ public void ShouldGoToUrlUsingUriAsync()
var navigation = driver.Navigate();
navigation.GoToUrlAsync(new Uri(macbethPage));
- Assert.AreEqual(driver.Title, macbethTitle);
+ Assert.That(macbethTitle, Is.EqualTo(driver.Title));
navigation.GoToUrl(new Uri(simpleTestPage));
- Assert.AreEqual(simpleTestTitle, driver.Title);
+ Assert.That(driver.Title, Is.EqualTo(simpleTestTitle));
}
[Test]
@@ -172,11 +171,11 @@ public async Task ShouldRefreshPageAsync()
IWebElement changedDiv = driver.FindElement(By.Id("dynamo"));
driver.FindElement(By.Id("updatediv")).Click();
- Assert.AreEqual("Fish and chips!", changedDiv.Text);
+ Assert.That(changedDiv.Text, Is.EqualTo("Fish and chips!"));
await driver.Navigate().RefreshAsync();
changedDiv = driver.FindElement(By.Id("dynamo"));
- Assert.AreEqual("What's for dinner?", changedDiv.Text);
+ Assert.That(changedDiv.Text, Is.EqualTo("What's for dinner?"));
}
}
}
diff --git a/dotnet/test/common/NetworkInterceptionTests.cs b/dotnet/test/common/NetworkInterceptionTests.cs
index 10234945895d0..59434fb563e86 100644
--- a/dotnet/test/common/NetworkInterceptionTests.cs
+++ b/dotnet/test/common/NetworkInterceptionTests.cs
@@ -57,7 +57,7 @@ public async Task TestCanInterceptNetworkCalls()
driver.Url = simpleTestPage;
string text = driver.FindElement(By.CssSelector("p")).Text;
await network.StopMonitoring();
- Assert.AreEqual("I intercepted you", text);
+ Assert.That(text, Is.EqualTo("I intercepted you"));
}
}
@@ -78,7 +78,7 @@ public async Task TestCanUseAuthorizationHandler()
driver.Url = authenticationPage;
string text = driver.FindElement(By.CssSelector("h1")).Text;
await network.StopMonitoring();
- Assert.AreEqual("authorized", text);
+ Assert.That(text, Is.EqualTo("authorized"));
}
}
}
diff --git a/dotnet/test/common/PageLoadingTest.cs b/dotnet/test/common/PageLoadingTest.cs
index 9cbb86c06bcb4..0b231c94746e1 100644
--- a/dotnet/test/common/PageLoadingTest.cs
+++ b/dotnet/test/common/PageLoadingTest.cs
@@ -145,7 +145,7 @@ public void NormalStrategyShouldWaitForDocumentToBeLoaded()
{
driver.Url = simpleTestPage;
- Assert.AreEqual(driver.Title, "Hello WebDriver");
+ Assert.That(driver.Title, Is.EqualTo("Hello WebDriver"));
}
[Test]
@@ -153,7 +153,7 @@ public void NormalStrategyShouldWaitForDocumentToBeLoaded()
public void ShouldFollowRedirectsSentInTheHttpResponseHeaders()
{
driver.Url = redirectPage;
- Assert.AreEqual(driver.Title, "We Arrive Here");
+ Assert.That(driver.Title, Is.EqualTo("We Arrive Here"));
}
[Test]
@@ -161,7 +161,7 @@ public void ShouldFollowMetaRedirects()
{
driver.Url = metaRedirectPage;
WaitFor(() => { return driver.Title == "We Arrive Here"; }, "Browser title was not 'We Arrive Here'");
- Assert.AreEqual(driver.Title, "We Arrive Here");
+ Assert.That(driver.Title, Is.EqualTo("We Arrive Here"));
}
[Test]
@@ -192,7 +192,7 @@ public void ShouldReturnUrlOnNotExistedPage()
{
string url = EnvironmentManager.Instance.UrlBuilder.WhereIs("not_existed_page.html");
driver.Url = url;
- Assert.AreEqual(url, driver.Url);
+ Assert.That(driver.Url, Is.EqualTo(url));
}
[Test]
@@ -202,11 +202,11 @@ public void ShouldBeAbleToLoadAPageWithFramesetsAndWaitUntilAllFramesAreLoaded()
driver.SwitchTo().Frame(0);
IWebElement pageNumber = driver.FindElement(By.XPath("//span[@id='pageNumber']"));
- Assert.AreEqual(pageNumber.Text.Trim(), "1");
+ Assert.That(pageNumber.Text.Trim(), Is.EqualTo("1"));
driver.SwitchTo().DefaultContent().SwitchTo().Frame(1);
pageNumber = driver.FindElement(By.XPath("//span[@id='pageNumber']"));
- Assert.AreEqual(pageNumber.Text.Trim(), "2");
+ Assert.That(pageNumber.Text.Trim(), Is.EqualTo("2"));
}
[Test]
@@ -223,7 +223,7 @@ public void ShouldDoNothingIfThereIsNothingToGoBackTo()
if (driver.Title == originalTitle)
{
driver.Navigate().Back();
- Assert.AreEqual(originalTitle, driver.Title);
+ Assert.That(driver.Title, Is.EqualTo(originalTitle));
}
}
@@ -234,11 +234,11 @@ public void ShouldBeAbleToNavigateBackInTheBrowserHistory()
driver.FindElement(By.Id("imageButton")).Submit();
WaitFor(TitleToBeEqualTo("We Arrive Here"), "Browser title was not 'We Arrive Here'");
- Assert.AreEqual(driver.Title, "We Arrive Here");
+ Assert.That(driver.Title, Is.EqualTo("We Arrive Here"));
driver.Navigate().Back();
WaitFor(TitleToBeEqualTo("We Leave From Here"), "Browser title was not 'We Leave From Here'");
- Assert.AreEqual(driver.Title, "We Leave From Here");
+ Assert.That(driver.Title, Is.EqualTo("We Leave From Here"));
}
[Test]
@@ -248,11 +248,11 @@ public void ShouldBeAbleToNavigateBackInTheBrowserHistoryInPresenceOfIframes()
driver.FindElement(By.Name("sameWindow")).Click();
WaitFor(TitleToBeEqualTo("This page has iframes"), "Browser title was not 'This page has iframes'");
- Assert.AreEqual(driver.Title, "This page has iframes");
+ Assert.That(driver.Title, Is.EqualTo("This page has iframes"));
driver.Navigate().Back();
WaitFor(TitleToBeEqualTo("XHTML Test Page"), "Browser title was not 'XHTML Test Page'");
- Assert.AreEqual(driver.Title, "XHTML Test Page");
+ Assert.That(driver.Title, Is.EqualTo("XHTML Test Page"));
}
[Test]
@@ -262,15 +262,15 @@ public void ShouldBeAbleToNavigateForwardsInTheBrowserHistory()
driver.FindElement(By.Id("imageButton")).Submit();
WaitFor(TitleToBeEqualTo("We Arrive Here"), "Browser title was not 'We Arrive Here'");
- Assert.AreEqual(driver.Title, "We Arrive Here");
+ Assert.That(driver.Title, Is.EqualTo("We Arrive Here"));
driver.Navigate().Back();
WaitFor(TitleToBeEqualTo("We Leave From Here"), "Browser title was not 'We Leave From Here'");
- Assert.AreEqual(driver.Title, "We Leave From Here");
+ Assert.That(driver.Title, Is.EqualTo("We Leave From Here"));
driver.Navigate().Forward();
WaitFor(TitleToBeEqualTo("We Arrive Here"), "Browser title was not 'We Arrive Here'");
- Assert.AreEqual(driver.Title, "We Arrive Here");
+ Assert.That(driver.Title, Is.EqualTo("We Arrive Here"));
}
[Test]
@@ -283,7 +283,7 @@ public void ShouldBeAbleToAccessPagesWithAnInsecureSslCertificate()
driver.Url = url;
// This should work
- Assert.AreEqual(driver.Title, "Hello WebDriver");
+ Assert.That(driver.Title, Is.EqualTo("Hello WebDriver"));
}
[Test]
@@ -293,7 +293,7 @@ public void ShouldBeAbleToRefreshAPage()
driver.Navigate().Refresh();
- Assert.AreEqual(driver.Title, "XHTML Test Page");
+ Assert.That(driver.Title, Is.EqualTo("XHTML Test Page"));
}
///
diff --git a/dotnet/test/common/PartialLinkTextMatchTest.cs b/dotnet/test/common/PartialLinkTextMatchTest.cs
index 111c7e301702a..1d69fe0b7aea7 100644
--- a/dotnet/test/common/PartialLinkTextMatchTest.cs
+++ b/dotnet/test/common/PartialLinkTextMatchTest.cs
@@ -33,7 +33,7 @@ public void LinkWithFormattingTags()
IWebElement res = elem.FindElement(By.PartialLinkText("link with formatting tags"));
Assert.That(res, Is.Not.Null);
- Assert.AreEqual("link with formatting tags", res.Text);
+ Assert.That(res.Text, Is.EqualTo("link with formatting tags"));
}
[Test]
@@ -44,7 +44,7 @@ public void LinkWithLeadingSpaces()
IWebElement res = elem.FindElement(By.PartialLinkText("link with leading space"));
Assert.That(res, Is.Not.Null);
- Assert.AreEqual("link with leading space", res.Text);
+ Assert.That(res.Text, Is.EqualTo("link with leading space"));
}
[Test]
@@ -56,7 +56,7 @@ public void LinkWithTrailingSpace()
IWebElement res =
elem.FindElement(By.PartialLinkText("link with trailing space"));
Assert.That(res, Is.Not.Null);
- Assert.AreEqual("link with trailing space", res.Text);
+ Assert.That(res.Text, Is.EqualTo("link with trailing space"));
}
[Test]
@@ -67,7 +67,7 @@ public void FindMultipleElements()
ReadOnlyCollection elements = elem.FindElements(By.PartialLinkText("link"));
Assert.That(elements, Is.Not.Null);
- Assert.AreEqual(6, elements.Count);
+ Assert.That(elements, Has.Count.EqualTo(6));
}
[Test]
@@ -76,7 +76,7 @@ public void DriverCanGetLinkByLinkTestIgnoringTrailingWhitespace()
driver.Url = simpleTestPage;
IWebElement link = null;
link = driver.FindElement(By.LinkText("link with trailing space"));
- Assert.AreEqual("linkWithTrailingSpace", link.GetAttribute("id"));
+ Assert.That(link.GetAttribute("id"), Is.EqualTo("linkWithTrailingSpace"));
}
[Test]
@@ -87,7 +87,7 @@ public void ElementCanGetLinkByLinkTestIgnoringTrailingWhitespace()
IWebElement link = null;
link = elem.FindElement(By.LinkText("link with trailing space"));
- Assert.AreEqual("linkWithTrailingSpace", link.GetAttribute("id"));
+ Assert.That(link.GetAttribute("id"), Is.EqualTo("linkWithTrailingSpace"));
}
}
}
diff --git a/dotnet/test/common/PositionAndSizeTest.cs b/dotnet/test/common/PositionAndSizeTest.cs
index 8b8f225148ec7..5d5cab17a89e5 100644
--- a/dotnet/test/common/PositionAndSizeTest.cs
+++ b/dotnet/test/common/PositionAndSizeTest.cs
@@ -43,40 +43,40 @@ public void ShouldBeAbleToDetermineTheLocationOfAnElement()
public void ShouldGetCoordinatesOfAnElement()
{
driver.Url = EnvironmentManager.Instance.UrlBuilder.WhereIs("coordinates_tests/simple_page.html");
- Assert.AreEqual(new Point(10, 10), GetLocationInViewPort(By.Id("box")));
- Assert.AreEqual(new Point(10, 10), GetLocationOnPage(By.Id("box")));
+ Assert.That(GetLocationInViewPort(By.Id("box")), Is.EqualTo(new Point(10, 10)));
+ Assert.That(GetLocationOnPage(By.Id("box")), Is.EqualTo(new Point(10, 10)));
}
[Test]
public void ShouldGetCoordinatesOfAnEmptyElement()
{
driver.Url = EnvironmentManager.Instance.UrlBuilder.WhereIs("coordinates_tests/page_with_empty_element.html");
- Assert.AreEqual(new Point(10, 10), GetLocationInViewPort(By.Id("box")));
- Assert.AreEqual(new Point(10, 10), GetLocationOnPage(By.Id("box")));
+ Assert.That(GetLocationInViewPort(By.Id("box")), Is.EqualTo(new Point(10, 10)));
+ Assert.That(GetLocationOnPage(By.Id("box")), Is.EqualTo(new Point(10, 10)));
}
[Test]
public void ShouldGetCoordinatesOfATransparentElement()
{
driver.Url = EnvironmentManager.Instance.UrlBuilder.WhereIs("coordinates_tests/page_with_transparent_element.html");
- Assert.AreEqual(new Point(10, 10), GetLocationInViewPort(By.Id("box")));
- Assert.AreEqual(new Point(10, 10), GetLocationOnPage(By.Id("box")));
+ Assert.That(GetLocationInViewPort(By.Id("box")), Is.EqualTo(new Point(10, 10)));
+ Assert.That(GetLocationOnPage(By.Id("box")), Is.EqualTo(new Point(10, 10)));
}
[Test]
public void ShouldGetCoordinatesOfAHiddenElement()
{
driver.Url = EnvironmentManager.Instance.UrlBuilder.WhereIs("coordinates_tests/page_with_hidden_element.html");
- Assert.AreEqual(new Point(10, 10), GetLocationInViewPort(By.Id("box")));
- Assert.AreEqual(new Point(10, 10), GetLocationOnPage(By.Id("box")));
+ Assert.That(GetLocationInViewPort(By.Id("box")), Is.EqualTo(new Point(10, 10)));
+ Assert.That(GetLocationOnPage(By.Id("box")), Is.EqualTo(new Point(10, 10)));
}
[Test]
public void ShouldGetCoordinatesOfAnInvisibleElement()
{
driver.Url = EnvironmentManager.Instance.UrlBuilder.WhereIs("coordinates_tests/page_with_invisible_element.html");
- Assert.AreEqual(new Point(0, 0), GetLocationInViewPort(By.Id("box")));
- Assert.AreEqual(new Point(0, 0), GetLocationOnPage(By.Id("box")));
+ Assert.That(GetLocationInViewPort(By.Id("box")), Is.EqualTo(new Point(0, 0)));
+ Assert.That(GetLocationOnPage(By.Id("box")), Is.EqualTo(new Point(0, 0)));
}
[Test]
@@ -99,8 +99,8 @@ public void ShouldGetCoordinatesOfAnElementInAFrame()
driver.Url = EnvironmentManager.Instance.UrlBuilder.WhereIs("coordinates_tests/element_in_frame.html");
driver.SwitchTo().Frame("ifr");
IWebElement box = driver.FindElement(By.Id("box"));
- Assert.AreEqual(new Point(10, 10), box.Location);
- Assert.AreEqual(new Point(10, 10), GetLocationOnPage(By.Id("box")));
+ Assert.That(box.Location, Is.EqualTo(new Point(10, 10)));
+ Assert.That(GetLocationOnPage(By.Id("box")), Is.EqualTo(new Point(10, 10)));
}
[Test]
@@ -108,10 +108,10 @@ public void ShouldGetCoordinatesInViewPortOfAnElementInAFrame()
{
driver.Url = EnvironmentManager.Instance.UrlBuilder.WhereIs("coordinates_tests/element_in_frame.html");
driver.SwitchTo().Frame("ifr");
- Assert.AreEqual(new Point(10, 10), GetLocationOnPage(By.Id("box")));
+ Assert.That(GetLocationOnPage(By.Id("box")), Is.EqualTo(new Point(10, 10)));
// GetLocationInViewPort only works within the context of a single frame
// for W3C-spec compliant remote ends.
- // Assert.AreEqual(new Point(25, 25), GetLocationInViewPort(By.Id("box")));
+ // Assert.That(GetLocationInViewPort(By.Id("box")), Is.EqualTo(new Point(25, 25)));
}
[Test]
@@ -120,10 +120,10 @@ public void ShouldGetCoordinatesInViewPortOfAnElementInANestedFrame()
driver.Url = EnvironmentManager.Instance.UrlBuilder.WhereIs("coordinates_tests/element_in_nested_frame.html");
driver.SwitchTo().Frame("ifr");
driver.SwitchTo().Frame("ifr");
- Assert.AreEqual(new Point(10, 10), GetLocationOnPage(By.Id("box")));
+ Assert.That(GetLocationOnPage(By.Id("box")), Is.EqualTo(new Point(10, 10)));
// GetLocationInViewPort only works within the context of a single frame
// for W3C-spec compliant remote ends.
- // Assert.AreEqual(new Point(40, 40), GetLocationInViewPort(By.Id("box")));
+ // Assert.That(GetLocationInViewPort(By.Id("box")), Is.EqualTo(new Point(40, 40)));
}
[Test]
@@ -156,15 +156,15 @@ public void ShouldHandleNonIntegerPositionAndSize()
IWebElement r2 = driver.FindElement(By.Id("r2"));
string left = r2.GetCssValue("left");
- Assert.AreEqual(10.9, Math.Round(Convert.ToDecimal(left.Replace("px", "")), 1));
+ Assert.That(Math.Round(Convert.ToDecimal(left.Replace("px", "")), 1), Is.EqualTo(10.9));
string top = r2.GetCssValue("top");
- Assert.AreEqual(10.1, Math.Round(Convert.ToDecimal(top.Replace("px", "")), 1));
- Assert.AreEqual(new Point(11, 10), r2.Location);
+ Assert.That(Math.Round(Convert.ToDecimal(top.Replace("px", "")), 1), Is.EqualTo(10.1));
+ Assert.That(r2.Location, Is.EqualTo(new Point(11, 10)));
string width = r2.GetCssValue("width");
- Assert.AreEqual(48.7, Math.Round(Convert.ToDecimal(width.Replace("px", "")), 1));
+ Assert.That(Math.Round(Convert.ToDecimal(width.Replace("px", "")), 1), Is.EqualTo(48.7));
string height = r2.GetCssValue("height");
- Assert.AreEqual(49.3, Math.Round(Convert.ToDecimal(height.Replace("px", "")), 1));
- Assert.AreEqual(new Size(49, 49), r2.Size);
+ Assert.That(Math.Round(Convert.ToDecimal(height.Replace("px", "")), 1), Is.EqualTo(49.3));
+ Assert.That(r2.Size, Is.EqualTo(new Size(49, 49)));
}
//------------------------------------------------------------------
diff --git a/dotnet/test/common/SessionHandlingTest.cs b/dotnet/test/common/SessionHandlingTest.cs
index f0c50c329a691..8b9c1db2f5504 100644
--- a/dotnet/test/common/SessionHandlingTest.cs
+++ b/dotnet/test/common/SessionHandlingTest.cs
@@ -49,7 +49,7 @@ public void CallingQuitAfterClosingTheLastWindowIsANoOp()
testDriver.Quit();
testDriver = EnvironmentManager.Instance.CreateDriverInstance();
testDriver.Url = xhtmlTestPage;
- Assert.AreEqual("XHTML Test Page", testDriver.Title);
+ Assert.That(testDriver.Title, Is.EqualTo("XHTML Test Page"));
testDriver.Quit();
}
@@ -106,7 +106,7 @@ public void ShouldBeAbleToStartNewDriverAfterCallingCloseOnOnlyOpenWindow()
testDriver.Dispose();
testDriver = EnvironmentManager.Instance.CreateDriverInstance();
testDriver.Url = xhtmlTestPage;
- Assert.AreEqual("XHTML Test Page", testDriver.Title);
+ Assert.That(testDriver.Title, Is.EqualTo("XHTML Test Page"));
testDriver.Close();
testDriver.Dispose();
}
@@ -143,7 +143,7 @@ public void ShouldBeAbleToCallDisposeAfterQuit()
testDriver.Dispose();
testDriver = EnvironmentManager.Instance.CreateDriverInstance();
testDriver.Url = xhtmlTestPage;
- Assert.AreEqual("XHTML Test Page", testDriver.Title);
+ Assert.That(testDriver.Title, Is.EqualTo("XHTML Test Page"));
testDriver.Quit();
}
@@ -155,7 +155,7 @@ public void ShouldOpenAndCloseBrowserRepeatedly()
EnvironmentManager.Instance.CloseCurrentDriver();
CreateFreshDriver();
driver.Url = simpleTestPage;
- Assert.AreEqual(simpleTestTitle, driver.Title);
+ Assert.That(driver.Title, Is.EqualTo(simpleTestTitle));
}
}
}
diff --git a/dotnet/test/common/SvgDocumentTest.cs b/dotnet/test/common/SvgDocumentTest.cs
index 5eb5483667c79..5a777d920492a 100644
--- a/dotnet/test/common/SvgDocumentTest.cs
+++ b/dotnet/test/common/SvgDocumentTest.cs
@@ -38,9 +38,9 @@ public void ClickOnSvgElement()
driver.Url = svgTestPage;
IWebElement rect = driver.FindElement(By.Id("rect"));
- Assert.AreEqual("blue", rect.GetAttribute("fill"));
+ Assert.That(rect.GetAttribute("fill"), Is.EqualTo("blue"));
rect.Click();
- Assert.AreEqual("green", rect.GetAttribute("fill"));
+ Assert.That(rect.GetAttribute("fill"), Is.EqualTo("green"));
}
[Test]
@@ -54,9 +54,9 @@ public void ExecuteScriptInSvgDocument()
driver.Url = svgTestPage;
IWebElement rect = driver.FindElement(By.Id("rect"));
- Assert.AreEqual("blue", rect.GetAttribute("fill"));
+ Assert.That(rect.GetAttribute("fill"), Is.EqualTo("blue"));
((IJavaScriptExecutor)driver).ExecuteScript("document.getElementById('rect').setAttribute('fill', 'yellow');");
- Assert.AreEqual("yellow", rect.GetAttribute("fill"));
+ Assert.That(rect.GetAttribute("fill"), Is.EqualTo("yellow"));
}
}
}
diff --git a/dotnet/test/common/SvgElementTest.cs b/dotnet/test/common/SvgElementTest.cs
index fbefdea76a6ea..554b860edbc18 100644
--- a/dotnet/test/common/SvgElementTest.cs
+++ b/dotnet/test/common/SvgElementTest.cs
@@ -39,17 +39,17 @@ public void ShouldClickOnGraphVisualElements()
IWebElement svg = driver.FindElement(By.CssSelector("svg"));
ReadOnlyCollection groupElements = svg.FindElements(By.CssSelector("g"));
- Assert.AreEqual(5, groupElements.Count);
+ Assert.That(groupElements, Has.Count.EqualTo(5));
groupElements[1].Click();
IWebElement resultElement = driver.FindElement(By.Id("result"));
WaitFor(() => { return resultElement.Text == "slice_red"; }, "Element text was not 'slice_red'");
- Assert.AreEqual("slice_red", resultElement.Text);
+ Assert.That(resultElement.Text, Is.EqualTo("slice_red"));
groupElements[2].Click();
resultElement = driver.FindElement(By.Id("result"));
WaitFor(() => { return resultElement.Text == "slice_green"; }, "Element text was not 'slice_green'");
- Assert.AreEqual("slice_green", resultElement.Text);
+ Assert.That(resultElement.Text, Is.EqualTo("slice_green"));
}
[Test]
@@ -70,7 +70,7 @@ public void ShouldClickOnGraphTextElements()
appleElement.Click();
IWebElement resultElement = driver.FindElement(By.Id("result"));
WaitFor(() => { return resultElement.Text == "text_apple"; }, "Element text was not 'text_apple'");
- Assert.AreEqual("text_apple", resultElement.Text);
+ Assert.That(resultElement.Text, Is.EqualTo("text_apple"));
}
private IWebElement FindAppleElement(IEnumerable textElements)
diff --git a/dotnet/test/common/TagNameTest.cs b/dotnet/test/common/TagNameTest.cs
index fec7d75d2cc0d..77b64af111de8 100644
--- a/dotnet/test/common/TagNameTest.cs
+++ b/dotnet/test/common/TagNameTest.cs
@@ -29,7 +29,7 @@ public void ShouldReturnInput()
{
driver.Url = formsPage;
IWebElement selectBox = driver.FindElement(By.Id("cheese"));
- Assert.AreEqual(selectBox.TagName.ToLower(), "input");
+ Assert.That(selectBox.TagName, Is.EqualTo("input").IgnoreCase);
}
}
}
diff --git a/dotnet/test/common/TakesScreenshotTest.cs b/dotnet/test/common/TakesScreenshotTest.cs
index 6c09b0acfde93..74fcad3463f42 100644
--- a/dotnet/test/common/TakesScreenshotTest.cs
+++ b/dotnet/test/common/TakesScreenshotTest.cs
@@ -141,7 +141,7 @@ public void ShouldTakeScreenshotsOfAnElement()
Color pixelColor = GetPixelColor(screenImage, 1, 1);
string pixelColorString = FormatColorToHex(pixelColor.ToArgb());
- Assert.AreEqual("#0f12f7", pixelColorString);
+ Assert.That(pixelColorString, Is.EqualTo("#0f12f7"));
}
[Test]
diff --git a/dotnet/test/common/TargetLocatorTest.cs b/dotnet/test/common/TargetLocatorTest.cs
index 19a23cb1dd086..de1cd4a70816a 100644
--- a/dotnet/test/common/TargetLocatorTest.cs
+++ b/dotnet/test/common/TargetLocatorTest.cs
@@ -89,7 +89,7 @@ public void ShouldSwitchToFrameByNameAndBackToDefaultContent()
driver.Url = framesPage;
driver.SwitchTo().Frame("first");
- Assert.AreEqual(driver.FindElement(By.Id("pageNumber")).Text, "1");
+ Assert.That(driver.FindElement(By.Id("pageNumber")).Text, Is.EqualTo("1"));
driver.SwitchTo().DefaultContent();
@@ -99,7 +99,7 @@ public void ShouldSwitchToFrameByNameAndBackToDefaultContent()
Throws.TypeOf());
driver.SwitchTo().Frame("second");
- Assert.AreEqual(driver.FindElement(By.Id("pageNumber")).Text, "2");
+ Assert.That(driver.FindElement(By.Id("pageNumber")).Text, Is.EqualTo("2"));
driver.SwitchTo().DefaultContent();
@@ -115,7 +115,7 @@ public void ShouldSwitchToFrameByIndexAndBackToDefaultContent()
driver.Url = framesPage;
driver.SwitchTo().Frame(0);
- Assert.AreEqual(driver.FindElement(By.Id("pageNumber")).Text, "1");
+ Assert.That(driver.FindElement(By.Id("pageNumber")).Text, Is.EqualTo("1"));
driver.SwitchTo().DefaultContent();
@@ -126,7 +126,7 @@ public void ShouldSwitchToFrameByIndexAndBackToDefaultContent()
driver.SwitchTo().Frame(1);
- Assert.AreEqual(driver.FindElement(By.Id("pageNumber")).Text, "2");
+ Assert.That(driver.FindElement(By.Id("pageNumber")).Text, Is.EqualTo("2"));
driver.SwitchTo().DefaultContent();
diff --git a/dotnet/test/common/TextHandlingTest.cs b/dotnet/test/common/TextHandlingTest.cs
index f087f1fbd2346..3b66fe86dd2c4 100644
--- a/dotnet/test/common/TextHandlingTest.cs
+++ b/dotnet/test/common/TextHandlingTest.cs
@@ -34,10 +34,10 @@ public void ShouldReturnTheTextContentOfASingleElementWithNoChildren()
{
driver.Url = simpleTestPage;
string selectText = driver.FindElement(By.Id("oneline")).Text;
- Assert.AreEqual(selectText, "A single line of text");
+ Assert.That(selectText, Is.EqualTo("A single line of text"));
string getText = driver.FindElement(By.Id("oneline")).Text;
- Assert.AreEqual(getText, "A single line of text");
+ Assert.That(getText, Is.EqualTo("A single line of text"));
}
[Test]
@@ -58,9 +58,9 @@ public void ShouldIgnoreScriptElements()
IWebElement labelForUsername = driver.FindElement(By.Id("labelforusername"));
string text = labelForUsername.Text;
- Assert.AreEqual(labelForUsername.FindElements(By.TagName("script")).Count, 1);
+ Assert.That(labelForUsername.FindElements(By.TagName("script")).Count, Is.EqualTo(1));
Assert.That(text, Does.Not.Contain("document.getElementById"));
- Assert.AreEqual(text, "Username:");
+ Assert.That(text, Is.EqualTo("Username:"));
}
[Test]
@@ -80,7 +80,7 @@ public void ShouldCollapseMultipleWhitespaceCharactersIntoASingleSpace()
driver.Url = (simpleTestPage);
string text = driver.FindElement(By.Id("lotsofspaces")).Text;
- Assert.AreEqual(text, "This line has lots of spaces.");
+ Assert.That(text, Is.EqualTo("This line has lots of spaces."));
}
[Test]
@@ -99,7 +99,7 @@ public void ShouldConvertANonBreakingSpaceIntoANormalSpaceCharacter()
driver.Url = (simpleTestPage);
string text = driver.FindElement(By.Id("nbsp")).Text;
- Assert.AreEqual(text, "This line has a non-breaking space");
+ Assert.That(text, Is.EqualTo("This line has a non-breaking space"));
}
[Test]
@@ -109,7 +109,7 @@ public void ShouldNotCollapseANonBreakingSpaces()
IWebElement element = driver.FindElement(By.Id("nbspandspaces"));
string text = element.Text;
- Assert.AreEqual(text, "This line has a non-breaking space and spaces");
+ Assert.That(text, Is.EqualTo("This line has a non-breaking space and spaces"));
}
[Test]
@@ -147,7 +147,7 @@ public void HavingInlineElementsShouldNotAffectHowTextIsReturned()
{
driver.Url = (simpleTestPage);
string text = driver.FindElement(By.Id("inline")).Text;
- Assert.AreEqual(text, "This line has text within elements that are meant to be displayed inline");
+ Assert.That(text, Is.EqualTo("This line has text within elements that are meant to be displayed inline"));
}
[Test]
@@ -156,7 +156,7 @@ public void ShouldReturnTheEntireTextOfInlineElements()
driver.Url = (simpleTestPage);
string text = driver.FindElement(By.Id("span")).Text;
- Assert.AreEqual(text, "An inline element");
+ Assert.That(text, Is.EqualTo("An inline element"));
}
[Test]
@@ -195,7 +195,7 @@ public void ShouldBeAbleToSetMoreThanOneLineOfTextInATextArea()
textarea.SendKeys(expectedText);
string seenText = textarea.GetAttribute("value");
- Assert.AreEqual(expectedText, seenText);
+ Assert.That(seenText, Is.EqualTo(expectedText));
}
[Test]
@@ -207,7 +207,7 @@ public void ShouldBeAbleToEnterDatesAfterFillingInOtherValuesFirst()
input.SendKeys(expectedValue);
string seenValue = input.GetAttribute("value");
- Assert.AreEqual(seenValue, expectedValue);
+ Assert.That(expectedValue, Is.EqualTo(seenValue));
}
[Test]
@@ -216,7 +216,7 @@ public void ShouldReturnEmptyStringWhenTextIsOnlySpaces()
driver.Url = (xhtmlTestPage);
string text = driver.FindElement(By.Id("spaces")).Text;
- Assert.AreEqual(text, string.Empty);
+ Assert.That(text, Is.Empty);
}
[Test]
@@ -225,7 +225,7 @@ public void ShouldReturnEmptyStringWhenTextIsEmpty()
driver.Url = (xhtmlTestPage);
string text = driver.FindElement(By.Id("empty")).Text;
- Assert.AreEqual(text, string.Empty);
+ Assert.That(text, Is.Empty);
}
[Test]
@@ -234,7 +234,7 @@ public void ShouldReturnEmptyStringWhenTagIsSelfClosing()
driver.Url = (xhtmlFormPage);
string text = driver.FindElement(By.Id("self-closed")).Text;
- Assert.AreEqual(text, string.Empty);
+ Assert.That(text, Is.Empty);
}
[Test]
@@ -243,7 +243,7 @@ public void ShouldNotTrimSpacesWhenLineWraps()
driver.Url = simpleTestPage;
string text = driver.FindElement(By.XPath("//table/tbody/tr[1]/td[1]")).Text;
- Assert.AreEqual("beforeSpace afterSpace", text);
+ Assert.That(text, Is.EqualTo("beforeSpace afterSpace"));
}
[Test]
@@ -253,7 +253,7 @@ public void ShouldHandleSiblingBlockLevelElements()
string text = driver.FindElement(By.Id("twoblocks")).Text;
- Assert.AreEqual("Some text" + NewLine + "Some more text", text);
+ Assert.That(text, Is.EqualTo("Some text" + NewLine + "Some more text"));
}
[Test]
@@ -263,8 +263,8 @@ public void ShouldHandleNestedBlockLevelElements()
string text = driver.FindElement(By.Id("nestedblocks")).Text;
- Assert.AreEqual("Cheese" + NewLine + "Some text" + NewLine + "Some more text" + NewLine
- + "and also" + NewLine + "Brie", text);
+ Assert.That(text, Is.EqualTo("Cheese" + NewLine + "Some text" + NewLine + "Some more text" + NewLine
+ + "and also" + NewLine + "Brie"));
}
[Test]
@@ -274,7 +274,7 @@ public void ShouldHandleWhitespaceInInlineElements()
string text = driver.FindElement(By.Id("inlinespan")).Text;
- Assert.AreEqual(text, "line has text");
+ Assert.That(text, Is.EqualTo("line has text"));
}
[Test]
@@ -305,8 +305,8 @@ public void ShouldOnlyIncludeVisibleText()
string empty = driver.FindElement(By.Id("suppressedParagraph")).Text;
string explicitText = driver.FindElement(By.Id("outer")).Text;
- Assert.AreEqual(string.Empty, empty);
- Assert.AreEqual("sub-element that is explicitly visible", explicitText);
+ Assert.That(empty, Is.Empty);
+ Assert.That(explicitText, Is.EqualTo("sub-element that is explicitly visible"));
}
[Test]
@@ -326,7 +326,7 @@ public void TextOfAnInputFieldShouldBeEmpty()
{
driver.Url = formsPage;
IWebElement input = driver.FindElement(By.Id("inputWithText"));
- Assert.AreEqual(string.Empty, input.Text);
+ Assert.That(input.Text, Is.Empty);
}
[Test]
@@ -334,7 +334,7 @@ public void TextOfATextAreaShouldBeEqualToItsDefaultText()
{
driver.Url = formsPage;
IWebElement area = driver.FindElement(By.Id("withText"));
- Assert.AreEqual("Example text", area.Text);
+ Assert.That(area.Text, Is.EqualTo("Example text"));
}
[Test]
@@ -345,7 +345,7 @@ public void TextOfATextAreaShouldBeEqualToItsDefaultTextEvenAfterTyping()
IWebElement area = driver.FindElement(By.Id("withText"));
string oldText = area.Text;
area.SendKeys("New Text");
- Assert.AreEqual(oldText, area.Text);
+ Assert.That(area.Text, Is.EqualTo(oldText));
}
[Test]
@@ -356,7 +356,7 @@ public void TextOfATextAreaShouldBeEqualToItsDefaultTextEvenAfterChangingTheValu
IWebElement area = driver.FindElement(By.Id("withText"));
string oldText = area.GetAttribute("value");
((IJavaScriptExecutor)driver).ExecuteScript("arguments[0].value = arguments[1]", area, "New Text");
- Assert.AreEqual(oldText, area.Text);
+ Assert.That(area.Text, Is.EqualTo(oldText));
}
[Test]
@@ -364,7 +364,7 @@ public void ShouldGetTextWhichIsAValidJSONObject()
{
driver.Url = simpleTestPage;
IWebElement element = driver.FindElement(By.Id("simpleJsonText"));
- Assert.AreEqual("{a=\"b\", c=1, d=true}", element.Text);
+ Assert.That(element.Text, Is.EqualTo("{a=\"b\", c=1, d=true}"));
//assertEquals("{a=\"b\", \"c\"=d, e=true, f=\\123\\\\g\\\\\"\"\"\\\'}", element.getText());
}
@@ -373,7 +373,7 @@ public void ShouldGetTextWhichIsAValidComplexJSONObject()
{
driver.Url = simpleTestPage;
IWebElement element = driver.FindElement(By.Id("complexJsonText"));
- Assert.AreEqual("{a=\"\\\\b\\\\\\\"\'\\\'\"}", element.Text);
+ Assert.That(element.Text, Is.EqualTo("{a=\"\\\\b\\\\\\\"\'\\\'\"}"));
}
[Test]
@@ -384,11 +384,11 @@ public void ShouldNotReturnLtrMarks()
IWebElement element = driver.FindElement(By.Id("EH")).FindElement(By.TagName("nobr"));
string text = element.Text;
String expected = "Some notes";
- Assert.AreNotSame(8206, (int)text[0], "RTL mark should not be present");
+ Assert.That((int)text[0], Is.Not.EqualTo(8206), "RTL mark should not be present");
// Note: If this assertion fails but the content of the strings *looks* the same
// it may be because of hidden unicode LTR character being included in the string.
// That's the reason for the previous assert.
- Assert.Equals(expected, element.Text);
+ Assert.That(element.Text, Is.EqualTo(expected));
}
[Test]
@@ -398,7 +398,7 @@ public void ShouldTrimTextWithMultiByteWhitespaces()
driver.Url = simpleTestPage;
String text = driver.FindElement(By.Id("trimmedSpace")).Text;
- Assert.AreEqual("test", text);
+ Assert.That(text, Is.EqualTo("test"));
}
[Test]
diff --git a/dotnet/test/common/TypingTest.cs b/dotnet/test/common/TypingTest.cs
index d2290a210fdc7..55caf6f76cfe0 100644
--- a/dotnet/test/common/TypingTest.cs
+++ b/dotnet/test/common/TypingTest.cs
@@ -74,7 +74,7 @@ public void ShouldTypeLowerCaseLetters()
IWebElement keyReporter = driver.FindElement(By.Id("keyReporter"));
keyReporter.SendKeys("abc def");
- Assert.AreEqual("abc def", keyReporter.GetAttribute("value"));
+ Assert.That(keyReporter.GetAttribute("value"), Is.EqualTo("abc def"));
}
[Test]
@@ -85,7 +85,7 @@ public void ShouldBeAbleToTypeCapitalLetters()
IWebElement keyReporter = driver.FindElement(By.Id("keyReporter"));
keyReporter.SendKeys("ABC DEF");
- Assert.AreEqual("ABC DEF", keyReporter.GetAttribute("value"));
+ Assert.That(keyReporter.GetAttribute("value"), Is.EqualTo("ABC DEF"));
}
[Test]
@@ -96,7 +96,7 @@ public void ShouldBeAbleToTypeQuoteMarks()
IWebElement keyReporter = driver.FindElement(By.Id("keyReporter"));
keyReporter.SendKeys("\"");
- Assert.AreEqual("\"", keyReporter.GetAttribute("value"));
+ Assert.That(keyReporter.GetAttribute("value"), Is.EqualTo("\""));
}
[Test]
@@ -113,7 +113,7 @@ public void ShouldBeAbleToTypeTheAtCharacter()
IWebElement keyReporter = driver.FindElement(By.Id("keyReporter"));
keyReporter.SendKeys("@");
- Assert.AreEqual("@", keyReporter.GetAttribute("value"));
+ Assert.That(keyReporter.GetAttribute("value"), Is.EqualTo("@"));
}
[Test]
@@ -124,7 +124,7 @@ public void ShouldBeAbleToMixUpperAndLowerCaseLetters()
IWebElement keyReporter = driver.FindElement(By.Id("keyReporter"));
keyReporter.SendKeys("me@eXample.com");
- Assert.AreEqual("me@eXample.com", keyReporter.GetAttribute("value"));
+ Assert.That(keyReporter.GetAttribute("value"), Is.EqualTo("me@eXample.com"));
}
[Test]
@@ -135,7 +135,7 @@ public void ArrowKeysShouldNotBePrintable()
IWebElement keyReporter = driver.FindElement(By.Id("keyReporter"));
keyReporter.SendKeys(Keys.ArrowLeft);
- Assert.AreEqual(string.Empty, keyReporter.GetAttribute("value"));
+ Assert.That(keyReporter.GetAttribute("value"), Is.Empty);
}
[Test]
@@ -146,7 +146,7 @@ public void ShouldBeAbleToUseArrowKeys()
IWebElement keyReporter = driver.FindElement(By.Id("keyReporter"));
keyReporter.SendKeys("Tet" + Keys.ArrowLeft + "s");
- Assert.AreEqual("Test", keyReporter.GetAttribute("value"));
+ Assert.That(keyReporter.GetAttribute("value"), Is.EqualTo("Test"));
}
[Test]
@@ -158,7 +158,7 @@ public void WillSimulateAKeyUpWhenEnteringTextIntoInputElements()
element.SendKeys("I like cheese");
IWebElement result = driver.FindElement(By.Id("result"));
- Assert.AreEqual("I like cheese", result.Text);
+ Assert.That(result.Text, Is.EqualTo("I like cheese"));
}
[Test]
@@ -172,7 +172,7 @@ public void WillSimulateAKeyDownWhenEnteringTextIntoInputElements()
IWebElement result = driver.FindElement(By.Id("result"));
// Because the key down gets the result before the input element is
// filled, we're a letter short here
- Assert.AreEqual("I like chees", result.Text);
+ Assert.That(result.Text, Is.EqualTo("I like chees"));
}
[Test]
@@ -186,7 +186,7 @@ public void WillSimulateAKeyPressWhenEnteringTextIntoInputElements()
IWebElement result = driver.FindElement(By.Id("result"));
// Because the key down gets the result before the input element is
// filled, we're a letter short here
- Assert.AreEqual("I like chees", result.Text);
+ Assert.That(result.Text, Is.EqualTo("I like chees"));
}
[Test]
@@ -198,7 +198,7 @@ public void WillSimulateAKeyUpWhenEnteringTextIntoTextAreas()
element.SendKeys("I like cheese");
IWebElement result = driver.FindElement(By.Id("result"));
- Assert.AreEqual("I like cheese", result.Text);
+ Assert.That(result.Text, Is.EqualTo("I like cheese"));
}
[Test]
@@ -212,7 +212,7 @@ public void WillSimulateAKeyDownWhenEnteringTextIntoTextAreas()
IWebElement result = driver.FindElement(By.Id("result"));
// Because the key down gets the result before the input element is
// filled, we're a letter short here
- Assert.AreEqual("I like chees", result.Text);
+ Assert.That(result.Text, Is.EqualTo("I like chees"));
}
[Test]
@@ -226,7 +226,7 @@ public void WillSimulateAKeyPressWhenEnteringTextIntoTextAreas()
IWebElement result = driver.FindElement(By.Id("result"));
// Because the key down gets the result before the input element is
// filled, we're a letter short here
- Assert.AreEqual("I like chees", result.Text);
+ Assert.That(result.Text, Is.EqualTo("I like chees"));
}
[Test]
@@ -238,7 +238,7 @@ public void ShouldFireFocusKeyEventsInTheRightOrder()
IWebElement element = driver.FindElement(By.Id("theworks"));
element.SendKeys("a");
- Assert.AreEqual("focus keydown keypress keyup", result.Text.Trim());
+ Assert.That(result.Text.Trim(), Is.EqualTo("focus keydown keypress keyup"));
}
[Test]
@@ -262,7 +262,7 @@ public void ShouldReportKeyCodeOfArrowKeys()
CheckRecordedKeySequence(result, 39);
// And leave no rubbish/printable keys in the "keyReporter"
- Assert.AreEqual(string.Empty, element.GetAttribute("value"));
+ Assert.That(element.GetAttribute("value"), Is.Empty);
}
[Test]
@@ -294,7 +294,7 @@ public void ShouldReportKeyCodeOfArrowKeysUpDownEvents()
Assert.That(text, Does.Contain("up: 39"));
// And leave no rubbish/printable keys in the "keyReporter"
- Assert.AreEqual(string.Empty, element.GetAttribute("value"));
+ Assert.That(element.GetAttribute("value"), Is.Empty);
}
[Test]
@@ -307,7 +307,7 @@ public void NumericNonShiftKeys()
string numericLineCharsNonShifted = "`1234567890-=[]\\;,.'/42";
element.SendKeys(numericLineCharsNonShifted);
- Assert.AreEqual(numericLineCharsNonShifted, element.GetAttribute("value"));
+ Assert.That(element.GetAttribute("value"), Is.EqualTo(numericLineCharsNonShifted));
}
[Test]
@@ -322,7 +322,7 @@ public void NumericShiftKeys()
string numericShiftsEtc = "~!@#$%^&*()_+{}:\"<>?|END~";
element.SendKeys(numericShiftsEtc);
- Assert.AreEqual(numericShiftsEtc, element.GetAttribute("value"));
+ Assert.That(element.GetAttribute("value"), Is.EqualTo(numericShiftsEtc));
string text = result.Text.Trim();
Assert.That(text, Does.Contain(" up: 16"));
}
@@ -337,7 +337,7 @@ public void LowerCaseAlphaKeys()
String lowerAlphas = "abcdefghijklmnopqrstuvwxyz";
element.SendKeys(lowerAlphas);
- Assert.AreEqual(lowerAlphas, element.GetAttribute("value"));
+ Assert.That(element.GetAttribute("value"), Is.EqualTo(lowerAlphas));
}
[Test]
@@ -352,7 +352,7 @@ public void UppercaseAlphaKeys()
String upperAlphas = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
element.SendKeys(upperAlphas);
- Assert.AreEqual(upperAlphas, element.GetAttribute("value"));
+ Assert.That(element.GetAttribute("value"), Is.EqualTo(upperAlphas));
string text = result.Text.Trim();
Assert.That(text, Does.Contain(" up: 16"));
}
@@ -371,7 +371,7 @@ public void AllPrintableKeys()
"PQRSTUVWXYZ [\\]^_`abcdefghijklmnopqrstuvwxyz{|}~";
element.SendKeys(allPrintable);
- Assert.AreEqual(allPrintable, element.GetAttribute("value"));
+ Assert.That(element.GetAttribute("value"), Is.EqualTo(allPrintable));
string text = result.Text.Trim();
Assert.That(text, Does.Contain(" up: 16"));
}
@@ -385,7 +385,7 @@ public void ArrowKeysAndPageUpAndDown()
element.SendKeys("a" + Keys.Left + "b" + Keys.Right +
Keys.Up + Keys.Down + Keys.PageUp + Keys.PageDown + "1");
- Assert.AreEqual("ba1", element.GetAttribute("value"));
+ Assert.That(element.GetAttribute("value"), Is.EqualTo("ba1"));
}
[Test]
@@ -399,7 +399,7 @@ public void HomeAndEndAndPageUpAndPageDownKeys()
element.SendKeys("abc" + HomeKey() + "0" + Keys.Left + Keys.Right +
Keys.PageUp + Keys.PageDown + EndKey() + "1" + HomeKey() +
"0" + Keys.PageUp + EndKey() + "111" + HomeKey() + "00");
- Assert.AreEqual("0000abc1111", element.GetAttribute("value"));
+ Assert.That(element.GetAttribute("value"), Is.EqualTo("0000abc1111"));
}
[Test]
@@ -410,13 +410,13 @@ public void DeleteAndBackspaceKeys()
IWebElement element = driver.FindElement(By.Id("keyReporter"));
element.SendKeys("abcdefghi");
- Assert.AreEqual("abcdefghi", element.GetAttribute("value"));
+ Assert.That(element.GetAttribute("value"), Is.EqualTo("abcdefghi"));
element.SendKeys(Keys.Left + Keys.Left + Keys.Delete);
- Assert.AreEqual("abcdefgi", element.GetAttribute("value"));
+ Assert.That(element.GetAttribute("value"), Is.EqualTo("abcdefgi"));
element.SendKeys(Keys.Left + Keys.Left + Keys.Backspace);
- Assert.AreEqual("abcdfgi", element.GetAttribute("value"));
+ Assert.That(element.GetAttribute("value"), Is.EqualTo("abcdfgi"));
}
[Test]
@@ -427,7 +427,7 @@ public void SpecialSpaceKeys()
IWebElement element = driver.FindElement(By.Id("keyReporter"));
element.SendKeys("abcd" + Keys.Space + "fgh" + Keys.Space + "ij");
- Assert.AreEqual("abcd fgh ij", element.GetAttribute("value"));
+ Assert.That(element.GetAttribute("value"), Is.EqualTo("abcd fgh ij"));
}
[Test]
@@ -441,7 +441,7 @@ public void NumberpadKeys()
Keys.Decimal + Keys.Separator + Keys.NumberPad0 + Keys.NumberPad9 +
Keys.Add + Keys.Semicolon + Keys.Equal + Keys.Divide +
Keys.NumberPad3 + "abcd");
- Assert.AreEqual("abcd*-+.,09+;=/3abcd", element.GetAttribute("value"));
+ Assert.That(element.GetAttribute("value"), Is.EqualTo("abcd*-+.,09+;=/3abcd"));
}
[Test]
@@ -453,7 +453,7 @@ public void FunctionKeys()
element.SendKeys("FUNCTION" + Keys.F8 + "-KEYS" + Keys.F8);
element.SendKeys("" + Keys.F8 + "-TOO" + Keys.F8);
- Assert.AreEqual("FUNCTION-KEYS-TOO", element.GetAttribute("value"));
+ Assert.That(element.GetAttribute("value"), Is.EqualTo("FUNCTION-KEYS-TOO"));
}
[Test]
@@ -464,12 +464,12 @@ public void ShiftSelectionDeletes()
IWebElement element = driver.FindElement(By.Id("keyReporter"));
element.SendKeys("abcd efgh");
- Assert.AreEqual(element.GetAttribute("value"), "abcd efgh");
+ Assert.That(element.GetAttribute("value"), Is.EqualTo("abcd efgh"));
//Could be chord problem
element.SendKeys(Keys.Shift + Keys.Left + Keys.Left + Keys.Left);
element.SendKeys(Keys.Delete);
- Assert.AreEqual("abcd e", element.GetAttribute("value"));
+ Assert.That(element.GetAttribute("value"), Is.EqualTo("abcd e"));
}
[Test]
@@ -486,7 +486,7 @@ public void ChordControlHomeShiftEndDelete()
element.SendKeys(HomeKey());
element.SendKeys("" + Keys.Shift + EndKey() + Keys.Delete);
- Assert.AreEqual(string.Empty, element.GetAttribute("value"));
+ Assert.That(element.GetAttribute("value"), Is.Empty);
string text = result.Text.Trim();
Assert.That(text, Does.Contain(" up: 16"));
}
@@ -501,22 +501,22 @@ public void ChordReverseShiftHomeSelectionDeletes()
IWebElement element = driver.FindElement(By.Id("keyReporter"));
element.SendKeys("done" + HomeKey());
- Assert.AreEqual("done", element.GetAttribute("value"));
+ Assert.That(element.GetAttribute("value"), Is.EqualTo("done"));
//Sending chords
element.SendKeys("" + Keys.Shift + "ALL " + HomeKey());
- Assert.AreEqual("ALL done", element.GetAttribute("value"));
+ Assert.That(element.GetAttribute("value"), Is.EqualTo("ALL done"));
element.SendKeys(Keys.Delete);
- Assert.AreEqual("done", element.GetAttribute("value"), "done");
+ Assert.That(element.GetAttribute("value"), Is.EqualTo("done"), "done");
element.SendKeys("" + EndKey() + Keys.Shift + HomeKey());
- Assert.AreEqual("done", element.GetAttribute("value"));
+ Assert.That(element.GetAttribute("value"), Is.EqualTo("done"));
// Note: trailing SHIFT up here
string text = result.Text.Trim();
element.SendKeys("" + Keys.Delete);
- Assert.AreEqual(string.Empty, element.GetAttribute("value"));
+ Assert.That(element.GetAttribute("value"), Is.Empty);
}
[Test]
@@ -529,31 +529,31 @@ public void ChordControlCutAndPaste()
String paste = "!\"#$%&'()*+,-./0123456789:;<=>?@ ABCDEFG";
element.SendKeys(paste);
- Assert.AreEqual(paste, element.GetAttribute("value"));
+ Assert.That(element.GetAttribute("value"), Is.EqualTo(paste));
//Chords
element.SendKeys("" + HomeKey() + Keys.Shift + EndKey());
element.SendKeys(PrimaryModifier() + "x");
- Assert.AreEqual(string.Empty, element.GetAttribute("value"));
+ Assert.That(element.GetAttribute("value"), Is.Empty);
element.SendKeys(PrimaryModifier() + "v");
- Assert.AreEqual(paste, element.GetAttribute("value"));
+ Assert.That(element.GetAttribute("value"), Is.EqualTo(paste));
element.SendKeys("" + Keys.Left + Keys.Left + Keys.Left +
Keys.Shift + EndKey());
element.SendKeys(PrimaryModifier() + "x" + "v");
- Assert.AreEqual(paste, element.GetAttribute("value"));
+ Assert.That(element.GetAttribute("value"), Is.EqualTo(paste));
element.SendKeys(HomeKey());
element.SendKeys(PrimaryModifier() + "v");
element.SendKeys(PrimaryModifier() + "v" + "v");
element.SendKeys(PrimaryModifier() + "v" + "v" + "v");
- Assert.AreEqual("EFGEFGEFGEFGEFGEFG" + paste, element.GetAttribute("value"));
+ Assert.That(element.GetAttribute("value"), Is.EqualTo("EFGEFGEFGEFGEFGEFG" + paste));
element.SendKeys("" + EndKey() + Keys.Shift + HomeKey() +
Keys.Null + Keys.Delete);
- Assert.AreEqual(element.GetAttribute("value"), string.Empty);
+ Assert.That(element.GetAttribute("value"), Is.Empty);
}
[Test]
@@ -564,7 +564,7 @@ public void ShouldTypeIntoInputElementsThatHaveNoTypeAttribute()
IWebElement element = driver.FindElement(By.Id("no-type"));
element.SendKeys("Should Say Cheese");
- Assert.AreEqual("Should Say Cheese", element.GetAttribute("value"));
+ Assert.That(element.GetAttribute("value"), Is.EqualTo("Should Say Cheese"));
}
[Test]
@@ -575,7 +575,7 @@ public void ShouldNotTypeIntoElementsThatPreventKeyDownEvents()
IWebElement silent = driver.FindElement(By.Name("suppress"));
silent.SendKeys("s");
- Assert.AreEqual(string.Empty, silent.GetAttribute("value"));
+ Assert.That(silent.GetAttribute("value"), Is.Empty);
}
[Test]
@@ -596,7 +596,7 @@ public void ShouldBeAbleToTypeOnAnEmailInputField()
driver.Url = formsPage;
IWebElement email = driver.FindElement(By.Id("email"));
email.SendKeys("foobar");
- Assert.AreEqual("foobar", email.GetAttribute("value"));
+ Assert.That(email.GetAttribute("value"), Is.EqualTo("foobar"));
}
[Test]
@@ -605,7 +605,7 @@ public void ShouldBeAbleToTypeOnANumberInputField()
driver.Url = formsPage;
IWebElement numberElement = driver.FindElement(By.Id("age"));
numberElement.SendKeys("33");
- Assert.AreEqual("33", numberElement.GetAttribute("value"));
+ Assert.That(numberElement.GetAttribute("value"), Is.EqualTo("33"));
}
[Test]
@@ -624,11 +624,11 @@ public void CanSafelyTypeOnElementThatIsRemovedFromTheDomOnKeyPress()
IWebElement input = driver.FindElement(By.Id("target"));
IWebElement log = driver.FindElement(By.Id("log"));
- Assert.AreEqual("", log.GetAttribute("value"));
+ Assert.That(log.GetAttribute("value"), Is.EqualTo(""));
input.SendKeys("b");
string expected = "keydown (target)\nkeyup (target)\nkeyup (body)";
- Assert.AreEqual(expected, GetValueText(log));
+ Assert.That(GetValueText(log), Is.EqualTo(expected));
input.SendKeys("a");
@@ -647,7 +647,7 @@ public void CanClearNumberInputAfterTypingInvalidInput()
input.SendKeys("e");
input.Clear();
input.SendKeys("3");
- Assert.AreEqual("3", input.GetAttribute("value"));
+ Assert.That(input.GetAttribute("value"), Is.EqualTo("3"));
}
//------------------------------------------------------------------
@@ -684,7 +684,7 @@ public void NonPrintableCharactersShouldWorkWithContentEditableOrDesignModeSet()
element.SendKeys("Dishy" + Keys.Backspace + Keys.Left + Keys.Left);
element.SendKeys(Keys.Left + Keys.Left + "F" + Keys.Delete + EndKey() + "ee!");
- Assert.AreEqual(element.Text, "Fishee!");
+ Assert.That(element.Text, Is.EqualTo("Fishee!"));
}
[Test]
@@ -696,7 +696,7 @@ public void ShouldBeAbleToTypeIntoEmptyContentEditableElement()
editable.Clear();
editable.SendKeys("cheese"); // requires focus on OS X
- Assert.AreEqual("cheese", editable.Text);
+ Assert.That(editable.Text, Is.EqualTo("cheese"));
}
[Test]
@@ -711,7 +711,7 @@ public void ShouldBeAbleToTypeIntoContentEditableElementWithExistingValue()
string initialText = editable.Text;
editable.SendKeys(", edited");
- Assert.AreEqual(initialText + ", edited", editable.Text);
+ Assert.That(editable.Text, Is.EqualTo(initialText + ", edited"));
}
[Test]
@@ -726,7 +726,7 @@ public void ShouldBeAbleToTypeIntoTinyMCE()
editable.Clear();
editable.SendKeys("cheese"); // requires focus on OS X
- Assert.AreEqual("cheese", editable.Text);
+ Assert.That(editable.Text, Is.EqualTo("cheese"));
}
private string GetValueText(IWebElement el)
diff --git a/dotnet/test/common/UploadTest.cs b/dotnet/test/common/UploadTest.cs
index c83363c2a7b98..5608e1e5d2747 100644
--- a/dotnet/test/common/UploadTest.cs
+++ b/dotnet/test/common/UploadTest.cs
@@ -69,7 +69,7 @@ public void CleanFileInput()
IWebElement element = driver.FindElement(By.Id("upload"));
element.SendKeys(testFile.FullName);
element.Clear();
- Assert.AreEqual(string.Empty, element.GetAttribute("value"));
+ Assert.That(element.GetAttribute("value"), Is.Empty);
}
[Test]
diff --git a/dotnet/test/common/VirtualAuthn/VirtualAuthenticatorTest.cs b/dotnet/test/common/VirtualAuthn/VirtualAuthenticatorTest.cs
index e6c16e11b673a..fdfa743d4a51f 100644
--- a/dotnet/test/common/VirtualAuthn/VirtualAuthenticatorTest.cs
+++ b/dotnet/test/common/VirtualAuthn/VirtualAuthenticatorTest.cs
@@ -170,12 +170,12 @@ public void ShouldCreateAuthenticator()
object response = jsDriver.ExecuteAsyncScript(
"registerCredential().then(arguments[arguments.length - 1]);");
- Assert.AreEqual("OK", ((Dictionary)response)["status"]);
+ Assert.That((Dictionary)response, Does.ContainKey("status").WithValue("OK"));
object assertionResponse = GetAssertionFor(ExtractRawIdFrom(response));
// Attempt to use the credential to get an assertion.
- Assert.AreEqual("OK", ((Dictionary)assertionResponse)["status"]);
+ Assert.That((Dictionary)assertionResponse, Does.ContainKey("status").WithValue("OK"));
}
[Test]
@@ -191,7 +191,27 @@ public void ShouldRemoveAuthenticator()
webDriver.RemoveVirtualAuthenticator(authenticatorId);
- Assert.IsNull(webDriver.AuthenticatorId);
+ Assert.That(webDriver.AuthenticatorId, Is.Null);
+ }
+
+ [Test]
+ [NeedsFreshDriver(IsCreatedAfterTest = true)]
+ [IgnoreBrowser(Selenium.Browser.IE, "IE does not support Virtual Authenticator")]
+ [IgnoreBrowser(Selenium.Browser.Firefox, "Firefox does not support Virtual Authenticator")]
+ [IgnoreBrowser(Selenium.Browser.Safari, "Safari does not support Virtual Authenticator")]
+ public void ShouldSupportMultipleVirtualAuthenticatorsAtOnce()
+ {
+ VirtualAuthenticatorOptions options = new VirtualAuthenticatorOptions();
+
+ string authenticatorId1 = webDriver.AddVirtualAuthenticator(options);
+ Assert.That(webDriver.AuthenticatorId, Is.EqualTo(authenticatorId1));
+
+ string authenticatorId2 = webDriver.AddVirtualAuthenticator(options);
+
+ webDriver.RemoveVirtualAuthenticator(authenticatorId1);
+ webDriver.RemoveVirtualAuthenticator(authenticatorId2);
+
+ Assert.That(webDriver.AuthenticatorId, Is.Null);
}
[Test]
@@ -216,7 +236,7 @@ public void ShouldAddNonResidentCredential()
// Attempt to use the credential to generate an assertion.
object response = GetAssertionFor(id);
- Assert.AreEqual("OK", ((Dictionary)response)["status"]);
+ Assert.That((Dictionary)response, Does.ContainKey("status").WithValue("OK"));
}
[Test]
@@ -248,7 +268,7 @@ public void ShouldAddNonResidentCredentialWhenAuthenticatorUsesU2FProtocol()
// Attempt to use the credential to generate an assertion.
object response = GetAssertionFor(id);
- Assert.AreEqual("OK", ((Dictionary)response)["status"]);
+ Assert.That((Dictionary)response, Does.ContainKey("status").WithValue("OK"));
}
[Test]
@@ -272,14 +292,14 @@ public void ShouldAddResidentCredential()
// empty allowCredentials array.
object response = jsDriver.ExecuteAsyncScript(
"getCredential([]).then(arguments[arguments.length - 1]);");
- Assert.AreEqual("OK", ((Dictionary)response)["status"]);
+ Assert.That(((Dictionary)response)["status"], Is.EqualTo("OK"));
Dictionary attestation = (Dictionary)((Dictionary)response)["attestation"];
ReadOnlyCollection returnedUserHandle = (ReadOnlyCollection)attestation["userHandle"];
- Assert.AreEqual(1, returnedUserHandle.Count);
- Assert.AreEqual(0, returnedUserHandle.IndexOf(1L));
+ Assert.That(returnedUserHandle, Has.One.Items);
+ Assert.That(returnedUserHandle.IndexOf(1L), Is.Zero);
}
[Test]
@@ -302,7 +322,9 @@ public void AddResidentCredentialNotSupportedWhenAuthenticatorUsesU2FProtocol()
byte[] userHandle = { 1 };
Credential credential = Credential.CreateResidentCredential(
credentialId, "localhost", base64EncodedEC256PK, userHandle, /*signCount=*/0);
- Assert.Throws(() => webDriver.AddCredential(credential));
+ Assert.That(
+ () => webDriver.AddCredential(credential),
+ Throws.TypeOf().With.Message.Contains("The Authenticator does not support Resident Credentials."));
}
[Test]
@@ -319,21 +341,21 @@ public void ShouldGetCredential()
object response1 = jsDriver.ExecuteAsyncScript(
"registerCredential({authenticatorSelection: {requireResidentKey: true}})"
+ " .then(arguments[arguments.length - 1]);");
- Assert.AreEqual("OK", ((Dictionary)response1)["status"]);
+ Assert.That((Dictionary)response1, Does.ContainKey("status").WithValue("OK"));
// Register a non resident credential.
object response2 = jsDriver.ExecuteAsyncScript(
"registerCredential().then(arguments[arguments.length - 1]);");
- Assert.AreEqual("OK", ((Dictionary)response2)["status"]);
+ Assert.That((Dictionary)response2, Does.ContainKey("status").WithValue("OK"));
byte[] credential1Id = ConvertListIntoArrayOfBytes(ExtractRawIdFrom(response1));
byte[] credential2Id = ConvertListIntoArrayOfBytes(ExtractRawIdFrom(response2));
- Assert.AreNotEqual(credential1Id, credential2Id);
+ Assert.That(credential2Id, Is.Not.EqualTo(credential1Id));
// Retrieve the two credentials.
List credentials = webDriver.GetCredentials();
- Assert.AreEqual(2, credentials.Count);
+ Assert.That(credentials, Has.Exactly(2).Items);
Credential credential1 = null;
Credential credential2 = null;
@@ -353,11 +375,11 @@ public void ShouldGetCredential()
}
}
- Assert.True(credential1.IsResidentCredential);
- Assert.NotNull(credential1.PrivateKey);
+ Assert.That(credential1.IsResidentCredential, Is.True);
+ Assert.That(credential1.PrivateKey, Is.Not.Null);
- Assert.False(credential2.IsResidentCredential);
- Assert.NotNull(credential2.PrivateKey);
+ Assert.That(credential2.IsResidentCredential, Is.False);
+ Assert.That(credential2.PrivateKey, Is.Not.Null);
}
[Test]
@@ -373,7 +395,7 @@ public void ShouldRemoveCredentialByRawId()
object response = jsDriver.ExecuteAsyncScript(
"registerCredential().then(arguments[arguments.length - 1]);");
- Assert.AreEqual("OK", ((Dictionary)response)["status"]);
+ Assert.That((Dictionary)response, Does.ContainKey("status").WithValue("OK"));
// Remove a credential by its ID as an array of bytes.
List rawId = ExtractRawIdFrom(response);
@@ -384,7 +406,7 @@ public void ShouldRemoveCredentialByRawId()
object assertionResponse = GetAssertionFor(rawId);
string error = (string)((Dictionary)assertionResponse)["status"];
- Assert.True(error.StartsWith("NotAllowedError"));
+ Assert.That(error, Does.StartWith("NotAllowedError"));
}
[Test]
@@ -400,7 +422,7 @@ public void ShouldRemoveCredentialByBase64UrlId()
object response = jsDriver.ExecuteAsyncScript(
"registerCredential().then(arguments[arguments.length - 1]);");
- Assert.AreEqual("OK", ((Dictionary)response)["status"]);
+ Assert.That((Dictionary)response, Does.ContainKey("status").WithValue("OK"));
// Remove a credential by its base64url ID.
String credentialId = ExtractIdFrom(response);
@@ -410,7 +432,7 @@ public void ShouldRemoveCredentialByBase64UrlId()
object assertionResponse = GetAssertionFor(credentialId);
string error = (string)((Dictionary)assertionResponse)["status"];
- Assert.True(error.StartsWith("NotAllowedError"));
+ Assert.That(error, Does.StartWith("NotAllowedError"));
}
[Test]
@@ -425,12 +447,12 @@ public void ShouldRemoveAllCredentials()
// Register two credentials.
object response1 = jsDriver.ExecuteAsyncScript(
"registerCredential().then(arguments[arguments.length - 1]);");
- Assert.AreEqual("OK", ((Dictionary)response1)["status"]);
+ Assert.That((Dictionary)response1, Does.ContainKey("status").WithValue("OK"));
List rawId1 = ExtractRawIdFrom(response1);
object response2 = jsDriver.ExecuteAsyncScript(
"registerCredential().then(arguments[arguments.length - 1]);");
- Assert.AreEqual("OK", ((Dictionary)response2)["status"]);
+ Assert.That((Dictionary)response2, Does.ContainKey("status").WithValue("OK"));
List rawId2 = ExtractRawIdFrom(response1);
// Remove all credentials.
@@ -449,7 +471,7 @@ public void ShouldRemoveAllCredentials()
string error = (string)((Dictionary)response)["status"];
- Assert.True(error.StartsWith("NotAllowedError"));
+ Assert.That(error, Does.StartWith("NotAllowedError"));
}
[Test]
@@ -465,7 +487,7 @@ public void testSetUserVerified()
Object response = jsDriver.ExecuteAsyncScript(
"registerCredential({authenticatorSelection: {userVerification: 'required'}})"
+ " .then(arguments[arguments.length - 1]);");
- Assert.AreEqual("OK", ((Dictionary)response)["status"]);
+ Assert.That((Dictionary)response, Does.ContainKey("status").WithValue("OK"));
List rawId = ExtractRawIdFrom(response);
// Getting an assertion requiring user verification should succeed.
@@ -475,7 +497,7 @@ public void testSetUserVerified()
+ " \"id\": Int8Array.from(arguments[0]),"
+ "}], {userVerification: 'required'}).then(arguments[arguments.length - 1]);",
rawId);
- Assert.AreEqual("OK", ((Dictionary)response)["status"]);
+ Assert.That((Dictionary)response, Does.ContainKey("status").WithValue("OK"));
// Disable user verification.
webDriver.SetUserVerified(false);
@@ -490,7 +512,39 @@ public void testSetUserVerified()
string error = (string)((Dictionary)response)["status"];
- Assert.True(error.StartsWith("NotAllowedError"));
+ Assert.That(error, Does.StartWith("NotAllowedError"));
+ }
+
+ [Test]
+ [NeedsFreshDriver(IsCreatedAfterTest = true)]
+ [IgnoreBrowser(Selenium.Browser.IE, "IE does not support Virtual Authenticator")]
+ [IgnoreBrowser(Selenium.Browser.Firefox, "Firefox does not support Virtual Authenticator")]
+ [IgnoreBrowser(Selenium.Browser.Safari, "Safari does not support Virtual Authenticator")]
+ public void ShouldThrowOnInvalidArguments()
+ {
+ Assert.That(
+ () => webDriver.AddVirtualAuthenticator(null),
+ Throws.ArgumentNullException);
+
+ Assert.That(
+ () => webDriver.RemoveVirtualAuthenticator(null),
+ Throws.ArgumentNullException);
+
+ Assert.That(
+ () => webDriver.AddCredential(null),
+ Throws.ArgumentNullException);
+
+ Assert.That(
+ () => webDriver.RemoveCredential((byte[])null),
+ Throws.ArgumentNullException);
+
+ Assert.That(
+ () => webDriver.RemoveCredential((string)null),
+ Throws.ArgumentNullException);
+
+ Assert.That(
+ () => webDriver.RemoveVirtualAuthenticator("non-existant"),
+ Throws.TypeOf());
}
}
}
diff --git a/dotnet/test/common/VisibilityTest.cs b/dotnet/test/common/VisibilityTest.cs
index a48e785e95f8b..527699e6d8f88 100644
--- a/dotnet/test/common/VisibilityTest.cs
+++ b/dotnet/test/common/VisibilityTest.cs
@@ -111,8 +111,8 @@ public void ZeroSizedDivIsShownIfDescendantHasSize()
IWebElement element = driver.FindElement(By.Id("zero"));
Size size = element.Size;
- Assert.AreEqual(0, size.Width, "Should have 0 width");
- Assert.AreEqual(0, size.Height, "Should have 0 height");
+ Assert.That(size.Width, Is.Zero, "Should have 0 width");
+ Assert.That(size.Height, Is.Zero, "Should have 0 height");
Assert.That(element.Displayed, Is.True);
}
@@ -268,9 +268,9 @@ public void ShouldBeAbleToClickOnElementsWithOpacityZero()
driver.Url = clickJackerPage;
IWebElement element = driver.FindElement(By.Id("clickJacker"));
- Assert.AreEqual("0", element.GetCssValue("opacity"), "Precondition failed: clickJacker should be transparent");
+ Assert.That(element.GetCssValue("opacity"), Is.EqualTo("0"), "Precondition failed: clickJacker should be transparent");
element.Click();
- Assert.AreEqual("1", element.GetCssValue("opacity"));
+ Assert.That(element.GetCssValue("opacity"), Is.EqualTo("1"));
}
[Test]
diff --git a/dotnet/test/common/WebElementTest.cs b/dotnet/test/common/WebElementTest.cs
index 5da1ec406f1be..9fcf68ee1b0f4 100644
--- a/dotnet/test/common/WebElementTest.cs
+++ b/dotnet/test/common/WebElementTest.cs
@@ -68,7 +68,7 @@ public void ShouldGetElementName()
driver.Url = simpleTestPage;
IWebElement oneliner = driver.FindElement(By.Id("oneline"));
- Assert.AreEqual("p", oneliner.TagName.ToLower());
+ Assert.That(oneliner.TagName, Is.EqualTo("p").IgnoreCase);
}
@@ -78,12 +78,12 @@ public void ShouldGetElementText()
driver.Url = simpleTestPage;
IWebElement oneliner = driver.FindElement(By.Id("oneline"));
- Assert.AreEqual("A single line of text", oneliner.Text);
+ Assert.That(oneliner.Text, Is.EqualTo("A single line of text"));
IWebElement twoblocks = driver.FindElement(By.Id("twoblocks"));
- Assert.AreEqual("Some text" +
+ Assert.That(twoblocks.Text, Is.EqualTo("Some text" +
System.Environment.NewLine +
- "Some more text", twoblocks.Text);
+ "Some more text"));
}
@@ -110,7 +110,7 @@ public void ShouldClearElement()
IWebElement textbox = driver.FindElement(By.Id("keyUp"));
textbox.SendKeys("a@#$ç.ó");
textbox.Clear();
- Assert.AreEqual("", textbox.GetAttribute("value"));
+ Assert.That(textbox.GetAttribute("value"), Is.Empty);
}
[Test]
@@ -121,7 +121,7 @@ public void ShouldClearRenderedElement()
IWebElement textbox = driver.FindElement(By.Id("keyUp"));
textbox.SendKeys("a@#$ç.ó");
textbox.Clear();
- Assert.AreEqual("", textbox.GetAttribute("value"));
+ Assert.That(textbox.GetAttribute("value"), Is.Empty);
}
[Test]
@@ -131,7 +131,7 @@ public void ShouldSendKeysToElement()
IWebElement textbox = driver.FindElement(By.Id("keyUp"));
textbox.SendKeys("a@#$ç.ó");
- Assert.AreEqual("a@#$ç.ó", textbox.GetAttribute("value"));
+ Assert.That(textbox.GetAttribute("value"), Is.EqualTo("a@#$ç.ó"));
}
[Test]
@@ -152,7 +152,7 @@ public void ShouldClickLinkElement()
IWebElement changedDiv = driver.FindElement(By.Id("dynamo"));
IWebElement link = driver.FindElement(By.LinkText("Update a div"));
link.Click();
- Assert.AreEqual("Fish and chips!", changedDiv.Text);
+ Assert.That(changedDiv.Text, Is.EqualTo("Fish and chips!"));
}
[Test]
@@ -162,8 +162,8 @@ public void ShouldGetAttributesFromElement()
IWebElement dynamo = driver.FindElement(By.Id("dynamo"));
IWebElement mousedown = driver.FindElement(By.Id("mousedown"));
- Assert.AreEqual("mousedown", mousedown.GetAttribute("id"));
- Assert.AreEqual("dynamo", dynamo.GetAttribute("id"));
+ Assert.That(mousedown.GetAttribute("id"), Is.EqualTo("mousedown"));
+ Assert.That(dynamo.GetAttribute("id"), Is.EqualTo("dynamo"));
}
}
diff --git a/dotnet/test/common/WindowSwitchingTest.cs b/dotnet/test/common/WindowSwitchingTest.cs
index ab153b8377a50..9128351111f67 100644
--- a/dotnet/test/common/WindowSwitchingTest.cs
+++ b/dotnet/test/common/WindowSwitchingTest.cs
@@ -36,23 +36,23 @@ public void ShouldSwitchFocusToANewWindowWhenItIsOpenedAndNotStopFutureOperation
String current = driver.CurrentWindowHandle;
driver.FindElement(By.LinkText("Open new window")).Click();
- Assert.AreEqual("XHTML Test Page", driver.Title);
+ Assert.That(driver.Title, Is.EqualTo("XHTML Test Page"));
WaitFor(WindowCountToBe(2), "Window count was not 2");
WaitFor(WindowWithName("result"), "Could not find window with name 'result'");
WaitFor(() => { return driver.Title == "We Arrive Here"; }, "Browser title was not 'We Arrive Here'");
- Assert.AreEqual("We Arrive Here", driver.Title);
+ Assert.That(driver.Title, Is.EqualTo("We Arrive Here"));
driver.Url = iframesPage;
string handle = driver.CurrentWindowHandle;
driver.FindElement(By.Id("iframe_page_heading"));
driver.SwitchTo().Frame("iframe1");
- Assert.AreEqual(driver.CurrentWindowHandle, handle);
+ Assert.That(handle, Is.EqualTo(driver.CurrentWindowHandle));
driver.SwitchTo().DefaultContent();
driver.Close();
driver.SwitchTo().Window(current);
- //Assert.AreEqual("XHTML Test Page", driver.Title);
+ //Assert.That(driver.Title, Is.EqualTo("TML Test Page"));
}
[Test]
@@ -79,7 +79,7 @@ public void ShouldThrowNoSuchWindowExceptionOnAnAttemptToGetItsHandle()
driver.FindElement(By.LinkText("Open new window")).Click();
WaitFor(WindowCountToBe(2), "Window count was not 2");
- Assert.AreEqual(2, driver.WindowHandles.Count);
+ Assert.That(driver.WindowHandles, Has.Exactly(2).Items);
WaitFor(WindowWithName("result"), "Could not find window with name 'result'");
driver.SwitchTo().Window("result");
@@ -108,7 +108,7 @@ public void ShouldThrowNoSuchWindowExceptionOnAnyOperationIfAWindowIsClosed()
driver.FindElement(By.LinkText("Open new window")).Click();
WaitFor(WindowCountToBe(2), "Window count was not 2");
- Assert.AreEqual(2, driver.WindowHandles.Count);
+ Assert.That(driver.WindowHandles, Has.Exactly(2).Items);
WaitFor(WindowWithName("result"), "Could not find window with name 'result'");
driver.SwitchTo().Window("result");
@@ -141,7 +141,7 @@ public void ShouldThrowNoSuchWindowExceptionOnAnyElementOperationIfAWindowIsClos
driver.FindElement(By.LinkText("Open new window")).Click();
WaitFor(WindowCountToBe(2), "Window count was not 2");
- Assert.AreEqual(2, driver.WindowHandles.Count);
+ Assert.That(driver.WindowHandles, Has.Exactly(2).Items);
WaitFor(WindowWithName("result"), "Could not find window with name 'result'");
driver.SwitchTo().Window("result");
@@ -182,7 +182,7 @@ public void ShouldBeAbleToIterateOverAllOpenWindows()
seenHandles.Add(handle);
}
- Assert.AreEqual(3, allWindowHandles.Count);
+ Assert.That(allWindowHandles, Has.Exactly(3).Items);
}
[Test]
@@ -265,7 +265,7 @@ public void FailingToSwitchToAWindowLeavesTheCurrentWindowAsIs()
String newHandle = driver.CurrentWindowHandle;
- Assert.AreEqual(current, newHandle);
+ Assert.That(newHandle, Is.EqualTo(current));
}
[Test]
@@ -281,7 +281,7 @@ public void CanCloseWindowWhenMultipleWindowsAreOpen()
ReadOnlyCollection allWindowHandles = driver.WindowHandles;
// There should be two windows. We should also see each of the window titles at least once.
- Assert.AreEqual(2, allWindowHandles.Count);
+ Assert.That(allWindowHandles, Has.Exactly(2).Items);
string handle1 = allWindowHandles[1];
driver.SwitchTo().Window(handle1);
driver.Close();
@@ -289,7 +289,7 @@ public void CanCloseWindowWhenMultipleWindowsAreOpen()
WaitFor(WindowCountToBe(1), "Window count was not 1");
allWindowHandles = driver.WindowHandles;
- Assert.AreEqual(1, allWindowHandles.Count);
+ Assert.That(allWindowHandles, Has.One.Items);
}
[Test]
@@ -309,7 +309,7 @@ public void CanCloseWindowAndSwitchBackToMainWindow()
ReadOnlyCollection