Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement native scroll actions and use Selenium 4.23.0 #142

Merged
merged 1 commit into from
Jul 23, 2024

Conversation

mialeska
Copy link
Contributor

  • cover with tests
  • replace js references with native actions in pre-existing methods
  • add localization values for scrolling actions
  • refactor MouseActions
  • Update to Selenium 4.23.0

- cover with tests
- replace js references with native actions in pre-existing methods
- add localization values for scrolling actions
- refactor MouseActions
- Update to Selenium 4.23.0
Copy link

coderabbitai bot commented Jul 23, 2024

Walkthrough

The recent updates introduce enhancements primarily to scrolling functionalities within the Aquality Selenium framework. New methods for scrolling via JavaScript and mouse actions have been added, alongside improved logging for tracking actions. The localization files have been updated to provide clearer descriptions in multiple languages. Additionally, tests have been expanded to cover new scrolling functionalities, ensuring robust validation of user interactions with dynamically loaded content.

Changes

Files Change Summary
pom.xml Updated aquality-selenium-core from version 4.0.3 to 4.0.4.
src/main/java/aquality/selenium/browser/Browser.java Introduced methods for scrolling: scrollWindowBy, scrollWindowByViaJs, and scrollFromOrigin.
src/main/java/aquality/selenium/elements/actions/JsActions.java Enhanced logging in scrollBy method to include coordinates.
src/main/java/aquality/selenium/elements/actions/MouseActions.java Refactored mouse actions with improved logging and added scrolling methods: scrollToElement, scrollFromOrigin.
src/main/java/aquality/selenium/forms/Form.java Added scrollByJs method for JavaScript-based scrolling.
src/main/resources/localization/*.json Updated and added new scrolling-related strings in multiple languages for clarity.
src/test/java/tests/integration/ActionTests.java Added tests for scrolling functionalities: testScrollToElement and testScrollFromOrigin.
src/test/java/tests/integration/BrowserTests.java Introduced testShouldBePossibleToScrollWindowByViaJavaScript.
src/test/java/tests/usecases/devtools/*.java Updated Selenium DevTools imports from version 124 to 127.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Browser
    participant Page

    User->>Browser: Initiates scroll action
    Browser->>Page: scrollWindowBy(int x, int y)
    Page-->>Browser: Scrolls viewport
    Browser->>User: Displays updated content

    User->>Browser: Initiates scroll via JS
    Browser->>Page: scrollByJs(int x, int y)
    Page-->>Browser: Scrolls specific element
    Browser->>User: Displays element in view
Loading

🐇 Hopping with glee, oh what a sight,
New scroll methods added, what a delight!
With logs that now tell the tale,
Our tests will never fail!
Aquality shines bright,
In code, we take flight! 🌟


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@mialeska mialeska changed the title Implement native scroll actions +semver: feature Implement native scroll actions and use Selenium 4.23.0 +semver: feature Jul 23, 2024
Copy link

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Outside diff range, codebase verification and nitpick comments (1)
src/test/java/tests/usecases/devtools/DeviceEmulationTest.java (1)

6-7: Update import statements to use the latest Selenium DevTools version.

The following files still reference the older Selenium DevTools version (v85). Please update the import statements in these files to use the latest version (v127):

  • src/main/java/aquality/selenium/browser/devtools/JavaScriptHandling.java
  • src/main/java/aquality/selenium/browser/devtools/NetworkHandling.java
  • src/main/java/aquality/selenium/browser/devtools/EmulationHandling.java
  • src/main/java/aquality/selenium/browser/devtools/DevToolsHandling.java

Ensure that the code is adjusted to accommodate any API changes between versions.

Analysis chain

Update import statements to use the latest Selenium DevTools version.

The import statements have been updated to use Emulation and DisplayFeature from version 127 of the Selenium DevTools. Ensure that these versions are compatible with the rest of the code.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify that the new versions of Emulation and DisplayFeature are compatible with the existing code.

# Test: Search for the usage of Emulation and DisplayFeature in the codebase. Expect: Only occurances of the new versions.
rg --type java -A 5 $'Emulation'
rg --type java -A 5 $'DisplayFeature'

Length of output: 27588


Script:

#!/bin/bash
# Description: Search for all occurrences of the older Selenium DevTools version (v85) in the codebase.

rg --type java 'org.openqa.selenium.devtools.v85'

Length of output: 1922

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between e9892f6 and 530da31.

Files selected for processing (15)
  • pom.xml (1 hunks)
  • src/main/java/aquality/selenium/browser/Browser.java (2 hunks)
  • src/main/java/aquality/selenium/elements/actions/JsActions.java (1 hunks)
  • src/main/java/aquality/selenium/elements/actions/MouseActions.java (1 hunks)
  • src/main/java/aquality/selenium/forms/Form.java (1 hunks)
  • src/main/resources/localization/be.json (1 hunks)
  • src/main/resources/localization/en.json (1 hunks)
  • src/main/resources/localization/pl.json (1 hunks)
  • src/main/resources/localization/ru.json (1 hunks)
  • src/main/resources/localization/uk.json (1 hunks)
  • src/test/java/tests/integration/ActionTests.java (3 hunks)
  • src/test/java/tests/integration/BrowserTests.java (1 hunks)
  • src/test/java/tests/usecases/devtools/DeviceEmulationTest.java (1 hunks)
  • src/test/java/tests/usecases/devtools/NetworkSpeedEmulationTest.java (1 hunks)
  • src/test/java/tests/usecases/devtools/OverrideUserAgentTest.java (1 hunks)
Files skipped from review due to trivial changes (2)
  • pom.xml
  • src/test/java/tests/usecases/devtools/OverrideUserAgentTest.java
Additional comments not posted (41)
src/test/java/tests/usecases/devtools/NetworkSpeedEmulationTest.java (1)

5-5: Update import statement to use the latest Selenium DevTools version.

The import statement has been updated to use ConnectionType from version 127 of the Selenium DevTools network model. Ensure that this version is compatible with the rest of the code.

src/main/java/aquality/selenium/forms/Form.java (1)

83-85: New method scrollByJs added.

The new method scrollByJs provides an alternative way to scroll the form using JavaScript. Ensure that this method is implemented correctly and does not introduce any issues.

src/main/java/aquality/selenium/elements/actions/MouseActions.java (10)

4-11: Imports look good.

The new imports for ILocalizedLogger, IElementActionRetrier, and ScrollOrigin are appropriate for the added functionalities.


19-27: Constructor changes are appropriate.

The initialization of logger and elementActionRetrier is necessary for the new functionalities.


34-36: Improved logging and action handling in click method.

The use of logElementAction and performActionAfterMove enhances logging and ensures proper action handling.


43-45: Improved logging and action handling in rightClick method.

The use of logElementAction and performActionAfterMove enhances logging and ensures proper action handling.


50-53: New scrollToElement method looks good.

The method provides scrolling functionality with proper logging and action handling.


61-79: New scrollFromOrigin methods look good.

The methods provide scrolling functionalities by coordinates with and without offsets, along with proper logging and action handling.


86-87: Improved logging and action handling in moveMouseToElement method.

The use of logElementAction and performActionAfterMove enhances logging and ensures proper action handling.


94-95: Improved logging and action handling in moveMouseFromElement method.

The use of logElementAction and performAction enhances logging and ensures proper action handling.


102-104: Improved logging and action handling in doubleClick method.

The use of logElementAction and performActionAfterMove enhances logging and ensures proper action handling.


106-121: Improved action handling and logging methods.

The updates to performActionAfterMove and performAction methods, along with the new logElementAction method, enhance action handling flexibility and logging.

src/main/java/aquality/selenium/elements/actions/JsActions.java (1)

95-95: Enhanced logging in scrollBy method.

The additional logging of parameters x and y improves traceability and debugging.

src/test/java/tests/integration/ActionTests.java (3)

26-26: Simplified browser window maximization in beforeMethod.

The refactoring simplifies the code and improves readability.


45-60: Comprehensive test coverage in testScrollToElement method.

The method provides thorough testing of the new scrolling functionality, ensuring its reliability.


63-73: Comprehensive test coverage in testScrollFromOrigin method.

The method provides thorough testing of the new scrolling functionality, ensuring its reliability.

src/test/java/tests/integration/BrowserTests.java (1)

191-199: LGTM! The new test method is well-structured.

The test method testShouldBePossibleToScrollWindowByViaJavaScript is well-structured and effectively verifies the scrolling functionality using JavaScript.

src/main/resources/localization/en.json (4)

73-73: Approved: Updated localization string improves clarity.

The updated string "Scrolling to element via JavaScript" provides better clarity by specifying the scrolling action.


74-74: Approved: New localization string added.

The new string "Scrolling to element" provides a general description of the scrolling action.


75-75: Approved: New localization string added.

The new string "Scrolling by (%s,%s)" provides a detailed description of the scrolling action with coordinates.


76-76: Approved: New localization string added.

The new string "Scrolling by (%s,%s) via JavaScript" provides a detailed description of the scrolling action with coordinates in the context of JavaScript.

src/main/resources/localization/be.json (4)

73-73: Approved: Updated localization string improves clarity.

The updated string "Пракручваем старонку да элемента праз JavaScript" provides better clarity by specifying the scrolling action.


74-74: Approved: New localization string added.

The new string "Пракручваем старонку да элемента" provides a general description of the scrolling action.


75-75: Approved: New localization string added.

The new string "Пракручваем на (%s,%s)" provides a detailed description of the scrolling action with coordinates.


76-76: Approved: New localization string added.

The new string "Пракручваем на (%s,%s) праз JavaScript" provides a detailed description of the scrolling action with coordinates in the context of JavaScript.

src/main/resources/localization/uk.json (4)

73-73: Approved: Improved clarity for scrolling action.

The updated string "Прокрутка до елемента за допомогою JavaScript" enhances clarity by specifying that the scrolling action is directed towards a specific element.


74-74: Approved: Added clear description for scrolling action.

The new entry "Прокрутка до елемента" provides a clear description for the scrolling action.


75-75: Approved: Added description for scrolling to coordinates.

The new entry "Прокрутка на (%s,%s)" specifies scrolling to specific coordinates, enhancing clarity.


76-76: Approved: Added description for JavaScript scrolling to coordinates.

The new entry "Прокрутка на (%s,%s) за допомогою JavaScript" provides a clear description for scrolling to specific coordinates using JavaScript.

src/main/resources/localization/ru.json (4)

73-73: Approved: Improved clarity for scrolling action.

The updated string "Скроллинг к элементу (посредством JavaScript)" enhances clarity by specifying that the scrolling action is directed towards a specific element.


74-74: Approved: Added clear description for scrolling action.

The new entry "Скроллинг к элементу" provides a clear description for the scrolling action.


75-75: Approved: Added description for scrolling to coordinates.

The new entry "Скроллинг на (%s,%s)" specifies scrolling to specific coordinates, enhancing clarity.


76-76: Approved: Added description for JavaScript scrolling to coordinates.

The new entry "Скроллинг на (%s,%s) посредством JavaScript" provides a clear description for scrolling to specific coordinates using JavaScript.

src/main/resources/localization/pl.json (4)

73-73: Approved: Improved clarity for scrolling action.

The updated string "Przewijanie do elementu przez JavaScript" enhances clarity by specifying that the scrolling action is directed towards a specific element.


74-74: Approved: Added clear description for scrolling action.

The new entry "Przewijanie do elementu" provides a clear description for the scrolling action.


75-75: Approved: Added description for scrolling to coordinates.

The new entry "Przewijanie o (%s,%s)" specifies scrolling to specific coordinates, enhancing clarity.


76-76: Approved: Added description for JavaScript scrolling to coordinates.

The new entry "Przewijanie o (%s,%s) przez JavaScript" provides a clear description for scrolling to specific coordinates using JavaScript.

src/main/java/aquality/selenium/browser/Browser.java (4)

15-16: Imports approved.

The new imports for Actions and ScrollOrigin are necessary for the new scrolling functionalities.


357-359: Method scrollWindowBy approved.

The method correctly logs the action and performs scrolling using Selenium Actions.


367-370: Method scrollWindowByViaJs approved.

The method correctly logs the action and performs scrolling using JavaScript.


379-381: Method scrollFromOrigin approved.

The method correctly performs scrolling from a specified origin using Selenium Actions.

@mialeska mialeska changed the title Implement native scroll actions and use Selenium 4.23.0 +semver: feature Implement native scroll actions and use Selenium 4.23.0 Jul 23, 2024
@mialeska mialeska merged commit e59afe5 into master Jul 23, 2024
4 checks passed
@mialeska mialeska deleted the feature/scroll-actions branch July 23, 2024 21:32
@coderabbitai coderabbitai bot mentioned this pull request Oct 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

1 participant