Skip to content

[πŸ› Bug]: Return wrong value when using JavaScriptExecutor to execute decoding js function "atob"Β #13207

@Erix377

Description

@Erix377

What happened?

Running JavaScriptExecutor in Java code to excute the command "return atob('Rw0K')" in v3.2.0 will decode the string 'Rw0K' into 3 characters - ''G\r\n''. However, after upgrading to v4.13.0, it will decode this string into only 2 characters - which are 'G\n'. So basically, the '0K' string means to start a new line. However, in old version selenium, it will recognized as '\r\n' and for latest version, it will recognize as '\n'.

Since this incompatibility issue was found when we try to upgrade the selenium version from v3.2.0 to v4.13.0. Thus, it will cause some files' format doesn't match standard which leads to that file deprecated, like PNG file. Thus, I hope for the new selenium version, it can fix this incompatibility and when using JavaScriptExecutor to excute the command with 'atob' function, it can decode the encoded string which represents starting a new line back to "G\r\n", which is the same result as directly executing the command 'return atob('Rw0K')' web browser, like latest version chrome.

How can we reproduce the issue?

Using selenium v3.2.0, to create a JavaScriptExecutor to execute the JavaScript command "return atob('Rw0K')", you will get a decoded string "G\r\n", which includes 3 characters. 

However, if you using selenium v4.13.0 to create a JavaScriptExecutor and execute the same command above "return atob('Rw0K')", you will receive the decoded string "G\n", which only includes 2 characters.

Java Code Example:

//downloading different versions specified above

import org.openqa.selenium.JavascriptExecutor;
JavascriptExecutor js = (JavascriptExecutor) driver;
decoded_string=js.executeScript("return atob('Rw0K')");

// for v4.13.0, the decoded string length is expected as 2, and for v3.2.0, the length will be 3.

Relevant log output

no related log output

Operating System

Mac, Windows, Linux

Selenium version

Java 4.13.0

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

Chrome 119.0.6045.159 (Official Build) (arm64)

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

geckodriver-v0.33.0-macos-aarch64, chromedriver

Are you using Selenium Grid?

no

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-javaJava BindingsI-defectSomething is not working as intendedR-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