Skip to content

Add tested Java and JavaScript examples for the Expected Conditions page - #3009

Open
Mohsintl wants to merge 3 commits into
SeleniumHQ:trunkfrom
Mohsintl:expected-conditions-examples
Open

Mohsintl wants to merge 3 commits into
SeleniumHQ:trunkfrom
Mohsintl:expected-conditions-examples

Conversation

@Mohsintl

@Mohsintl Mohsintl commented Nov 23, 2026 •

Copy link
Copy Markdown

Thanks for contributing to the Selenium site and documentation!
A PR well described will help maintainers to review and merge it quickly

Description

Part of #2890. The Expected Conditions page showed "add example" in the Java and JavaScript tabs, and ExpectedConditionsTest.java was an empty stub.

  • Java (examples/java/src/test/java/dev/selenium/support/ExpectedConditionsTest.java): waits with ExpectedConditions.visibilityOfElementLocated.
  • JavaScript (examples/javascript/test/support/expectedConditions.spec.js, new): waits with until.elementIsVisible.
  • Both follow the existing Python example: open dynamic.html, click Reveal, wait for the revealed input, type into it and assert the value, so a broken example fails CI.
  • The page shows only the wait lines, like the Python tab, in the en, ja, pt-br and zh-cn files. Kotlin keeps its placeholder.

Motivation and Context

#2890 asks to complete the examples for the pages in llms.txt; the Expected Conditions page is one of them.

Types of changes

  • Change to the site (I have double-checked the Netlify deployment, and my changes look good)
  • Code example added (and I also added the example to all translated languages)
  • Improved translation
  • Added new translation (and I also added a notice to each document missing translation)

Checklist

  • I have read the contributing document.
  • I have used hugo to render the site/docs locally and I am sure it works.

I ran both tests locally with Chrome: the Java test with Maven (1/1) and the JavaScript test with mocha (1/1). I did not render the site with Hugo locally; I'll check the Netlify preview.

The Java and JavaScript tabs on the Expected Conditions page showed
placeholders, and ExpectedConditionsTest.java was an empty stub. Both
now hold a test that waits for a revealed element with an expected
condition, like the Python example, and the page renders them in all
translations.
@netlify

netlify Bot commented Nov 23, 2026 •

Copy link
Copy Markdown

👷 Deploy request for selenium-dev pending review.

Visit the deploys page to approve it

Name Link
🔨 Latest commit a8ed36f

@qodo-code-review

Copy link
Copy Markdown
Contributor

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

@rpallavisharma

Copy link
Copy Markdown
Member

@Mohsintl , please see two tests are failing. Check the error logs -
java.lang.NullPointerException: Cannot invoke "String.contains(java.lang.CharSequence)" because the return value of "org.openqa.selenium.WebDriver.getPageSource()" is null
at dev.selenium.bidirectional.webdriver_bidi.NetworkCommandsTest.canContinueWithoutAuthCredentials(NetworkCommandsTest.java:79)

@Mohsintl

Copy link
Copy Markdown
Author

Thanks for checking! The failing test is NetworkCommandsTest.canContinueWithoutAuthCredentials (BiDi), which this PR doesn't touch. It also fails on trunk without these changes, for example in this trunk (run). The new ExpectedConditionsTest passed on Windows stable, Windows nightly and Ubuntu stable. The Ubuntu nightly test step exited with no output in its log, so I can't tell what failed there. Could you re-run the failed jobs?

@rpallavisharma

Copy link
Copy Markdown
Member

@Mohsintl , a feedback and request, try to make small PRs. pick one language and provide the missing example code and update the gh code block lines. for example in this you are attempting both Java and JS.
Error is still coming , please check and verify thanks.

@rpallavisharma

Copy link
Copy Markdown
Member

The Windows job failed in Run Tests Stable (in Maven): NetworkCommandsTest.canContinueWithoutAuthCredentials errored on all four attempts. The key error was: getPageSource() returned null, so the test’s .contains(...) call threw a NullPointerException. This points to a test or application behavior issue rather than a runner setup failure.
Generated by AI. The question is, why is it then passing in other environments?

Please see and verify. thanks

@Mohsintl

Copy link
Copy Markdown
Author

Thanks for the feedback! I'll keep future PRs small, one language each.

Good question about the error. This test is flaky and not related to my changes: AutomatedTester confirmed on #3000 that NetworkCommandsTest.canContinueWithoutAuthCredentials also fails on trunk and on other open PRs, and this PR doesn't touch it. If it helps, I'd be happy to dig into the flaky test in a separate small PR.

@rpallavisharma

Copy link
Copy Markdown
Member

@SeleniumHQ/selenium-tlc please see.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants