Skip to content

[πŸ› Bug]: find-elements-fragment has an issue with JSONΒ #12549

@jlipps

Description

@jlipps

What happened?

I generated find-element-fragment.js and pasted it into a browser. One line (minified it looks like the only line in the fragment that includes ba.JSON.stringify) seems to host this bug: ba is undefined.

Reading the minified code as best I can, it looks like ba is either document or window.navigator. Neither of these host the JSON global (it is on window, I think).

Removing ba. from the line so that it references JSON as a pure global fixes the issue.

I'm not sure how to navigate the whole Google Closure Compiler situation. A quick grep of the codebase for a fixable line only showed up goog.global.JSON. Perhaps this issue is internal to the Compiler?

How can we reproduce the issue?

1. Generate the fragment with `bazel build //javascript/webdriver/atoms/inject/...`
2. Copy the contents of the built `find-element-fragment.js` file into a browser console
3. Invoke the pasted contents as an IIFE with some params (like `'css selector', 'body'`)
4. Observe the error

Relevant log output

VM368:1631 Uncaught TypeError: Cannot read properties of undefined (reading 'stringify')
    at Object.<anonymous> (<anonymous>:1631:26)
    at findElement (<anonymous>:2633:8)
    at <anonymous>:1:1

Operating System

macOS

Selenium version

4.11.0

What are the browser(s) and version(s) where you see this issue?

Chrome, Safari

What are the browser driver(s) and version(s) where you see this issue?

N/A

Are you using Selenium Grid?

N/A

Metadata

Metadata

Assignees

No one assigned

    Labels

    B-atomsJavaScript chunks generated by Google closureI-defectSomething is not working as intendedJ-staleApplied to issues that become stale, and eventually closed.R-help wantedIssues looking for contributions

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions