Repository navigation
Conversation
The Listeners page showed placeholders in every language, and the Java and Python example files were empty stubs. Both now hold a listener that records a navigation and a click, and a test that registers it on the driver and checks the events. The page renders them in all translations.
👷 Deploy request for selenium-dev pending review.Visit the deploys page to approve it
|
Qodo reviews are paused for this user.Troubleshooting steps vary by plan Learn more → On a Teams plan? Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center? |
|
@Mohsintl - please see error - |
|
Thanks! Both failures are in tests this PR doesn't change: InternetExplorerTest.basicOptionsWin11 couldn't start an IE session on the Windows runner, and NetworkCommandsTest.canContinueWithoutAuthCredentials also fails on trunk (run). ListenersTest passed on every job. Could you re-run the failed jobs? |
AutomatedTester
left a comment
There was a problem hiding this comment.
Thanks @Mohsintl, this looks good. I checked it against .github/pr_review.md:
- The
gh-codeblockranges are right in all four translations: Java#L16-L29is the listener class (with thepubliccomment) and#L33-L37is the registration; Python#L5-L13and#L17-L21match the same two parts. No lines are indented and thetabpanekeepstext=true. - Both tests assert the recorded events, so a broken example will fail CI, and they use
formPage.htmlfrom the Selenium test pages.
Minor (not blocking): ListenersTest.java line 27 uses element.getAttribute("id"), which is deprecated in Selenium Java since 4.27. Because that line is shown on the page, readers will copy it. element.getDomAttribute("id") returns the same value here and keeps the example on the current API.
About the red tests (windows, stable) job: it is not caused by this PR. InternetExplorerTest.basicOptionsWin11 timed out starting IE on the first try, then passed on the retry, so Surefire lists it under "Flakes". The job failed because NetworkCommandsTest.canContinueWithoutAuthCredentials failed all 4 attempts with a null page source; the same test fails on trunk (run 45135567526 and recent scheduled runs) and on other open PRs. ListenersTest passed on every job.
Generated by Claude Code
getAttribute is deprecated in Selenium Java since 4.27, and this line is shown on the Listeners page.
|
Thanks for the review and the getAttribute tip, and the update about deprecation! Switched to getDomAttribute("id") in 2d1d4b3, same line, so the page range is unchanged and the test still passes. |
|
@SeleniumHQ/selenium-tlc please see. |
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 Command Listeners page showed "add example" in every language, and
ListenersTest.javaandtest_listener.pywere empty stubs.examples/python/tests/support/test_listener.py): aRecordingListener(AbstractEventListener)withafter_navigate_toandbefore_click, registered withEventFiringWebDriver.examples/java/src/test/java/dev/selenium/support/ListenersTest.java): the same listener as aWebDriverListener, registered withEventFiringDecorator.formPage.html, click a checkbox and assert the recorded events, so a broken example fails CI.en,ja,pt-brandzh-cnfiles. C#, Ruby, JavaScript and Kotlin keep their placeholders.One thing worth knowing for Java:
EventFiringDecoratorcalls listener methods through reflection, so a listener class that is notpublicis skipped without any error (the events list stays empty). The example says so in a one-line comment, which shows on the page in every translation.Motivation and Context
#2890 asks to complete the examples for the pages in
llms.txt; the Listeners page is one of them.Types of changes
Checklist
I ran the tests locally (Selenium 4.52, Chrome): the Python test with pytest 4/4 and the Java test with Maven. With the click sent through the undecorated driver, both fail on the missing click event. I did not render the site with Hugo locally; I'll check the Netlify preview.