@@ -53,14 +53,21 @@ enum Platform {
5353async function takeAppScreenshot ( args : {
5454 desiredPlatform : Platform ;
5555 desiredPlatformVersion : string ;
56- appPath : string ;
56+ appPath ? : string ;
5757 desiredPhone : string ;
58+ browserstackAppUrl ?: string ;
5859 config : BrowserStackConfig ;
5960} ) : Promise < CallToolResult > {
6061 let driver ;
6162 try {
6263 validateArgs ( args ) ;
63- const { desiredPlatform, desiredPhone, appPath, config } = args ;
64+ const {
65+ desiredPlatform,
66+ desiredPhone,
67+ appPath,
68+ browserstackAppUrl,
69+ config,
70+ } = args ;
6471 let { desiredPlatformVersion } = args ;
6572
6673 const platforms = (
@@ -98,8 +105,19 @@ async function takeAppScreenshot(args: {
98105 const authString = getBrowserStackAuth ( config ) ;
99106 const [ username , password ] = authString . split ( ":" ) ;
100107
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+ }
103121
104122 const capabilities = {
105123 platformName : desiredPlatform ,
@@ -157,22 +175,54 @@ async function takeAppScreenshot(args: {
157175//Runs AppAutomate tests on BrowserStack by uploading app and test suite, then triggering a test run.
158176async function runAppTestsOnBrowserStack (
159177 args : {
160- appPath : string ;
161- testSuitePath : string ;
178+ appPath ?: string ;
179+ testSuitePath ?: string ;
180+ browserstackAppUrl ?: string ;
181+ browserstackTestSuiteUrl ?: string ;
162182 devices : string [ ] ;
163183 project : string ;
164184 detectedAutomationFramework : string ;
165185 } ,
166186 config : BrowserStackConfig ,
167187) : 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+
168200 switch ( args . detectedAutomationFramework ) {
169201 case AppTestPlatform . ESPRESSO : {
170202 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+
176226 const build_id = await triggerEspressoBuild (
177227 app_url ,
178228 test_suite_url ,
@@ -195,11 +245,29 @@ async function runAppTestsOnBrowserStack(
195245 }
196246 case AppTestPlatform . XCUITEST : {
197247 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+
203271 const build_id = await triggerXcuiBuild (
204272 app_url ,
205273 test_suite_url ,
0 commit comments