Forum Discussion
Hi,
Try to use the TryToSetCurrent() method. I.e. instead of
Mobile["Refresh"]()
if(Mobile["Device"](device)["Exists"]==true)
use
if(Mobile["TryToSetCurrent"](device))
...
and move
Mobile["Refresh"]()
to the end of the
while(aqDateTime["Now"]()<endtime)
loop in order not to do unnecessary refresh if the device is already found.
Does it help?
Hi Alexkaras,
Thank you for your suggestion but it didn't help. It happened because sometimes testcomplete doesn't recognize the device.
I just update my script and it works as expected.
adding: check the property is empty or null, if null I will refesh the usb port and check it again.
So far, it works for me.
- AlexKaras10 years agoCommunity Hero
Hi,
Thank you for the update.
Yes, for some reason TestComplete (or adb?) sometimes loses connection to the device.
> [...] if null I will refesh the usb port and check it again.
Just wondering if you do this programmatically within your test code or just manually reconnect the device?
- anhvu10 years agoFrequent Contributor
AlexKaras,
I did it automatically with the script as below:
I launch CMD and run the command line "adb usb"
- AlexKaras10 years agoCommunity Hero
Hi,
> I launch CMD and run the command line "adb usb"
Yes, I saw your http://community.smartbear.com/t5/Mobile-Application-Testing/Android-device-is-getting-unplugged-when-executing/m-p/113869#M906 message - thank you for sharing a possible approach.