appium / appium-mac2-driver

Next-gen Appium macOS driver, backed by Apple XCTest
Apache License 2.0
130 stars 25 forks source link

How to use cwd option while executing apple script? #105

Closed aakrandan closed 1 year ago

aakrandan commented 2 years ago

Hello,

You could also customize the script working directory by providing the cwd option.

The document says we can choose the working directory from where we can choose to execute our apple script. But I am struggling to understand how to use it. So far i have tried below ways:

String appleScript = "run script \"/Users/monitorteam/Desktop/ScreenCaptureSave.scpt\"";
String path  = System.getProperty("user.dir") + "/src/main/resources/ScreenCaptureSave.scpt";
System.out.println(driver.executeScript("macos: appleScript", ImmutableMap.of("script", appleScript, "cwd", path)));

This is the error I am facing:

org.openqa.selenium.WebDriverException: An unknown server-side error occurred while processing the command. Original error: spawn ENOTDIR
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:17:03'
System info: host: 'Monitors-MacBook-Air.local', ip: '2405:201:d012:2fb6:4479:ab5e:4a25:870b%en0', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.15.7', java.version: '16.0.2'
Driver info: io.appium.java_client.mac.Mac2Driver

I was forced to use script/command option because they weren't optional. But I am not sure what else should i use instead of that.

Also am I using cwd option properly?

KazuCocoa commented 2 years ago

https://github.com/appium/appium-mac2-driver/blob/6ab5fdd947e66946136103d5be09c2bcf4ddad02/README.md#macos-applescript may help. cwd is a working directory to run the given script on. https://github.com/appium/appium-mac2-driver/blob/443594195a5e90f82edbb61967b20c528c226a2c/lib/commands/applescript.js#L74

So, if you'd like to run the appleScript in /some/path, path probably should be /some/path