io.appium.java_client.android.nativekey.KeyEvent.<init>()方法的使用及代码示例

x33g5p2x  于2022-01-24 转载在 其他  
字(4.6k)|赞(0)|评价(0)|浏览(118)

本文整理了Java中io.appium.java_client.android.nativekey.KeyEvent.<init>()方法的一些代码示例,展示了KeyEvent.<init>()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。KeyEvent.<init>()方法的具体详情如下:
包路径:io.appium.java_client.android.nativekey.KeyEvent
类名称:KeyEvent
方法名:<init>

KeyEvent.<init>介绍

暂无

代码示例

代码示例来源:origin: appium/java-client

@Test
public void longPressKeyCodeTest() {
  driver.longPressKey(new KeyEvent(AndroidKey.SPACE));
  final String state = driver.findElement(PRESS_RESULT_VIEW).getText();
  assertThat(state, containsString(String.format("KEYCODE_%s", AndroidKey.SPACE.name())));
  assertThat(state, containsString(String.format("flags=0x%s",
      Integer.toHexString(KeyEventFlag.LONG_PRESS.getValue()))));
}

代码示例来源:origin: appium/java-client

@Test
  public void longPressKeyCodeWithMetastateTest() {
    driver.longPressKey(new KeyEvent(AndroidKey.SPACE)
        .withMetaModifier(KeyEventMetaModifier.SHIFT_ON));
    final String state = driver.findElement(PRESS_RESULT_VIEW).getText();
    assertThat(state, containsString(String.format("KEYCODE_%s", AndroidKey.SPACE.name())));
    assertThat(state, containsString(String.format("META_%s", KeyEventMetaModifier.SHIFT_ON.name())));
    assertThat(state, containsString(String.format("flags=0x%s",
        Integer.toHexString(KeyEventFlag.LONG_PRESS.getValue()))));
  }
}

代码示例来源:origin: appium/java-client

@Test
public void pressKeyCodeTest() {
  driver.pressKey(new KeyEvent(AndroidKey.ENTER));
  assertThat(driver.findElement(PRESS_RESULT_VIEW).getText(),
      containsString(String.format("KEYCODE_%s", AndroidKey.ENTER.name())));
}

代码示例来源:origin: appium/java-client

@Test
public void pressKeyCodeWithMetastateTest() {
  driver.pressKey(new KeyEvent(AndroidKey.SPACE)
      .withMetaModifier(KeyEventMetaModifier.SHIFT_ON));
  final String state = driver.findElement(PRESS_RESULT_VIEW).getText();
  assertThat(state, containsString(String.format("KEYCODE_%s", AndroidKey.SPACE.name())));
  assertThat(state, containsString(String.format("META_%s", KeyEventMetaModifier.SHIFT_ON.name())));
}

代码示例来源:origin: appium/java-client

@Test
public void pressKeyAndGenerateIMEActionTest() {
  driver.pressKey(new KeyEvent()
      .withKey(AndroidKey.ENTER)
      .withFlag(KeyEventFlag.SOFT_KEYBOARD)
      .withFlag(KeyEventFlag.KEEP_TOUCH_MODE)
      .withFlag(KeyEventFlag.EDITOR_ACTION));
  final String state = driver.findElement(PRESS_RESULT_VIEW).getText();
  // This event won't update the view
  assertTrue(state.isEmpty());
}

代码示例来源:origin: appium/java-client

@Test public void startActivityInNewAppTestCase() {
  Activity activity = new Activity("com.android.settings", ".Settings");
  driver.startActivity(activity);
  assertEquals(driver.currentActivity(), ".Settings");
  driver.pressKey(new KeyEvent(AndroidKey.BACK));
  assertEquals(driver.currentActivity(), ".ApiDemos");
}

代码示例来源:origin: qq542391099/FastAutoTest

@Test(description = "测试消息")
public void test() {
  element.click();
  driver.pressKey(new KeyEvent(AndroidKey.BACK));
}

代码示例来源:origin: lgxqf/UICrawler

public static void pressKeyCode(AndroidKey code){
  if(Util.isAndroid()){
    //((AndroidDriver)driver).pressKeyCode(code);
    ((AndroidDriver)driver).pressKey(new KeyEvent(code));
  }else{
    //((IOSDriver)driver)
  }
}

代码示例来源:origin: WasiqB/coteafs-appium

/**
 * @author wasiq.bhamla
 * @since Mar 5, 2018 10:50:09 PM
 */
public void pressEnter () {
  perform ("Pressing Enter button on Android device...",
    d -> d.pressKey (new KeyEvent (AndroidKey.ENTER)));
}

代码示例来源:origin: WasiqB/coteafs-appium

/**
 * @author wasiq.bhamla
 * @since Oct 21, 2017 8:27:50 PM
 */
public void pressBack () {
  perform ("Pressing Back button on Android device...",
    d -> d.pressKey (new KeyEvent (AndroidKey.BACK)));
}

代码示例来源:origin: appium/java-client

@Test public void startActivityInNewAppTestCaseWithoutClosingApp() {
    Activity activity = new Activity("io.appium.android.apis",
      ".accessibility.AccessibilityNodeProviderActivity");
    driver.startActivity(activity);
    assertEquals(driver.currentActivity(), ".accessibility.AccessibilityNodeProviderActivity");

    Activity newActivity = new Activity("com.android.settings", ".Settings")
        .setAppWaitPackage("com.android.settings")
        .setAppWaitActivity(".Settings")
        .setStopApp(false);
    driver.startActivity(newActivity);
    assertEquals(driver.currentActivity(), ".Settings");
    driver.pressKey(new KeyEvent(AndroidKey.BACK));
    assertEquals(driver.currentActivity(), ".accessibility.AccessibilityNodeProviderActivity");
  }
}

代码示例来源:origin: qaprosoft/carina

public static void pressKeyboardKey(AndroidKey key) {
  ((AndroidDriver<?>) getDriver()).pressKey(new KeyEvent(key)
      .withFlag(KeyEventFlag.SOFT_KEYBOARD).withFlag(KeyEventFlag.KEEP_TOUCH_MODE).withFlag(KeyEventFlag.EDITOR_ACTION));
}

相关文章