- Notifications
You must be signed in to change notification settings - Fork5
browserstack/ai-authoring-automate-demo-browserstack
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
TestNG Integration with BrowserStack.
This repository showcases the use ofBrowserStack's Cross-Device Automation Agent for web automation using TestNG and Selenium. The key feature is the ability to write test steps inNatural Language (Plain English), moving away from explicit Selenium locators and actions.
It contains a demo script:
BstackAIAuthoring.java: Runs complex test objectives (like selecting a product in a specific price range or navigating to a quote page) using simple English commands.
- Enablement: The feature is enabled by declaring the capability
aiAuthoring: truein yourbrowserstack.ymlconfiguration file. - The Command: Inside the test script (
BstackAIAuthoring.java), the test uses a standard SeleniumJavascriptExecutorto pass the Natural Language instruction to the BrowserStack environment:// Example Objective: Find Google Pixel 3 phone on the website and add 5 of them to the cartjse.executeScript("browserstack_executor: {\"action\":\"ai\",\"arguments\": [\" Click on the Google button and Add 5 Pixel 3 phones to cart\"]}");
- Execution: The BrowserStack Cross-Device Automation Agent intercepts this command, interprets the natural language, and executes the equivalent low-level Selenium actions on the target web page.
- Clone the repository
- Replace
YOUR_USERNAMEandYOUR_ACCESS_KEYwith your BrowserStack access credentials inbrowserstack.yml. - Declare capability
aiAuthoring: trueinbrowserstack.ymlfile (if not already present). - Install dependencies
mvn compile - To run the test suite having cross-platform with parallelization, run
mvn test -P sample-test. - To run local tests, run
mvn test -P sample-local-test.
Understand how many parallel sessions you need by using ourParallel Test Calculator.
- Add maven dependency of
browserstack-java-sdkin yourpom.xmlfile:<dependency> <groupId>com.browserstack</groupId> <artifactId>browserstack-java-sdk</artifactId> <version>LATEST</version> <scope>compile</scope></dependency>
- Modify your build plugin to run tests by adding
argLine -javaagent:${com.browserstack:browserstack-java-sdk:jar}in the Surefire plugin configuration. - Install dependencies
mvn compile.
- If using Gradle, Java v9+ is required.
- Clone the repository
- Install dependencies
gradle build - To run the test suite having cross-platform with parallelization, run
gradle sampleTest. - To run local tests, run
gradle sampleLocalTest.
- Add
compileOnly 'com.browserstack:browserstack-java-sdk:latest.release'in dependencies in yourgradle.build. - Fetch Artifact Information and add
jvmArgsproperty in tasksSampleTest andSampleLocalTest. - Install dependencies
gradle build.
- You can view your test results on theBrowserStack Automate dashboard.
- For detailed documentation on general Selenium and Java setup with BrowserStack Automate, please refer to theofficial documentation.
If you are running into any issues or have any queries, please checkBrowserstack Support page orget in touch with us.
About
AI Authoring Automate Demo Repository for Browserstack
Resources
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Releases
Packages0
Uh oh!
There was an error while loading.Please reload this page.
Contributors4
Uh oh!
There was an error while loading.Please reload this page.
