Katalon iOS移动自动化可以创建一个自定义关键字来长按并移动元素(拖放)

时间:2019-06-24 09:52:27

标签: mobile appium katalon-studio

当前,我在katalon中使用“拖放”关键字遇到了一些问题,因为我需要拖动的对象应该在弹出并移动之前被轻按(像1秒钟一样),但是由于“拖放” ”关键字立即生效,而第一个操作(拖动)没有任何超时。现在有没有人尝试使用自定义关键字来解决此类问题?

非常感谢您。

当前,这是我唯一尝试在移动设备上转换的代码,因为它最初是为Web创建的,我不确定自己是否做对了。

package aCustomDragmDrop
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.annotation.Keyword
import com.kms.katalon.core.checkpoint.Checkpoint
import com.kms.katalon.core.checkpoint.CheckpointFactory
import com.kms.katalon.core.mobile.keyword.MobileBuiltInKeywords
import com.kms.katalon.core.model.FailureHandling
import com.kms.katalon.core.testcase.TestCase
import com.kms.katalon.core.testcase.TestCaseFactory
import com.kms.katalon.core.testdata.TestData
import com.kms.katalon.core.testdata.TestDataFactory
import com.kms.katalon.core.testobject.ObjectRepository
import com.kms.katalon.core.testobject.TestObject
import com.kms.katalon.core.webservice.keyword.WSBuiltInKeywords
import com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords

import internal.GlobalVariable

import MobileBuiltInKeywords as Mobile
import WSBuiltInKeywords as WS
import WebUiBuiltInKeywords as WebUI

import org.openqa.selenium.WebElement
import org.openqa.selenium.WebDriver
import org.openqa.selenium.By

import com.kms.katalon.core.mobile.keyword.internal.MobileDriverFactory
import com.kms.katalon.core.webui.driver.DriverFactory

import com.kms.katalon.core.testobject.RequestObject
import com.kms.katalon.core.testobject.ResponseObject
import com.kms.katalon.core.testobject.ConditionType
import com.kms.katalon.core.testobject.TestObjectProperty

import com.kms.katalon.core.mobile.helper.MobileElementCommonHelper
import com.kms.katalon.core.util.KeywordUtil

import com.kms.katalon.core.webui.exception.WebElementNotFoundException

import io.appium.java_client.AppiumDriver
import io.appium.java_client.MobileElement
import io.appium.java_client.TouchAction

public class DragDrop {

    @Keyword
    def dragdrop(TestObject to,TestObject destination,Integer intX,Integer intY) {
    def Eleto = MobileElementCommonHelper.findElement(to, timout)
    def eledest = MobileElementCommonHelper.findElement(destination, timeout)   
    TouchAction touchAction = new TouchAction(driver)
    touchAction.moveToElement(eleto)
    touchAction.waitAction(WaitOptions.waitOptions(Duration.ofMillis(2000)))
    touchAction.perform()
    touchAction.moveToElement(eledest,intX, intY)
    touchAction.release()
    touchAction.perform();
}
}

0 个答案:

没有答案