@@ -53,14 +53,21 @@ enum Platform {
53
53
async function takeAppScreenshot ( args : {
54
54
desiredPlatform : Platform ;
55
55
desiredPlatformVersion : string ;
56
- appPath : string ;
56
+ appPath ? : string ;
57
57
desiredPhone : string ;
58
+ browserstackAppUrl ?: string ;
58
59
config : BrowserStackConfig ;
59
60
} ) : Promise < CallToolResult > {
60
61
let driver ;
61
62
try {
62
63
validateArgs ( args ) ;
63
- const { desiredPlatform, desiredPhone, appPath, config } = args ;
64
+ const {
65
+ desiredPlatform,
66
+ desiredPhone,
67
+ appPath,
68
+ browserstackAppUrl,
69
+ config,
70
+ } = args ;
64
71
let { desiredPlatformVersion } = args ;
65
72
66
73
const platforms = (
@@ -98,8 +105,19 @@ async function takeAppScreenshot(args: {
98
105
const authString = getBrowserStackAuth ( config ) ;
99
106
const [ username , password ] = authString . split ( ":" ) ;
100
107
101
- const app_url = await uploadApp ( appPath , username , password ) ;
102
- logger . info ( `App uploaded. URL: ${ app_url } ` ) ;
108
+ let app_url : string ;
109
+ if ( browserstackAppUrl ) {
110
+ app_url = browserstackAppUrl ;
111
+ logger . info ( `Using provided BrowserStack app URL: ${ app_url } ` ) ;
112
+ } else {
113
+ if ( ! appPath ) {
114
+ throw new Error (
115
+ "appPath is required when browserstackAppUrl is not provided" ,
116
+ ) ;
117
+ }
118
+ app_url = await uploadApp ( appPath , username , password ) ;
119
+ logger . info ( `App uploaded. URL: ${ app_url } ` ) ;
120
+ }
103
121
104
122
const capabilities = {
105
123
platformName : desiredPlatform ,
@@ -157,22 +175,54 @@ async function takeAppScreenshot(args: {
157
175
//Runs AppAutomate tests on BrowserStack by uploading app and test suite, then triggering a test run.
158
176
async function runAppTestsOnBrowserStack (
159
177
args : {
160
- appPath : string ;
161
- testSuitePath : string ;
178
+ appPath ?: string ;
179
+ testSuitePath ?: string ;
180
+ browserstackAppUrl ?: string ;
181
+ browserstackTestSuiteUrl ?: string ;
162
182
devices : string [ ] ;
163
183
project : string ;
164
184
detectedAutomationFramework : string ;
165
185
} ,
166
186
config : BrowserStackConfig ,
167
187
) : Promise < CallToolResult > {
188
+ // Validate that either paths or URLs are provided for both app and test suite
189
+ if ( ! args . browserstackAppUrl && ! args . appPath ) {
190
+ throw new Error (
191
+ "appPath is required when browserstackAppUrl is not provided" ,
192
+ ) ;
193
+ }
194
+ if ( ! args . browserstackTestSuiteUrl && ! args . testSuitePath ) {
195
+ throw new Error (
196
+ "testSuitePath is required when browserstackTestSuiteUrl is not provided" ,
197
+ ) ;
198
+ }
199
+
168
200
switch ( args . detectedAutomationFramework ) {
169
201
case AppTestPlatform . ESPRESSO : {
170
202
try {
171
- const app_url = await uploadEspressoApp ( args . appPath , config ) ;
172
- const test_suite_url = await uploadEspressoTestSuite (
173
- args . testSuitePath ,
174
- config ,
175
- ) ;
203
+ let app_url : string ;
204
+ if ( args . browserstackAppUrl ) {
205
+ app_url = args . browserstackAppUrl ;
206
+ logger . info ( `Using provided BrowserStack app URL: ${ app_url } ` ) ;
207
+ } else {
208
+ app_url = await uploadEspressoApp ( args . appPath ! , config ) ;
209
+ logger . info ( `App uploaded. URL: ${ app_url } ` ) ;
210
+ }
211
+
212
+ let test_suite_url : string ;
213
+ if ( args . browserstackTestSuiteUrl ) {
214
+ test_suite_url = args . browserstackTestSuiteUrl ;
215
+ logger . info (
216
+ `Using provided BrowserStack test suite URL: ${ test_suite_url } ` ,
217
+ ) ;
218
+ } else {
219
+ test_suite_url = await uploadEspressoTestSuite (
220
+ args . testSuitePath ! ,
221
+ config ,
222
+ ) ;
223
+ logger . info ( `Test suite uploaded. URL: ${ test_suite_url } ` ) ;
224
+ }
225
+
176
226
const build_id = await triggerEspressoBuild (
177
227
app_url ,
178
228
test_suite_url ,
@@ -195,11 +245,29 @@ async function runAppTestsOnBrowserStack(
195
245
}
196
246
case AppTestPlatform . XCUITEST : {
197
247
try {
198
- const app_url = await uploadXcuiApp ( args . appPath , config ) ;
199
- const test_suite_url = await uploadXcuiTestSuite (
200
- args . testSuitePath ,
201
- config ,
202
- ) ;
248
+ let app_url : string ;
249
+ if ( args . browserstackAppUrl ) {
250
+ app_url = args . browserstackAppUrl ;
251
+ logger . info ( `Using provided BrowserStack app URL: ${ app_url } ` ) ;
252
+ } else {
253
+ app_url = await uploadXcuiApp ( args . appPath ! , config ) ;
254
+ logger . info ( `App uploaded. URL: ${ app_url } ` ) ;
255
+ }
256
+
257
+ let test_suite_url : string ;
258
+ if ( args . browserstackTestSuiteUrl ) {
259
+ test_suite_url = args . browserstackTestSuiteUrl ;
260
+ logger . info (
261
+ `Using provided BrowserStack test suite URL: ${ test_suite_url } ` ,
262
+ ) ;
263
+ } else {
264
+ test_suite_url = await uploadXcuiTestSuite (
265
+ args . testSuitePath ! ,
266
+ config ,
267
+ ) ;
268
+ logger . info ( `Test suite uploaded. URL: ${ test_suite_url } ` ) ;
269
+ }
270
+
203
271
const build_id = await triggerXcuiBuild (
204
272
app_url ,
205
273
test_suite_url ,
0 commit comments