當前位置: 首頁>>代碼示例>>Java>>正文


Java UiObject.clickAndWaitForNewWindow方法代碼示例

本文整理匯總了Java中android.support.test.uiautomator.UiObject.clickAndWaitForNewWindow方法的典型用法代碼示例。如果您正苦於以下問題:Java UiObject.clickAndWaitForNewWindow方法的具體用法?Java UiObject.clickAndWaitForNewWindow怎麽用?Java UiObject.clickAndWaitForNewWindow使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.support.test.uiautomator.UiObject的用法示例。


在下文中一共展示了UiObject.clickAndWaitForNewWindow方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: openAppTest

import android.support.test.uiautomator.UiObject; //導入方法依賴的package包/類
@Test
public void openAppTest() throws Exception {
    UiDevice mDevice = UiDevice.getInstance(getInstrumentation());
    mDevice.pressHome();
    // Bring up the default launcher by searching for a UI component
    // that matches the content description for the launcher button.
    UiObject allAppsButton = mDevice
            .findObject(new UiSelector().description("Apps"));

    // Perform a click on the button to load the launcher.
    allAppsButton.clickAndWaitForNewWindow();
    // Context of the app under test.
    Context appContext = InstrumentationRegistry.getTargetContext();

    assertEquals("com.wbrawner.simplemarkdown", appContext.getPackageName());
    UiScrollable appView = new UiScrollable(new UiSelector().scrollable(true));
    UiSelector simpleMarkdownSelector = new UiSelector().text("Simple Markdown");
    appView.scrollIntoView(simpleMarkdownSelector);
    mDevice.findObject(simpleMarkdownSelector).clickAndWaitForNewWindow();
}
 
開發者ID:wbrawner,項目名稱:SimpleMarkdown,代碼行數:21,代碼來源:MainActivityTests.java

示例2: test026FoldupAppDetail

import android.support.test.uiautomator.UiObject; //導入方法依賴的package包/類
@Category(CategoryAppStoreTests_v3_3_15.class)
@Test
public void test026FoldupAppDetail() throws UiObjectNotFoundException {
    TestUtils.screenshotCap("appStoreHome");
    UiObject2 hotObj = device.findObject(By.res("woyou.market:id/tv_hot_all").text("全部"));
    hotObj.clickAndWait(Until.newWindow(), LONG_WAIT);
    TestUtils.screenshotCap("hotAllInterface");
    UiScrollable hotAllScroll = new UiScrollable(new UiSelector().resourceId("woyou.market:id/list_view"));
    UiObject fullAppObj = hotAllScroll.getChild(new UiSelector().className("android.widget.FrameLayout"));
    fullAppObj.clickAndWaitForNewWindow(LONG_WAIT);
    TestUtils.screenshotCap("enterAppDetail");
    UiObject2 foldupButton = device.findObject(By.res("woyou.market:id/iv_arrow"));
    foldupButton.clickAndWait(Until.newWindow(),LONG_WAIT);
    TestUtils.screenshotCap("foldUpAppDetail");
    UiScrollable hotAllScroll1 = new UiScrollable(new UiSelector().resourceId("woyou.market:id/list_view"));
    Assert.assertNotNull(hotAllScroll1);
}
 
開發者ID:sunmiqa,項目名稱:SunmiAuto,代碼行數:18,代碼來源:SunmiAppStore_v3_3_15.java

示例3: test026FoldupAppDetail

import android.support.test.uiautomator.UiObject; //導入方法依賴的package包/類
@Test
public void test026FoldupAppDetail() throws UiObjectNotFoundException {
    TestUtils.screenshotCap("appStoreHome");
    UiObject2 hotObj = device.findObject(By.res("woyou.market:id/tv_hot_all").text("全部"));
    hotObj.clickAndWait(Until.newWindow(), LONG_WAIT);
    TestUtils.screenshotCap("hotAllInterface");
    UiScrollable hotAllScroll = new UiScrollable(new UiSelector().resourceId("woyou.market:id/list_view"));
    UiObject fullAppObj = hotAllScroll.getChild(new UiSelector().resourceId("woyou.market:id/app_view"));
    fullAppObj.clickAndWaitForNewWindow(LONG_WAIT);
    TestUtils.screenshotCap("enterAppDetail");
    UiObject2 foldupButton = device.findObject(By.res("woyou.market:id/iv_arrow"));
    foldupButton.clickAndWait(Until.newWindow(),LONG_WAIT);
    TestUtils.screenshotCap("foldUpAppDetail");
    UiScrollable hotAllScroll1 = new UiScrollable(new UiSelector().resourceId("woyou.market:id/list_view"));
    Assert.assertNotNull(hotAllScroll1);
}
 
開發者ID:sunmiqa,項目名稱:SunmiAuto,代碼行數:17,代碼來源:SunmiAppStore.java

示例4: test023CheckAppDetail

import android.support.test.uiautomator.UiObject; //導入方法依賴的package包/類
@Category(CategoryAppStoreTests_v3_3_15.class)
@Test
public void test023CheckAppDetail() throws UiObjectNotFoundException {
    TestUtils.screenshotCap("appStoreHome");
    UiObject2 hotObj = device.findObject(By.res("woyou.market:id/tv_hot_all").text("全部"));
    hotObj.clickAndWait(Until.newWindow(), LONG_WAIT);
    TestUtils.screenshotCap("hotAllInterface");
    UiScrollable hotAllScroll = new UiScrollable(new UiSelector().resourceId("woyou.market:id/list_view"));
    UiObject fullAppObj = hotAllScroll.getChild(new UiSelector().className("android.widget.FrameLayout"));
    String appName = fullAppObj.getChild(new UiSelector().resourceId("woyou.market:id/tv_name")).getText();
    fullAppObj.clickAndWaitForNewWindow(LONG_WAIT);
    TestUtils.screenshotCap("enterHotAppsFirstOne");
    UiObject2 nameObj = device.findObject(By.res("woyou.market:id/tv_name"));
    Assert.assertEquals("期望的名字是"+appName+",而實際是"+nameObj.getText(),appName,nameObj.getText());
}
 
開發者ID:sunmiqa,項目名稱:SunmiAuto,代碼行數:16,代碼來源:SunmiAppStore_v3_3_15.java

示例5: test023CheckAppDetail

import android.support.test.uiautomator.UiObject; //導入方法依賴的package包/類
@Test
public void test023CheckAppDetail() throws UiObjectNotFoundException {
    TestUtils.screenshotCap("appStoreHome");
    UiObject2 hotObj = device.findObject(By.res("woyou.market:id/tv_hot_all").text("全部"));
    hotObj.clickAndWait(Until.newWindow(), LONG_WAIT);
    TestUtils.screenshotCap("hotAllInterface");
    UiScrollable hotAllScroll = new UiScrollable(new UiSelector().resourceId("woyou.market:id/list_view"));
    UiObject fullAppObj = hotAllScroll.getChild(new UiSelector().resourceId("woyou.market:id/app_view"));
    String appName = fullAppObj.getChild(new UiSelector().resourceId("woyou.market:id/tv_name")).getText();
    fullAppObj.clickAndWaitForNewWindow(LONG_WAIT);
    TestUtils.screenshotCap("enterHotAppsFirstOne");
    UiObject2 nameObj = device.findObject(By.res("woyou.market:id/tv_name"));
    Assert.assertEquals("期望的名字是"+appName+",而實際是"+nameObj.getText(),appName,nameObj.getText());
}
 
開發者ID:sunmiqa,項目名稱:SunmiAuto,代碼行數:15,代碼來源:SunmiAppStore.java

示例6: goToGalleryState

import android.support.test.uiautomator.UiObject; //導入方法依賴的package包/類
@LeadsTo(GalleryState.class)
public void goToGalleryState() {

    UiObject uiObject = getGallery();

    try {
        uiObject.clickAndWaitForNewWindow();
    } catch (UiObjectNotFoundException e) {
        //e.printStackTrace();
        assertNotNull(uiObject);
    }

    SystemClock.sleep(1000);

}
 
開發者ID:Adam-Fresko,項目名稱:brickator,代碼行數:16,代碼來源:MainMenuState.java

示例7: goToMainState

import android.support.test.uiautomator.UiObject; //導入方法依賴的package包/類
@LeadsTo(MainState.class)
public void goToMainState() {

    UiObject uiObject = getMainState();

    try {
        uiObject.clickAndWaitForNewWindow();
    } catch (UiObjectNotFoundException e) {
        //e.printStackTrace();
        assertNotNull(uiObject);
    }

    SystemClock.sleep(1000);

}
 
開發者ID:Adam-Fresko,項目名稱:brickator,代碼行數:16,代碼來源:MainMenuState.java

示例8: d

import android.support.test.uiautomator.UiObject; //導入方法依賴的package包/類
@Test
public void d() throws UiObjectNotFoundException {
    // Initialize UiDevice instance
    mDevice = UiDevice.getInstance(getInstrumentation());

    // Perform a short press on the HOME button
    mDevice.pressHome();

    // Bring up the default launcher by searching for
    // a UI component that matches the content-description for the launcher button
    UiObject allAppsButton = mDevice.findObject(new UiSelector().description("Apps"));

    // Perform a click on the button to bring up the launcher
    allAppsButton.clickAndWaitForNewWindow();
}
 
開發者ID:why168,項目名稱:AndroidProjects,代碼行數:16,代碼來源:MainEspressoTest.java

示例9: testCalculator

import android.support.test.uiautomator.UiObject; //導入方法依賴的package包/類
@Test
public void testCalculator() throws Exception {
    // Home screen apps button
    UiObject appButton = uiDevice.findObject(new UiSelector().descriptionContains("Apps"));
    assertTrue(appButton.exists());

    appButton.clickAndWaitForNewWindow();

    // Scrollable view with apps
    UiScrollable appViews = new UiScrollable(new UiSelector().scrollable(true));
    assertTrue(appViews.exists());

    appViews.setAsHorizontalList();

    // Find calculator application
    UiObject calculatorApp = appViews.getChildByText(new UiSelector()
            .className("android.widget.TextView"), "Calculator");
    assertTrue(calculatorApp.exists());

    calculatorApp.clickAndWaitForNewWindow();

    // Use calculator app
    UiObject clearButton = uiDevice.findObject(new UiSelector().textMatches("clr|del"));
    assertTrue(clearButton.exists());
    clearButton.longClick();

    UiObject threeButton = uiDevice.findObject(new UiSelector().text("3"));
    assertTrue(threeButton.exists());
    threeButton.click();

    UiObject plusButton = uiDevice.findObject(new UiSelector().text("+"));
    assertTrue(plusButton.exists());
    plusButton.click();

    UiObject fiveButton = uiDevice.findObject(new UiSelector().text("5"));
    assertTrue(fiveButton.exists());
    fiveButton.click();

    UiObject equalsButton = uiDevice.findObject(new UiSelector().text("="));
    assertTrue(equalsButton.exists());
    equalsButton.click();

    UiObject display = uiDevice.findObject(new UiSelector()
            .resourceId("com.android.calculator2:id/display"));
    assertTrue(display.exists());

    // Validate
    UiObject displayNumber = display.getChild(new UiSelector().index(0));
    assertTrue(displayNumber.exists());
    assertEquals(displayNumber.getText(), "8");
}
 
開發者ID:Janamou,項目名稱:android-testing-codelab,代碼行數:52,代碼來源:AutomatorTest.java

示例10: testBrowserApp

import android.support.test.uiautomator.UiObject; //導入方法依賴的package包/類
@Test
public void testBrowserApp() throws Exception {
    // Home screen apps button
    UiObject appButton = uiDevice.findObject(new UiSelector().descriptionContains("Apps"));
    assertTrue(appButton.exists());

    appButton.clickAndWaitForNewWindow();

    // Scrollable view with apps
    UiScrollable appViews = new UiScrollable(new UiSelector().scrollable(true));
    assertTrue(appViews.exists());

    appViews.setAsHorizontalList();

    // Find browser application
    UiObject browserApp = appViews.getChildByText(new UiSelector()
            .className("android.widget.TextView"), "Browser");
    assertTrue(browserApp.exists());
    browserApp.clickAndWaitForNewWindow();

    // Browser App set url
    UiObject urlForm = uiDevice.findObject(new UiSelector()
            .resourceId("com.android.browser:id/url"));
    assertTrue(urlForm.exists());
    urlForm.click();
    urlForm.setText("www.google.com");
    uiDevice.pressEnter();

    // Wait to load page
    SystemClock.sleep(10000);

    // Show menu
    uiDevice.pressMenu();

    // Find text on page
    UiObject findButton = uiDevice.findObject(new UiSelector()
            .text("Find on page"));
    assertTrue(findButton.exists());
    findButton.click();

    UiObject findView = uiDevice.findObject(new UiSelector()
            .resourceId("android:id/edit"));
    assertTrue(findView.exists());
    findView.click();
    findView.setText("Google");
    uiDevice.pressEnter();

    SystemClock.sleep(2000);

    // Dismiss search
    UiObject okButtonView = uiDevice.findObject(new UiSelector()
            .resourceId("com.android.browser:id/iconcombo"));
    assertTrue(okButtonView.exists());
    okButtonView.click();
}
 
開發者ID:Janamou,項目名稱:android-testing-codelab,代碼行數:56,代碼來源:AutomatorTest.java


注:本文中的android.support.test.uiautomator.UiObject.clickAndWaitForNewWindow方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。