我正在尝试点击第一屏幕上的元素[例如名为Views的元素],然后单击时会打开一个新屏幕,我想点击一个名为[可展开列表]的元素。因此,在第二次尝试时,我想使用Tap功能为我进行操作。点击()功能不起作用,而使用.click()点击功能确实有效。请看一下我写到此步骤之前的代码:import java.net.MalformedURLException;import java.time.Duration;import org.openqa.selenium.WebElement;import org.openqa.selenium.interactions.touch.TouchActions;import org.openqa.selenium.interactions.touch.TouchActions.*;import io.appium.java_client.TouchAction;import io.appium.java_client.android.AndroidDriver;import io.appium.java_client.android.AndroidElement;import static io.appium.java_client.touch.TapOptions.tapOptions;import static io.appium.java_client.touch.offset.ElementOption.element;import static io.appium.java_client.touch.WaitOptions.waitOptions;public class Gestures extends Parent { public static void main(String[] args) throws MalformedURLException { // TODO Auto-generated method stub AndroidDriver<AndroidElement> driver = Capabilities(); driver.findElementByXPath("//android.widget.TextView[@text= 'Views']").click(); TouchActions t = new TouchActions(driver); WebElement expandList= driver.findElementByXPath("//android.widget.TextView[@text='Expandable Lists']"); //t.tap(tapOptions().withElement(element(webElement))); // for element we need to import it's library just like we did //for the WebElement t.singleTap(expandList); t.perform(); TouchAction(driver).tap(tapOptions() .withElement(element(expandList))) .waitAction(waitOptions(Duration.ofMillis(250))).perform(); }}
添加回答
举报
0/150
提交
取消