Skip to content

[CR-2110] Click on element using javascript executor in mobile web #141

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

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from

Conversation

ManojTestsigma
Copy link
Contributor

@ManojTestsigma ManojTestsigma commented Apr 4, 2025

Jira

https://testsigma.atlassian.net/browse/CR-2110

Indian region (Publish as Public)

Addon name : Javascript Executor (https://jarvis-in.testsigma.com/ui/tenants/1/addons)
account : rachel@testsigma.com

fix

add js executor script to click on the given element

Summary by CodeRabbit

  • New Features
    • Added a JavaScript-based click action for mobile web elements to enhance interaction reliability.
    • Introduced a new project configuration file to streamline dependency management and build processes.
    • Enabled improved integration with the testing service through a new API key configuration.

Copy link

coderabbitai bot commented Apr 4, 2025

Walkthrough

This pull request introduces three key changes. A new Maven POM file is added to the javascript_executor project, detailing project metadata, dependency versions, and build configurations with relevant plugins. Additionally, a new Java class, ClickOnElementUsingJsExecutor, is incorporated to perform JavaScript-based click actions on web elements using AppiumDriver with proper exception handling and logging. A properties file is also provided to configure the TestSigma SDK using a JWT API key.

Changes

File(s) Change Summary
javascript_executor 2/pom.xml Introduces a new Maven POM specifying project metadata, dependency versions, and build plugins (maven-shade-plugin, maven-source-plugin).
javascript_executor 2/src/main/java/com/testsigma/addons/mobile_web/ClickOnElementUsingJsExecutor.java Adds a new Java class extending WebAction to perform click actions using JavaScript execution, including logging, exception handling, and AppiumDriver usage.
javascript_executor 2/src/main/resources/testsigma-sdk.properties Introduces a properties file containing a JWT API key for the TestSigma SDK configuration.

Sequence Diagram(s)

sequenceDiagram
    participant Runner as Test Runner
    participant Action as ClickOnElementUsingJsExecutor
    participant Driver as AppiumDriver
    participant JS as JavascriptExecutor
    participant Element as WebElement

    Runner->>Action: Call execute()
    Action->>Driver: Retrieve WebElement using locator
    Driver-->>Action: Return WebElement
    Action->>JS: executeScript("arguments[0].click()", Element)
    JS-->>Action: Acknowledge click action
    Action-->>Runner: Return success result
Loading

Possibly related PRs

Suggested reviewers

  • Ganesh-Testsigma

Poem

I’m a rabbit with a skip and a bound,
Celebrating changes as they astound!
New clicks with JavaScript in the air,
And POMs that show a project so fair.
Hopping through code with joy profound 🐇✨
Every line and key makes the magic sound!


📜 Recent review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 0404433 and 3ffe033.

📒 Files selected for processing (1)
  • javascript_executor 2/src/main/java/com/testsigma/addons/mobile_web/ClickOnElementUsingJsExecutor.java (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • javascript_executor 2/src/main/java/com/testsigma/addons/mobile_web/ClickOnElementUsingJsExecutor.java

🪧 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.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai plan to trigger planning for file edits and PR creation.
  • @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: 4

🧹 Nitpick comments (4)
javascript_executor 2/pom.xml (3)

12-22: Dependencies with conflicting versions property defined but not used

I noticed you've defined the property testsigma.addon.maven.plugin with version 1.0.0 in line 18, but it doesn't appear to be referenced anywhere in the POM file.

Unless it's planned for future use, consider removing this unused property.


36-46: Multiple test frameworks included

You're including both JUnit Jupiter (with test scope) and TestNG (with compile scope) in your dependencies. This is unusual as they're competing test frameworks.

Consider standardizing on a single test framework. If you need both for compatibility reasons, add a comment explaining why, and consider setting the TestNG dependency to test scope:

 <dependency>
     <groupId>org.testng</groupId>
     <artifactId>testng</artifactId>
     <version>6.14.3</version>
+    <scope>test</scope>
 </dependency>

74-86: Missing configuration in maven-shade-plugin

The maven-shade-plugin is configured with minimal settings. For a more robust build, consider adding transformer configuration to handle META-INF services and specifying a main class if this is an executable JAR.

For example:

 <plugin>
     <groupId>org.apache.maven.plugins</groupId>
     <artifactId>maven-shade-plugin</artifactId>
     <version>3.2.4</version>
     <executions>
         <execution>
             <phase>package</phase>
             <goals>
                 <goal>shade</goal>
             </goals>
+            <configuration>
+                <transformers>
+                    <transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>
+                    <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
+                        <mainClass>com.testsigma.addons.mobile_web.Main</mainClass>
+                    </transformer>
+                </transformers>
+            </configuration>
         </execution>
     </executions>
 </plugin>
javascript_executor 2/src/main/java/com/testsigma/addons/mobile_web/ClickOnElementUsingJsExecutor.java (1)

22-24: Remove commented code hint

The comment "Your Awesome code starts here" appears to be a template hint that should be removed in the final implementation.

- //Your Awesome code starts here
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 8675b7c and 0404433.

📒 Files selected for processing (3)
  • javascript_executor 2/pom.xml (1 hunks)
  • javascript_executor 2/src/main/java/com/testsigma/addons/mobile_web/ClickOnElementUsingJsExecutor.java (1 hunks)
  • javascript_executor 2/src/main/resources/testsigma-sdk.properties (1 hunks)
🧰 Additional context used
🪛 Gitleaks (8.21.2)
javascript_executor 2/src/main/resources/testsigma-sdk.properties

1-1: Uncovered a JSON Web Token, which may lead to unauthorized access to web applications and sensitive user data.

(jwt)

🔇 Additional comments (3)
javascript_executor 2/src/main/java/com/testsigma/addons/mobile_web/ClickOnElementUsingJsExecutor.java (3)

13-16: Clear and well-documented action annotation

The action annotation is well-structured with clear actionText, description, and appropriate applicationType for mobile web.


18-19: Element reference annotation is correctly used

The Element annotation correctly references "element-locator" which matches the actionText from the Action annotation.


25-26: Good logging practices implemented

The code includes appropriate logging at different levels (info for execution start and debug for detailed element information).

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.

2 participants