After execute `adb` command via Window CMD, Connection is refused

Below is my script

Mobile.startApplication('F:\\%%my app%%.apk', false)

MobileDriverFactory.getDriver().resetApp() // app data clear

GlobalVariable.G_device_Height = Mobile.getDeviceHeight() 

GlobalVariable.G_device_Width = Mobile.getDeviceWidth()



String cmd = "adb shell monkey -p com.rsupport.mvagent -c android.intent.category.LAUNCHER 1"

WebUI.comment(cmd.toString())

Runtime.getRuntime().exec(cmd)

WebUI.delay(1)

int startX = GlobalVariable.G_device_Width / 2
int endX = startX

int startY = GlobalVariable.G_device_Height * 0.99
int endY = GlobalVariable.G_device_Height * 0.01

Mobile.swipe(startX, endY, endX, startY)

Mobile.tap(findTestObject('android.widget.Button1 -  (3)'), 10) // tap Button

I am trying to execute a certain app(%com.rsupport.mvagent%) that already installed at test device.

So after start Application(%%my app%%), I execute cmd command that runs (%com.rsupport.mvagent%).

cmd command contains “adb ~~”.
( I think executing a “adb ~~” cmd command makes problem at connection. )

After executing that cmd command, Error occurs.
Root cause: org.openqa.selenium.WebDriverException: Connection refused: connect

2019-06-24 18:49:22.475 ERROR c.k.k.core.keyword.internal.KeywordMain  - ❌ Cannot swipe on device. (Root cause: org.openqa.selenium.WebDriverException: Connection refused: connect
Build info: version: '3.7.1', revision: '8a0099a', time: '2017-11-06T21:07:36.161Z'
System info: host: 'DESKTOP-NHPS9K4', ip: '192.168.9.2', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_181'
Driver info: driver.version: AppiumDriver
    at io.appium.java_client.remote.AppiumCommandExecutor.lambda$2(AppiumCommandExecutor.java:101)
    at io.appium.java_client.remote.AppiumCommandExecutor.execute(AppiumCommandExecutor.java:100)
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:600)
    at io.appium.java_client.DefaultGenericMobileDriver.execute(DefaultGenericMobileDriver.java:46)
    at io.appium.java_client.AppiumDriver.execute(AppiumDriver.java:1)
    at io.appium.java_client.android.AndroidDriver.execute(AndroidDriver.java:1)
    at com.kms.katalon.core.appium.driver.SwipeableAndroidDriver.execute(SwipeableAndroidDriver.java:1)
    at io.appium.java_client.AppiumDriver.getContext(AppiumDriver.java:216)
    at com.kms.katalon.core.mobile.keyword.builtin.SwipeKeyword$_swipe_closure1.doCall(SwipeKeyword.groovy:73)
    at com.kms.katalon.core.mobile.keyword.builtin.SwipeKeyword$_swipe_closure1.call(SwipeKeyword.groovy)
    at com.kms.katalon.core.mobile.keyword.internal.MobileKeywordMain.runKeyword(MobileKeywordMain.groovy:21)
    at com.kms.katalon.core.mobile.keyword.builtin.SwipeKeyword.swipe(SwipeKeyword.groovy:71)
    at com.kms.katalon.core.mobile.keyword.builtin.SwipeKeyword.execute(SwipeKeyword.groovy:66)
    at com.kms.katalon.core.keyword.internal.KeywordExecutor.executeKeywordForPlatform(KeywordExecutor.groovy:56)
    at com.kms.katalon.core.mobile.keyword.MobileBuiltInKeywords.swipe(MobileBuiltInKeywords.groovy:153)
    at com.kms.katalon.core.mobile.keyword.MobileBuiltInKeywords$swipe$2.call(Unknown Source)
    at Run_Mobizen.run(Run_Mobizen:53)
    at com.kms.katalon.core.main.ScriptEngine.run(ScriptEngine.java:194)
    at com.kms.katalon.core.main.ScriptEngine.runScriptAsRawText(ScriptEngine.java:119)
    at com.kms.katalon.core.main.TestCaseExecutor.runScript(TestCaseExecutor.java:337)
    at com.kms.katalon.core.main.TestCaseExecutor.doExecute(TestCaseExecutor.java:328)
    at com.kms.katalon.core.main.TestCaseExecutor.processExecutionPhase(TestCaseExecutor.java:307)
    at com.kms.katalon.core.main.TestCaseExecutor.accessMainPhase(TestCaseExecutor.java:299)
    at com.kms.katalon.core.main.TestCaseExecutor.execute(TestCaseExecutor.java:233)
    at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:114)
    at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:105)
    at com.kms.katalon.core.main.TestCaseMain$runTestCase$0.call(Unknown Source)
    at TempTestCase1561369721125.run(TempTestCase1561369721125.groovy:21)

I’m looking for good problem solving solution.

Such as

  1. After execute “adb ~~” cmd command, make connection right again
    or
  2. Another way to execute installed app.

Have you guys have good think?

Thank you.