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

feat/TE-24462-Browser Permissions for Edge #93

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from

Conversation

akhil-testsigma
Copy link
Contributor

@akhil-testsigma akhil-testsigma commented Jan 24, 2025

JIRA

https://testsigma.atlassian.net/browse/TE-24462

Fix

Browser Permissions for Edge

Summary by CodeRabbit

  • New Features

    • Added a new Maven project for managing Microsoft Edge site permissions
    • Introduced a new Java class to handle Edge browser permission settings
    • Implemented functionality to modify site permissions programmatically
  • Chores

    • Configured project dependencies and build settings
    • Added SDK authentication properties

Copy link

coderabbitai bot commented Jan 24, 2025

Walkthrough

A new Maven project for Microsoft Edge site permissions has been established. The project introduces an EdgePermissionAction Java class that enables programmatic management of browser permissions in Microsoft Edge. The implementation includes a comprehensive Maven configuration with necessary dependencies, a new action class for handling site permissions, and a configuration properties file for SDK authentication.

Changes

File Change Summary
microsoft_edge_site_permissions/pom.xml New Maven POM file created with project metadata, Java 11 configuration, and dependencies including Testsigma SDK, Lombok, JUnit, Selenium, and Appium
microsoft_edge_site_permissions/src/main/java/.../EdgePermissionAction.java New WebAction class for managing Edge browser site permissions, with methods to execute permission settings and handle browser interactions
microsoft_edge_site_permissions/src/main/resources/testsigma-sdk.properties Added new API key property for SDK authentication

Sequence Diagram

sequenceDiagram
    participant User
    participant EdgePermissionAction
    participant WebDriver
    participant EdgeSettingsPage

    User->>EdgePermissionAction: Execute with URL and Permission
    EdgePermissionAction->>WebDriver: Open new tab
    EdgePermissionAction->>EdgeSettingsPage: Navigate to settings
    EdgePermissionAction->>EdgeSettingsPage: Set permission
    EdgePermissionAction->>WebDriver: Refresh page
    EdgePermissionAction->>WebDriver: Switch back to original tab
    EdgePermissionAction-->>User: Return result
Loading

Poem

🐰 A rabbit's tale of browser might,
Where Edge permissions dance so bright
With clicks and codes, we set the stage
For websites to behave just right
Hop, hop, hooray for addon's flight! 🌐

Warning

Review ran into problems

🔥 Problems

Git: Failed to clone repository. Please run the @coderabbitai full review command to re-trigger a full review.

✨ Finishing Touches
  • 📝 Generate Docstrings (Beta)

🪧 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>, please review it.
    • 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 gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @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 using 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 generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

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.

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: 1

🧹 Nitpick comments (5)
microsoft_edge_site_permissions/src/main/java/com/testsigma/addons/web/EdgePermissionAction.java (4)

16-21: Leverage descriptive actionText for better user clarity
The action text is sufficiently descriptive. However, consider including usage instructions or a more detailed summary in the description. This helps end-users understand any prerequisites or known constraints for the Edge browser.


23-30: Validate test data for null or empty inputs
When storing user-provided values, consider validating if the test data is null or empty to prevent NullPointerException or unexpected behavior when building the edge://settings URL.

+if (targetUrl == null || targetUrl.getValue() == null) {
+  throw new IllegalArgumentException("Target URL is required and cannot be null");
+}

86-101: Finer-grained exception messages for debugging
While the error handling is comprehensive, consider adding more contextual information (like which element was not found or timed out) to assist in diagnosing test failures quickly. Each exception message can reference the specific step or permission being set.


120-135: Use more robust locators or alternative fallback logic
The XPath relies on visible text matching for the permission value. If the UI language or text changes, this may break the action. Consider a fallback locator or a robust data attribute for better maintainability.

microsoft_edge_site_permissions/pom.xml (1)

24-64: Unify test frameworks or confirm necessity
Both JUnit (lines 37-41) and TestNG (lines 43-46) dependencies are present. If there’s no requirement for them simultaneously, consider standardizing on a single framework to reduce project complexity.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b831cd2 and c2807a7.

📒 Files selected for processing (3)
  • microsoft_edge_site_permissions/pom.xml (1 hunks)
  • microsoft_edge_site_permissions/src/main/java/com/testsigma/addons/web/EdgePermissionAction.java (1 hunks)
  • microsoft_edge_site_permissions/src/main/resources/testsigma-sdk.properties (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • microsoft_edge_site_permissions/src/main/resources/testsigma-sdk.properties
🔇 Additional comments (3)
microsoft_edge_site_permissions/src/main/java/com/testsigma/addons/web/EdgePermissionAction.java (2)

3-5: Validate imports and inheritance
The usage of WebAction from the Testsigma SDK is appropriate for custom web actions. The imports appear relevant. Ensure no unwanted or unused libraries are being pulled in.


48-54: Prevent potential new tab handle race
Right after switching to a new window, there's a possibility of a race condition if the tab isn't fully opened before retrieving its handle. The existing wait might mitigate this, but consider handling it with a well-defined explicit wait for the new tab to be recognized.

microsoft_edge_site_permissions/pom.xml (1)

66-96: Validate plugin versions and library compatibility
The maven-shade-plugin and maven-source-plugin configurations look consistent. Double-check that the Selenium 4.14.1 and Testsigma SDK 1.2.18 versions match any known compatibility requirements for the Edge testing scenario.

Comment on lines +36 to +44
com.testsigma.sdk.Result result = com.testsigma.sdk.Result.SUCCESS;
String permissionName_ = permissionName.getValue().toString();
String permissionValue_ = permissionValue.getValue().toString();
String origWindowHandle = driver.getWindowHandle();
List<String> origWindowsList = new ArrayList<>(driver.getWindowHandles());
WebDriverWait wait = new WebDriverWait(driver, Duration.ofSeconds(10));

try {
String edgeSettingsUrl = SETTINGS_URL_PREFIX + targetUrl.getValue().toString();
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Replace hard-coded sleeps with dynamic waits
Frequent 1500ms Thread.sleep() calls can increase the overall test run time and introduce flaky behavior. Prefer Selenium explicit waits (e.g., waiting for specific page states or elements) rather than fixed sleeps.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant