Skip to content

Conversation

@HaniASU
Copy link

@HaniASU HaniASU commented Sep 8, 2025

User description

What
Update the support URL in NoSuchElementException to use the non-hyphen docs anchor:

  • #nosuchelementexception

Why
The Selenium docs use lowercase exception names without hyphens for section anchors.
Old link (#no-such-element-exception) doesn’t match and drops users at the top.

How I tested

Scope

  • No changes to other exceptions.

Fixes #16302 16302


PR Type

Bug fix


Description

  • Update NoSuchElementException support URL anchor

  • Fix broken documentation links in error messages

  • Update test expectations to match new URL format


Diagram Walkthrough

flowchart LR
  A["Old anchor: #no-such-element-exception"] --> B["New anchor: #nosuchelementexception"]
  B --> C["Updated Java exception"]
  B --> D["Updated .NET exception"]
  B --> E["Updated Ruby exception"]
  B --> F["Updated test expectations"]
Loading

File Walkthrough

Relevant files
Bug fix
NoSuchElementException.java
Update Java exception support URL anchor                                 

java/src/org/openqa/selenium/NoSuchElementException.java

  • Changed SUPPORT_URL anchor from "#no-such-element-exception" to
    "#nosuchelementexception"
+1/-1     
NoSuchElementException.cs
Update .NET exception support URL anchor                                 

dotnet/src/webdriver/NoSuchElementException.cs

  • Changed supportUrl anchor from "#no-such-element-exception" to
    "#nosuchelementexception"
+1/-1     
error.rb
Update Ruby error URL mapping                                                       

rb/lib/selenium/webdriver/common/error.rb

  • Changed NoSuchElementError URL mapping from
    "#no-such-element-exception" to "#nosuchelementexception"
+1/-1     
Tests
RelativeLocatorTest.cs
Update .NET test URL expectation                                                 

dotnet/test/common/RelativeLocatorTest.cs

  • Updated test assertion to expect new URL format in exception message
+1/-1     
driver_spec.rb
Update Ruby driver test URL expectation                                   

rb/spec/integration/selenium/webdriver/driver_spec.rb

  • Updated test regex to match new URL format in error message
+1/-1     
error_spec.rb
Update Ruby error test URL expectation                                     

rb/spec/integration/selenium/webdriver/error_spec.rb

  • Updated test regex to match new URL format in error message
+1/-1     

Switch support URL anchor from #no-such-element-exception → #nosuchelementexception
to match Selenium docs. Scope: NoSuchElementException only.
@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@selenium-ci selenium-ci added C-rb Ruby Bindings C-dotnet .NET Bindings C-java Java Bindings labels Sep 8, 2025
@qodo-merge-pro
Copy link
Contributor

qodo-merge-pro bot commented Sep 8, 2025

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

⏱️ Estimated effort to review: 1 🔵⚪⚪⚪⚪
🧪 PR contains tests
🔒 No security concerns identified
⚡ Recommended focus areas for review

Consistency

Verify other exception classes use the correct non-hyphen anchors as well to maintain consistency across the codebase and docs links.

private static final String SUPPORT_URL = BASE_SUPPORT_URL + "#nosuchelementexception";
Immutability

Consider making the C# support URL field readonly/const (if possible) to match its constant nature and prevent unintended mutation.

private static string supportUrl = baseSupportUrl + "#nosuchelementexception";

@qodo-merge-pro
Copy link
Contributor

qodo-merge-pro bot commented Sep 8, 2025

PR Code Suggestions ✨

Explore these optional code suggestions:

CategorySuggestion                                                                                                                                    Impact
Possible issue
Normalize URL before fragment

Normalize the base URL before appending the fragment to avoid producing
'.../errors/#nosuchelementexception' when baseSupportUrl ends with a slash. Trim
the trailing slash so the generated link consistently matches tests and docs.

dotnet/src/webdriver/NoSuchElementException.cs [34]

-private static string supportUrl = baseSupportUrl + "#nosuchelementexception";
+private static string supportUrl = baseSupportUrl.TrimEnd('/') + "#nosuchelementexception";
  • Apply / Chat
Suggestion importance[1-10]: 6

__

Why: The suggestion improves robustness by ensuring the constructed URL is always correct, even if the baseSupportUrl has an unexpected trailing slash.

Low
Strip trailing slash before fragment

Guard against a trailing slash in BASE_SUPPORT_URL to prevent generating
'.../errors/#nosuchelementexception', which may not match assertions and can
vary across environments. Normalize by stripping a trailing slash before
appending the fragment.

java/src/org/openqa/selenium/NoSuchElementException.java [30]

-private static final String SUPPORT_URL = BASE_SUPPORT_URL + "#nosuchelementexception";
+private static final String SUPPORT_URL =
+    (BASE_SUPPORT_URL.endsWith("/") ? BASE_SUPPORT_URL.substring(0, BASE_SUPPORT_URL.length() - 1) : BASE_SUPPORT_URL)
+        + "#nosuchelementexception";
  • Apply / Chat
Suggestion importance[1-10]: 6

__

Why: The suggestion improves robustness by ensuring the constructed URL is always correct, even if the BASE_SUPPORT_URL has an unexpected trailing slash.

Low
General
Relax test for optional slash

Make the assertion resilient to an optional slash before the fragment to reduce
brittleness if the base URL definition changes. Use a regex match that allows an
optional '/' before #nosuchelementexception while still validating the full
message.

dotnet/test/common/RelativeLocatorTest.cs [227]

-}, Throws.TypeOf<NoSuchElementException>().With.Message.EqualTo("Unable to find element; For documentation on this error, please visit: https://www.selenium.dev/documentation/webdriver/troubleshooting/errors#nosuchelementexception"));
+}, Throws.TypeOf<NoSuchElementException>().With.Message.Matches(@"^Unable to find element; For documentation on this error, please visit: https://www\.selenium\.dev/documentation/webdriver/troubleshooting/errors/?#nosuchelementexception$"));
  • Apply / Chat
Suggestion importance[1-10]: 5

__

Why: The suggestion improves test resilience by using a regular expression to handle potential variations in the URL, making the test less brittle to changes in baseSupportUrl.

Low
Learned
best practice
Use interpolation and readonly

Prefer C# string interpolation for clarity and mark the field readonly to
prevent accidental reassignment.

dotnet/src/webdriver/NoSuchElementException.cs [34]

-private static string supportUrl = baseSupportUrl + "#nosuchelementexception";
+private static readonly string supportUrl = $"{baseSupportUrl}#nosuchelementexception";
  • Apply / Chat
Suggestion importance[1-10]: 5

__

Why:
Relevant best practice - Use language-appropriate string interpolation and prefer immutable fields for constant values.

Low
  • More

@HaniASU HaniASU deleted the fix/support-url-anchors branch September 8, 2025 15:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

C-dotnet .NET Bindings C-java Java Bindings C-rb Ruby Bindings Review effort 1/5

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[🐛 Bug]: [java][rb][dotnet] Exception support URLs use hyphenated anchors that don’t exist in docs

3 participants