I am trying to catch unexpected events in the background of a mobile app and decided to create a separate thread that would wait for that event to occur using the Mobile.waitForElementPresent
keyword. I would start the application in the main thread, and then create a new thread right after that would wait for the events to occur. Whenever I run the program, I get this error.
Exception in thread "Thread-14" com.kms.katalon.core.exception.StepFailedException: No driver found
at com.kms.katalon.core.mobile.helper.MobileScreenCaptor.getAnyAppiumDriver(MobileScreenCaptor.java:82)
at com.kms.katalon.core.mobile.helper.MobileScreenCaptor.take(MobileScreenCaptor.java:49)
at com.kms.katalon.core.helper.screenshot.ScreenCaptor.takeScreenshotAndGetAttributes(ScreenCaptor.java:37)
at com.kms.katalon.core.mobile.keyword.internal.MobileKeywordMain.stepFailed(MobileKeywordMain.groovy:40)
at com.kms.katalon.core.mobile.keyword.internal.MobileKeywordMain.runKeyword(MobileKeywordMain.groovy:23)
at com.kms.katalon.core.mobile.keyword.builtin.WaitForElementPresentKeyword.waitForElementPresent(WaitForElementPresentKeyword.groovy:80)
at com.kms.katalon.core.mobile.keyword.builtin.WaitForElementPresentKeyword.execute(WaitForElementPresentKeyword.groovy:64)
at com.kms.katalon.core.keyword.internal.KeywordExecutor.executeKeywordForPlatform(KeywordExecutor.groovy:73)
at com.kms.katalon.core.mobile.keyword.MobileBuiltInKeywords.waitForElementPresent(MobileBuiltInKeywords.groovy:1553)
at com.kms.katalon.core.mobile.keyword.MobileBuiltInKeywords$waitForElementPresent$0.call(Unknown Source)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:47)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:136)
at patient.ErrorHandling$ThreadDeploy_Error.run(ErrorHandling.groovy:29)
Is there any way I can use Mobile keywords on the application I already started, within the newly created separate thread?
Here is the run method for the thread I am creating.
public void run() {
try {
println("[THREAD INFO] Thread " + this.threadName + " successfully deployed. Date: " + Util.getCurrentDateAsString())
KeywordUtil.logInfo("[THREAD INFO] Thread " + this.threadName + " successfully deployed. Date: " + Util.getCurrentDateAsString())
// Wait for error element
Mobile.waitForElementPresent(findTestObject('Object Repository/Mobile/Error_Elements/android.widget.Error_PopUp_Text'), Constants.INFINITY)
KeywordUtil.markError("[THREAD WARN] Error notification recieved. Date: " + Util.getCurrentDateAsString())
} catch (InterruptedException e) {
System.out.println( this.threadName + "-- Thread interrupted!!!");
}
}