使用Katalon运行移动自动化测试

时间:2018-11-05 13:01:32

标签: mobile automated-tests katalon-studio

我在运行简单的登录,使用Katalon和Kobiton注销自动测试时遇到问题。每当我运行脚本时,它都会卡在开头,并且永远不会运行。我正在尝试找出要完成的工作。任何帮助将不胜感激。

您将在下面看到这是所使用的代码以及通过Katalon接收到的结果消息。

代码:

import static com.kms.katalon.core.checkpoint.CheckpointFactory.findCheckpoint
import static com.kms.katalon.core.testcase.TestCaseFactory.findTestCase
import static com.kms.katalon.core.testdata.TestDataFactory.findTestData
import static com.kms.katalon.core.testobject.ObjectRepository.findTestObject
import com.kms.katalon.core.checkpoint.Checkpoint as Checkpoint
import com.kms.katalon.core.cucumber.keyword.CucumberBuiltinKeywords as CucumberKW
import com.kms.katalon.core.mobile.keyword.MobileBuiltInKeywords as Mobile
import com.kms.katalon.core.model.FailureHandling as FailureHandling
import com.kms.katalon.core.testcase.TestCase as TestCase
import com.kms.katalon.core.testdata.TestData as TestData
import com.kms.katalon.core.testobject.TestObject as TestObject
import com.kms.katalon.core.webservice.keyword.WSBuiltInKeywords as WS
import com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords as WebUI
import internal.GlobalVariable as GlobalVariable

Mobile.startApplication('kobiton', true)

Mobile.tap(findTestObject('android.widget.Button0 - ALREADY HAVE AN ACCOUNT'), 0)

Mobile.tap(findTestObject('android.widget.Button0 - ALREADY HAVE AN ACCOUNT'), 0)

Mobile.tap(findTestObject('android.widget.EditText0 - Email'), 0)

Mobile.setText(findTestObject('android.widget.EditText0 - Email (1)'), '', 0)

Mobile.setText(findTestObject('android.widget.EditText1 - Password'), '', 0)

Mobile.tap(findTestObject('android.widget.ImageView7'), 0)

Mobile.tap(findTestObject('android.widget.Switch0 - OFF'), 0)

Mobile.tap(findTestObject('android.widget.Button3 - LOGIN'), 0)

Mobile.tap(findTestObject('android.widget.Button0 - '), 0)

Mobile.tap(findTestObject('android.widget.TextView12 - Logout'), 0)

Mobile.closeApplication()

消息:

(Stack trace: com.kms.katalon.core.exception.StepFailedException: Unable to start app at: (Root cause: org.openqa.selenium.WebDriverException: org.apache.http.client.ClientProtocolException
Build info: version: '3.7.1', revision: '8a0099a', time: '2017-11-06T21:07:36.161Z'
System info: os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_181'
Driver info: driver.version: SwipeableAndroidDriver)
    at com.kms.katalon.core.keyword.internal.KeywordMain.stepFailed(KeywordMain.groovy:36)
    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.StartApplicationKeyword.startApplication(StartApplicationKeyword.groovy:51)
    at com.kms.katalon.core.mobile.keyword.builtin.StartApplicationKeyword.execute(StartApplicationKeyword.groovy:40)
    at com.kms.katalon.core.keyword.internal.KeywordExecutor.executeKeywordForPlatform(KeywordExecutor.groovy:53)
    at com.kms.katalon.core.mobile.keyword.MobileBuiltInKeywords.startApplication(MobileBuiltInKeywords.groovy:74)
    at com.kms.katalon.core.mobile.keyword.MobileBuiltInKeywords$startApplication.call(Unknown Source)
    at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:133)
    at Script1541159043147.run(Script1541159043147.groovy:16)
    at com.kms.katalon.core.main.ScriptEngine.run(ScriptEngine.java:183)
    at com.kms.katalon.core.main.ScriptEngine.runScriptAsRawText(ScriptEngine.java:108)
    at com.kms.katalon.core.main.TestCaseExecutor.runScript(TestCaseExecutor.java:294)
    at com.kms.katalon.core.main.TestCaseExecutor.doExecute(TestCaseExecutor.java:285)
    at com.kms.katalon.core.main.TestCaseExecutor.processExecutionPhase(TestCaseExecutor.java:264)
    at com.kms.katalon.core.main.TestCaseExecutor.accessMainPhase(TestCaseExecutor.java:256)
    at com.kms.katalon.core.main.TestCaseExecutor.execute(TestCaseExecutor.java:200)
    at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:99)
    at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:90)
    at com.kms.katalon.core.main.TestCaseMain$runTestCase$0.call(Unknown Source)
    at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:149)
    at TempTestCase1541422340602.run(TempTestCase1541422340602.groovy:22)
    at groovy.lang.GroovyShell.runScriptOrMainOrTestOrRunnable(GroovyShell.java:263)
    at groovy.lang.GroovyShell.run(GroovyShell.java:518)
    at groovy.lang.GroovyShell.run(GroovyShell.java:507)
    at groovy.ui.GroovyMain.processOnce(GroovyMain.java:653)
    at groovy.ui.GroovyMain.run(GroovyMain.java:384)
    at groovy.ui.GroovyMain.process(GroovyMain.java:370)
    at groovy.ui.GroovyMain.processArgs(GroovyMain.java:129)
    at groovy.ui.GroovyMain.main(GroovyMain.java:109)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.codehaus.groovy.tools.GroovyStarter.rootLoader(GroovyStarter.java:109)
    at org.codehaus.groovy.tools.GroovyStarter.main(GroovyStarter.java:131)
)

1 个答案:

答案 0 :(得分:0)

您需要将真实的file.apk添加到代码中

src/hello

那么你会成功

您可以在此路径中找到APIdemos.apk文件 “ C:\ Users \ username \ Katalon Studio \ NewTest1.prj \ androidapp \ APIdemos.apk”