I'm using NativeScript 8.x with Appium to run End to End tests using the Android emulator. I have a requirement to run the appium tests on a different port than the default (5546) as it's colliding with another user on the same machine trying to do the same tests.
I've setup an Android Virtual Device with the following capabilities in the appium.capabilities.json file;
"samsung": {
"platformName": "Android",
"platformVersion": "7.0",
"deviceName": "samsung_galaxy_s8",
"avd": "samsung_galaxy_s8",
"lt": 60000,
"newCommandTimeout": 720,
"noReset": false,
"fullReset": false,
"app": ""
}
When I start the tests with;
npm run e2e -- --runType samsung
I get the following;
Executing "/bin/ps aux | grep -ie 'sdk/emulator/qemu' | grep -ie 'samsung_galaxy_s8' | grep -v grep | xargs kill -9"
No matching processes to kill!
Starting emulator with options: -avd samsung_galaxy_s8 -port 5546 ["-no-audio","-no-boot-anim","-wipe-data","-no-snapshot-load","-no-snapshot-save"]
Booting emulator ...
Check if "emulator-5546" is running.
Check has "passed".
Check if emulator is responding
Emulator is booted!
Started device: {"name":"samsung_galaxy_s8","apiLevel":"24","releaseVersion":"7.0","platform":"android","type":"emulator","status":"booted","token":"5546","pid":26944,"startedAt":1572236203683,"config":{"density":1.6,"offsetPixels":25}}
NOTE: The "-avd samsung_galaxy_s8 -port 5546" line there is what I want to change.
Update
I found where appium starts the process and that the port is set by using the attribute 'token' on the emulator object.
This is in the /node_modules/mobile-devices-controller/lib/android-controller.js file;
static startEmulatorProcess(emulator, logPath, options) {
return __awaiter(this, void 0, void 0, function* () {
options = options || ["-no-audio", "-no-snapshot-save", "-no-boot-anim"];
if (logPath) {
options.push(` > ${logPath} 2 >& 1`);
}
utils_1.logInfo(`Starting emulator with options: -avd ${emulator.name} -port ${emulator.token}`, options);
const process = child_process_1.spawn(AndroidController.EMULATOR, [" -avd ", emulator.name, " -port ", emulator.token, ...options], {
shell: true,
detached: false,
});
process.stdout.on("data", (data) => {
console.log(data.toString());
});
process.stdout.on("error", (data) => {
console.log(data.toString());
});
emulator.pid = process.pid;
emulator.process = process;
return emulator;
});
}
Where do I set this token? It's current set to 5546.
from Change port for nativescript end to end testing
No comments:
Post a Comment