Skip to content

Conversation

@mialeska
Copy link
Contributor

  • cover with tests
  • replace js references with native actions in pre-existing methods
  • add localization values for scrolling actions

- cover with tests
- add localization values for scrolling actions
@mialeska mialeska added feature New feature dotnet labels Jul 22, 2024
@mialeska mialeska self-assigned this Jul 22, 2024
@coderabbitai
Copy link

coderabbitai bot commented Jul 22, 2024

Walkthrough

The recent updates to the Aquality.Selenium framework enhance its scrolling capabilities, incorporating new methods for scrolling elements and windows using JavaScript. These additions improve user interaction by allowing more precise control over scrolling behaviors, complemented by enhanced logging and localization support across multiple languages. This update strengthens the framework's functionality and usability in web automation tasks.

Changes

Files Change Summary
Aquality.Selenium/.../Aquality.Selenium.xml New methods for scrolling (e.g., ScrollWindowByViaJs, ScrollFromOrigin, etc.) documented.
Aquality.Selenium/.../Browsers/Browser.cs Added methods ScrollWindowByViaJs and ScrollFromOrigin to enhance scrolling functionality.
Aquality.Selenium/.../Elements/Actions/JsActions.cs Updated ScrollBy method logging to include coordinates.
Aquality.Selenium/.../Elements/Actions/MouseActions.cs Introduced ScrollToElement and ScrollFromOrigin methods to enhance mouse actions.
Aquality.Selenium/.../Forms/Form.cs Added ScrollByJs method for JavaScript-based form scrolling.
Aquality.Selenium/.../Resources/Localization/*.json Updated and added localization strings to clarify scrolling actions in multiple languages.
Aquality.Selenium/.../Tests/Integration/MouseActionsTests.cs Added tests for ScrollToElement and ScrollFromOrigin methods.
Aquality.Selenium/.../Tests/Integration/BrowserTests.cs Added test for ScrollWindowBy_ViaJs to validate JavaScript scrolling functionality.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Browser
    participant JsActions
    participant MouseActions

    User->>Browser: ScrollWindowByViaJs(x, y)
    Browser->>JsActions: Execute JavaScript Scroll
    JsActions-->>Browser: Scroll Completed
    Browser-->>User: Window Scrolled
Loading
sequenceDiagram
    participant User
    participant MouseActions

    User->>MouseActions: ScrollToElement(element)
    MouseActions-->>User: Element Scrolled Into View
Loading

🐇 In the meadow where bunnies play,
New scroll methods hop in today!
With JavaScript magic, they glide and sway,
Making elements dance in a wondrous display!
So let’s twirl and leap, oh what a thrill,
With Aquality's updates, we jump with skill! 🌼


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.

@sonarqubecloud
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

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between a69263a and 243d430.

Files selected for processing (12)
  • Aquality.Selenium/src/Aquality.Selenium/Aquality.Selenium.xml (3 hunks)
  • Aquality.Selenium/src/Aquality.Selenium/Browsers/Browser.cs (2 hunks)
  • Aquality.Selenium/src/Aquality.Selenium/Elements/Actions/JsActions.cs (1 hunks)
  • Aquality.Selenium/src/Aquality.Selenium/Elements/Actions/MouseActions.cs (2 hunks)
  • Aquality.Selenium/src/Aquality.Selenium/Forms/Form.cs (1 hunks)
  • Aquality.Selenium/src/Aquality.Selenium/Resources/Localization/be.json (1 hunks)
  • Aquality.Selenium/src/Aquality.Selenium/Resources/Localization/en.json (1 hunks)
  • Aquality.Selenium/src/Aquality.Selenium/Resources/Localization/pl.json (1 hunks)
  • Aquality.Selenium/src/Aquality.Selenium/Resources/Localization/ru.json (1 hunks)
  • Aquality.Selenium/src/Aquality.Selenium/Resources/Localization/uk.json (1 hunks)
  • Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/Actions/MouseActionsTests.cs (1 hunks)
  • Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/BrowserTests.cs (1 hunks)
Additional comments not posted (38)
Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/Actions/MouseActionsTests.cs (2)

46-61: LGTM!

The test method Should_BePossibleTo_ScrollToElement is well-structured and ensures that scrolling to an element works as expected without raising exceptions.


63-77: LGTM!

The test method Should_BePossibleTo_ScrollFromOrigin is well-structured and ensures that scrolling from an origin point works as expected without raising exceptions.

Aquality.Selenium/src/Aquality.Selenium/Forms/Form.cs (1)

93-98: LGTM!

The method ScrollByJs is well-structured and provides enhanced scrolling functionality using JavaScript.

Aquality.Selenium/src/Aquality.Selenium/Elements/Actions/MouseActions.cs (2)

61-68: LGTM!

The method ScrollToElement is well-structured and ensures that scrolling to an element works as expected with robust retry mechanisms.


70-91: LGTM!

The method ScrollFromOrigin is well-structured and ensures that scrolling from an origin point works as expected with robust retry mechanisms.

Aquality.Selenium/src/Aquality.Selenium/Elements/Actions/JsActions.cs (1)

96-97: Enhanced logging in ScrollBy method.

The logging now includes the x and y parameters, which improves the detail of the log entries. This is useful for debugging and tracking user interactions more accurately.

Aquality.Selenium/src/Aquality.Selenium/Resources/Localization/en.json (4)

69-69: Updated localization string for scrolling via JavaScript.

The string has been updated to "Scrolling to element via JavaScript," providing a clearer indication of the action being performed.


70-70: Added new localization string for scrolling to element.

The new entry "Scrolling to element" enhances the clarity of the action being described.


71-71: Added new localization string for scrolling by coordinates.

The new entry "Scrolling by ({0},{1})" provides a clear description of the action being performed with specific coordinates.


72-72: Added new localization string for scrolling by coordinates via JavaScript.

The new entry "Scrolling by ({0},{1}) via JavaScript" specifies the scrolling action by coordinates via JavaScript, enhancing clarity.

Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/BrowserTests.cs (1)

203-217: New test method Should_BePossibleTo_ScrollWindowBy_ViaJs.

The new test method validates the functionality of scrolling a window using JavaScript in an infinite scroll form. It ensures that new examples are loaded as expected after the scroll. The implementation correctly opens the form, waits for the page to load, captures the initial count of example labels, performs the scroll action, and asserts the expected behavior.

Aquality.Selenium/src/Aquality.Selenium/Resources/Localization/uk.json (4)

69-69: Update localization string for clarity.

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


70-70: Add new localization string for element scrolling.

The new string "Прокрутка до елемента" accurately describes scrolling to an element.


71-71: Add new localization string for coordinate scrolling.

The new string "Прокрутка на ({0},{1})" specifies scrolling to specific coordinates, enhancing localization support.


72-72: Add new localization string for coordinate scrolling via JavaScript.

The new string "Прокрутка на ({0},{1}) за допомогою JavaScript" indicates scrolling to specific coordinates using JavaScript, improving clarity.

Aquality.Selenium/src/Aquality.Selenium/Resources/Localization/be.json (4)

69-69: Update localization string for clarity.

The updated string "Пракручваем старонку да элемента праз JavaScript" provides clearer context by specifying that the scrolling action is directed towards an element.


70-70: Add new localization string for element scrolling.

The new string "Пракручваем старонку да элемента" accurately describes scrolling to an element.


71-71: Add new localization string for coordinate scrolling.

The new string "Пракручваем на ({0},{1})" specifies scrolling to specific coordinates, enhancing localization support.


72-72: Add new localization string for coordinate scrolling via JavaScript.

The new string "Пракручваем на ({0},{1}) праз JavaScript" indicates scrolling to specific coordinates using JavaScript, improving clarity.

Aquality.Selenium/src/Aquality.Selenium/Resources/Localization/ru.json (4)

69-69: Update localization string for clarity.

The updated string "Скроллинг к элементу с помощью JavaScript" provides clearer context by specifying that the scrolling action is directed towards an element.


70-70: Add new localization string for element scrolling.

The new string "Скроллинг к элементу" accurately describes scrolling to an element.


71-71: Add new localization string for coordinate scrolling.

The new string "Скроллинг на ({0},{1})" specifies scrolling to specific coordinates, enhancing localization support.


72-72: Add new localization string for coordinate scrolling via JavaScript.

The new string "Скроллинг на ({0},{1}) с помощью JavaScript" indicates scrolling to specific coordinates using JavaScript, improving clarity.

Aquality.Selenium/src/Aquality.Selenium/Resources/Localization/pl.json (4)

69-69: LGTM! Improved clarity in localization string.

The updated string "Przewijanie do elementu przez JavaScript" is more descriptive.


70-70: LGTM! New localization string added.

The new string "Przewijanie do elementu" provides a clear description.


71-71: LGTM! New localization string added.

The new string "Przewijanie o ({0},{1})" provides a clear description for scrolling by specific coordinates.


72-72: LGTM! New localization string added.

The new string "Przewijanie o ({0},{1}) przez JavaScript" provides a clear description for scrolling by specific coordinates using JavaScript.

Aquality.Selenium/src/Aquality.Selenium/Browsers/Browser.cs (6)

13-14: LGTM! Necessary imports added.

The new import statements for OpenQA.Selenium.Interactions and WheelInputDevice are necessary for the new scrolling functionalities.


324-326: LGTM! Logging added to ScrollWindowBy.

The added logging improves traceability of scrolling actions.


328-336: LGTM! New method ScrollWindowByViaJs added.

The new method performs scrolling using JavaScript and includes logging for traceability.


339-348: LGTM! New method ScrollFromOrigin added.

The new method expands scrolling capabilities and uses the Actions class for enhanced interaction.


333-336: Verify the usage of ExecuteScript.

Ensure that the ExecuteScript method is correctly utilized in the new scrolling methods.

Also applies to: 347-348

Verification successful

Verify the usage of ExecuteScript in the Browser.cs file.

Ensure that the ExecuteScript method is correctly utilized in the new scrolling methods.

  • Aquality.Selenium/src/Aquality.Selenium/Browsers/Browser.cs: ExecuteScript(JavaScript.ScrollWindowBy, x, y);
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the usage of `ExecuteScript` in the new scrolling methods.

# Test: Search for the method usage. Expect: Correct utilization in the new methods.
rg --type cs -A 5 $'ExecuteScript'

Length of output: 41828


Line range hint 349-354:
Verify the usage of ExecuteScriptFromFile.

Ensure that the ExecuteScriptFromFile method is correctly utilized in the class.

Verification successful

The method ExecuteScriptFromFile is correctly utilized in the Browser class and is well-tested in various integration tests.

  • Aquality.Selenium/src/Aquality.Selenium/Browsers/Browser.cs: Verified usage within the class.
  • Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/BrowserTests.cs: Verified usage in integration tests.
  • Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/Actions/JsActionsTests.cs: Verified usage in integration tests.
  • Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/Usecases/FileDownloadingTests.cs: Verified usage in integration tests.
  • Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/DevToolsEmulationTests.cs: Verified usage in integration tests.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the usage of `ExecuteScriptFromFile` in the class.

# Test: Search for the method usage. Expect: Correct utilization in the class.
rg --type cs -A 5 $'ExecuteScriptFromFile'

Length of output: 8318

Aquality.Selenium/src/Aquality.Selenium/Aquality.Selenium.xml (5)

233-239: Documentation for ScrollWindowByViaJs is correct.

The documentation for the ScrollWindowByViaJs method is accurate and complete.


240-247: Documentation for ScrollFromOrigin is correct.

The documentation for the ScrollFromOrigin method is accurate and complete.


1470-1474: Documentation for ScrollToElement is correct.

The documentation for the ScrollToElement method is accurate and complete.


1475-1479: Documentation for ScrollFromOrigin is correct.

The documentation for the ScrollFromOrigin method is accurate and complete.


2452-2458: Documentation for ScrollByJs is correct.

The documentation for the ScrollByJs method is accurate and complete.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants