@@ -33,6 +33,63 @@ browserstack-sdk python <path-to-test-file>
33
33
\`\`\`
34
34
` ;
35
35
36
+
37
+ const javaInstructions = `
38
+ Add the following dependency to your pom.xml:
39
+ \`\`\`xml
40
+ <dependency>
41
+ <groupId>com.browserstack</groupId>
42
+ <artifactId>browserstack-java-sdk</artifactId>
43
+ <version>LATEST</version>
44
+ <scope>compile</scope>
45
+ </dependency>
46
+ \`\`\`
47
+
48
+ For Gradle projects, add to build.gradle:
49
+ \`\`\`groovy
50
+ dependencies {
51
+ implementation 'com.browserstack:browserstack-java-sdk:LATEST'
52
+ }
53
+ \`\`\`
54
+
55
+ **Automated Step:**
56
+ To migrate your project to use BrowserStack, automatically replace all local WebDriver instantiations (such as \`new ChromeDriver()\`, \`new FirefoxDriver()\`, etc.) with the following BrowserStack RemoteWebDriver code:
57
+
58
+ \`\`\`java
59
+ import org.openqa.selenium.remote.RemoteWebDriver;
60
+ import org.openqa.selenium.MutableCapabilities;
61
+ import java.net.URL;
62
+
63
+ MutableCapabilities capabilities = new MutableCapabilities();
64
+ // Add any desired capabilities here
65
+
66
+ capabilities.setCapability("browserstack.user", System.getenv("BROWSERSTACK_USERNAME"));
67
+ capabilities.setCapability("browserstack.key", System.getenv("BROWSERSTACK_ACCESS_KEY"));
68
+
69
+ WebDriver driver = new RemoteWebDriver(
70
+ new URL("https://hub-cloud.browserstack.com/wd/hub"),
71
+ capabilities
72
+ );
73
+ \`\`\`
74
+
75
+ You can use MCP or a code automation tool to:
76
+ - Search for all occurrences of \`new ChromeDriver()\`, \`new FirefoxDriver()\`, \`new EdgeDriver()\`, and \`new SafariDriver()\` in your codebase.
77
+ - Replace them with the above BrowserStack RemoteWebDriver code.
78
+
79
+ Inform user to export BROWSERSTACK_USERNAME=${ config . browserstackUsername } and
80
+ BROWSERSTACK_ACCESS_KEY=${ config . browserstackAccessKey } as environment variables.
81
+
82
+ Run tests using:
83
+ \`\`\`bash
84
+ mvn clean test
85
+ \`\`\`
86
+
87
+ Or for Gradle:
88
+ \`\`\`bash
89
+ gradle clean test
90
+ \`\`\`
91
+ ` ;
92
+
36
93
export const SUPPORTED_CONFIGURATIONS : ConfigMapping = {
37
94
nodejs : {
38
95
playwright : {
@@ -59,4 +116,11 @@ export const SUPPORTED_CONFIGURATIONS: ConfigMapping = {
59
116
behave : { instructions : pythonInstructions } ,
60
117
} ,
61
118
} ,
119
+ java : {
120
+ playwright : { } ,
121
+ selenium : {
122
+ testng : { instructions : javaInstructions } ,
123
+ cucumber : { instructions : javaInstructions } ,
124
+ } ,
125
+ } ,
62
126
} ;
0 commit comments