selenium icon indicating copy to clipboard operation
selenium copied to clipboard

[java] Remove obsolete variables from DriverCommand and W3CHttpCommandCodec

Open iampopovich opened this issue 5 months ago • 3 comments

User description

🔗 Related Issues

Related to #10397

💥 What does this PR do?

changes to remove driver commands are the same as in the commit also rb and node bindings need similar changes

🔧 Implementation Notes

This pull request removes support for local storage and session storage commands from the Selenium WebDriver's W3C HTTP Command Codec. The changes streamline the codebase by eliminating unused or deprecated commands and their associated logic.

Removal of Local Storage and Session Storage Commands:

  • java/src/org/openqa/selenium/remote/DriverCommand.java: Removed constants for local storage and session storage commands, such as GET_LOCAL_STORAGE_ITEM, SET_LOCAL_STORAGE_ITEM, and CLEAR_SESSION_STORAGE.
  • java/src/org/openqa/selenium/remote/codec/w3c/W3CHttpCommandCodec.java: Removed import statements for local storage and session storage commands that were no longer needed. [1] [2]
  • java/src/org/openqa/selenium/remote/codec/w3c/W3CHttpCommandCodec.java: Removed alias definitions for local storage and session storage commands, which mapped these commands to JavaScript execution.
  • java/src/org/openqa/selenium/remote/codec/w3c/W3CHttpCommandCodec.java: Removed case statements and associated JavaScript logic for handling local storage and session storage commands. This includes commands like CLEAR_LOCAL_STORAGE, GET_SESSION_STORAGE_KEYS, and SET_SESSION_STORAGE_ITEM.

💡 Additional Considerations

🔄 Types of changes

  • Cleanup (formatting, renaming)

PR Type

Bug fix


Description

  • Remove deprecated HTML5 local storage and session storage commands

  • Clean up unused driver command constants and imports

  • Eliminate associated command codec aliases and implementations

  • Streamline W3C HTTP command codec for better maintainability


Changes diagram

flowchart LR
  A["DriverCommand.java"] -- "Remove constants" --> B["Storage Commands Removed"]
  C["W3CHttpCommandCodec.java"] -- "Remove imports" --> B
  C -- "Remove aliases" --> B
  C -- "Remove implementations" --> B
  B --> D["Cleaner Codebase"]

Changes walkthrough 📝

Relevant files
Cleanup
DriverCommand.java
Remove HTML5 storage command constants                                     

java/src/org/openqa/selenium/remote/DriverCommand.java

  • Removed 12 local storage command constants
  • Removed 6 session storage command constants
  • Cleaned up interface definition
  • +0/-12   
    W3CHttpCommandCodec.java
    Remove storage command codec implementations                         

    java/src/org/openqa/selenium/remote/codec/w3c/W3CHttpCommandCodec.java

  • Removed 12 static imports for storage commands
  • Removed 12 command aliases for storage operations
  • Removed 12 JavaScript implementations for storage methods
  • Eliminated localStorage and sessionStorage script executions
  • +0/-72   

    Need help?
  • Type /help how to ... in the comments thread for any questions about Qodo Merge usage.
  • Check out the documentation for more information.
  • iampopovich avatar Jul 07 '25 16:07 iampopovich

    PR Reviewer Guide 🔍

    Here are some key observations to aid the review process:

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

    Breaking Change

    Removal of local storage and session storage commands may break existing code that depends on these features. Verify that this is intentional deprecation and that proper migration guidance exists.

    public W3CHttpCommandCodec() {
      String sessionId = "/session/:sessionId";
    
      alias(GET_ELEMENT_ATTRIBUTE, EXECUTE_SCRIPT);
      alias(GET_ELEMENT_LOCATION, GET_ELEMENT_RECT);
      alias(GET_ELEMENT_LOCATION_ONCE_SCROLLED_INTO_VIEW, EXECUTE_SCRIPT);
      alias(GET_ELEMENT_SIZE, GET_ELEMENT_RECT);
      alias(IS_ELEMENT_DISPLAYED, EXECUTE_SCRIPT);
      alias(SUBMIT_ELEMENT, EXECUTE_SCRIPT);
    
      defineCommand(EXECUTE_SCRIPT, post(sessionId + "/execute/sync"));
      defineCommand(EXECUTE_ASYNC_SCRIPT, post(sessionId + "/execute/async"));
    
      alias(GET_PAGE_SOURCE, EXECUTE_SCRIPT);
    
      String window = sessionId + "/window";
      defineCommand(MAXIMIZE_CURRENT_WINDOW, post(window + "/maximize"));
      defineCommand(MINIMIZE_CURRENT_WINDOW, post(window + "/minimize"));
    

    qodo-code-review[bot] avatar Jul 07 '25 16:07 qodo-code-review[bot]

    PR Code Suggestions ✨

    No code suggestions found for the PR.

    qodo-code-review[bot] avatar Jul 07 '25 16:07 qodo-code-review[bot]

    @iampopovich The changes made and the PR title don't seem to align. Can you please update it?

    pujagani avatar Aug 05 '25 12:08 pujagani