Now I have a Test Suites running on Jenkins, how do I get deviceId?
Thinks.
Now I have a Test Suites running on Jenkins, how do I get deviceId?
Thinks.
Hi @roy.zheng,
For me, the Android emulator device id, you can run the command adb devices
, which will return you a list of the running emulators.
The device id seems to be emulator-
plus the port number the emulator is running on. For me, itâs always running on port 5554, so my device id is always emulator-5554
.
Hope this helps,
Chris
thank you @Chris_Trevarthen .
I try, but it prompts me âNo mobile device with name âemulator-5786â availableâ.
In addition, I also want to know how to make the emulator port always 5786
Hi @roy.zheng,
That does seem weird that the device is created but then canât be found. Could you share the Android Emulator Plugin settings youâre using?
As for using a specific port, the Android Emulator Plugin docs say that it will be a random port every time. However, you might be able to use the Jenkins Port Allocator Plugin to set a value for the port:
https://wiki.jenkins.io/display/JENKINS/Port+Allocator+Plugin
Hope this helps,
Chris
thank you @Chris_Trevarthen
Hi @roy.zheng,
Are you able to turn on the âShow emulator windowâ setting? Iâm wondering if Katalon running on CI is having a problem because there is no graphical representation of the device.
â Chris
thank you @Chris_Trevarthen ,
I turn on the Show emulator window, but the emulator does not work properly.
Hi @roy.zheng,
That makes sense if thereâs no display hooked up to the build node.
Iâve also seen similar issues to what youâre seeing when I didnât run the startApplication()
command at the beginning of the test. Could you share the code of the first test in your test suite?
â Chris
@Chris_Trevarthen Of course,
StartApplication () has the wrong appFile and I know it.
Mobile.startApplication('C:\\Users\\User\\Desktop\\debug0410.apk', false)
def timeout = GlobalVariable.g_Mobile_TimeOut
' need to log in ?'
if(Mobile.waitForElementPresent(findTestObject('android_V1/Login/Button_Sign in'), GlobalVariable.g_waitForElementTime)){
def g_ServerAddress = GlobalVariable.g_ServerAddress
'server is correct? or Switch servers'
if (Mobile.getAttribute(findTestObject('android_V1/Login/Text_ServerName'), 'text', timeout) != g_ServerAddress) {
Mobile.tap(findTestObject('android_V1/Login/Text_ServerName'), timeout)
def serverAddress = GlobalVariable.g_ServerAddress
Mobile.tap(findTestObject('android_V1/Login/CheckedText_serverAddress',[('serverAddress'):serverAddress]), timeout)
Mobile.tap(findTestObject('android_V1/Login/button_ok'), timeout)
}
Mobile.setText(findTestObject('android_V1/Login/EditText_Account'), GlobalVariable.g_username, timeout)
Mobile.setText(findTestObject('android_V1/Login/EditText_Password'), GlobalVariable.g_password, timeout)
Mobile.tap(findTestObject('android_V1/Login/Button_Sign in'), timeout)
}
Hi @roy.zheng,
Ah yes, if youâre not running startApplication()
at all or running it with a non-existent .apk file, Iâm pretty sure that you get the exact error youâre seeing. It definitely isnât very obvious about whatâs really going on.
So, if you point to an actual .apk located on the Jenkins build node, in the startApplication()
call, I bet youâll get further in your test.
Also check out this post that can help you avoid hardcoding the .apk file path in your scripts so itâll be easier to run on Jenkins:
Hope this helps,
Chris
thank you @Chris_Trevarthen
I think reading your article later will be very helpful to me, but I want to solve the problem first.
I tried to make the.apk file exist, but the emulator still doesnât work
Hi @roy.zheng,
That startApplication
code in your test looks right. Itâs odd that itâs still failing. I assume that you turned off the checkbox for âShow emulator windowâ again?
The only other thing that comes to mind is that you might need to move the âstartApplicationâ into the Test Suite itself. So taking it out of the Test Case file and having it as the setup step of the Test Suite script.
âChris
thank you @Chris_Trevarthen,
I turned on the âShow emulator windowâ.
Move the âstartApplication" in the test suite itself?How to?
Hi @roy.zheng,
First, letât try turning off the âShow emulator windowâ again, because I donât think your Jenkins node has a display on it and that could cause the emulator not to start. After youâve done that, try running the tests again, making sure you have the startApplication()
function using the correct path to the file: /data/jenkins/workspace/Mobile_V1/debug0410.apk
.
If that doesnât work, my suggestion to put the startApplication()
function in the Test Suite would mean:
Test Suites/mobile_test
file in Katalon@SetUp
, change it to the following:@SetUp(skipped = false) // Please change skipped to be false to activate this method.
def setUp() {
Mobile.startApplication('/data/jenkins/workspace/Mobile_V1/debug0410.apk', false)
}
startApplication()
line from your Test Case fileThis will mean that you canât run the individual Test Cases any more - youâll need to run them through a Test Suite. There are ways around this, but for right now, we should just see if we can get the Test Suite working.
Hope this helps,
Chris
hi @Chris_Trevarthen or @roy.zheng , can you help to how give the static value of emulaor port number?
for example emulator-5556 will be the name for every build.
I already explore about port allocatiot but still not find the solusion about that.
since I need to parsing the emulator name to deviceID value in katalon CMD execution.
really approciate if you can help
Iâm now using Remote devices (like BrowserStack) to execute Android test cases
Hi @rswitch,
If youâre looking to specify the emulator port when youâre starting the emulator, you might be able to follow these steps:
If you already have an emulator running, you should be able to get the emulator name using this command on the command line:
adb devices
Hope this helps,
Chris
I am facing the same issue as @roy.zheng and still couldnât find a way to work with the emulator.
Any leads would be really helpful?
My emulator always starts on a different port and the port plugin you mentioned here is descoped and there is no way i could pass a device id in this case which matches the random port.