标签: ui-testing

Android espresso maven和gradle设置

有没有人有一个名为espresso的新Android UI测试框架的maven设置示例?

android ui-testing maven android-espresso

6
推荐指数
1
解决办法
3984
查看次数

动态类型和iOS模拟器:如何设置值?

我想编写我的UI测试,以便测试动态类型的所有七种状态,从最小到最大.我该怎么做?

我可以在我的Scheme中为模拟器设置环境变量,然后制作不同的方案吗?

或者我可以在我的测试中以编程方式设置动态类型变量吗?

我宁愿不做一个DynamicTypeController,然后让它说出它是什么类型,因为我冒险忘记将它用于某些元素,然后没有正确测试的行为.

干杯

testing ui-testing ios dynamictype ios-simulator

6
推荐指数
1
解决办法
601
查看次数

Espresso - 如何将 typeText 切换为英语或其他语言输入模式

我正在使用 Espresso 来实现我的应用程序的自动测试框架。但是在我设计的一些测试用例中,我发现我的测试总是失败,根本原因不在我的测试代码中的功能实现代码。根本原因是在android输入法模式下,有时是中文输入模式,而我的输入文本是英文,那么输入值就会失败。所以我想知道如何将当前的typeText输入法模式从中文切换到英文,或者如何在不手动配置的情况下确保输入法模式为英文?我相信这是一个重要的要求,因为当我们的应用程序支持多种语言时,我们需要此功能在测试期间自动切换到所需的语言。以下是我的代码,如果默认输入模式是英文就没有问题。

    onView(withId(R.id.entryWordInput))
        .perform(typeText(entryWord), closeSoftKeyboard());
    onView(withId(R.id.OkButton))
        .perform(click());
Run Code Online (Sandbox Code Playgroud)

提前致谢。

android ui-testing android-testing android-espresso

6
推荐指数
1
解决办法
1242
查看次数

当所有测试一起运行时,Android Instrumented 测试会失败

我正在使用 espresso 运行 Android 仪器测试。

我要运行 70 多个测试,所有测试都通过我的应用程序的不同部分进行点击。

当我将每个测试作为单个测试运行时,它们都有效,并且我得到了绿色测试结果。

当我同时运行它们时(右键单击 androidTest 文件夹 -> 点击运行),其中一些会失败,说找不到视图。

在不同的运行中,不同的测试失败。我想这可能是事情进展得太快了。

你们对如何解决这个问题有什么建议吗?提前非常感谢!

testing android ui-testing android-espresso

6
推荐指数
1
解决办法
1690
查看次数

Espresso 片段事务测试

我正在做这个项目。我开始学习Espresso用于编写 UI 测试的工具测试。我有一个底视图,每个底视图选项卡都有一个父片段及其子片段。我做了一个错误的片段事务,即当从服务底部视图选项卡导航到主页底部视图选项卡时,选择了主页但显示服务片段。

我想在单击主页底部视图选项卡时测试是否添加了主页片段。我已经尝试过这样的代码,但它也传递了错误的情况

我也浏览了下面的 StackOverflow 帖子,但没有工作

在浓缩咖啡测试时确定片段变化

如何使用 Espresso 测试片段是否可见

@Test
fun testHomeFragment_isDisplayed() {

    //click on home navigation button of bottom view
    onView(withId(R.id.navigation_home)).perform(click())

    //click on services navigation button of bottom view
    onView(withId(R.id.navigation_more)).perform(click())

    //click on recycler view item at given position
    onView(withId(R.id.more_rv)).perform(
            RecyclerViewActions.actionOnItemAtPosition<RecyclerView.ViewHolder>(
                    1,
                    MyViewAction.clickChildViewWithId(R.id.row_more_parent)));

    //Again click on home navigation button of bottom view
    onView(withId(R.id.navigation_home)).perform(click())

    //check that the home fragment is displayed or not.
    onView(allOf(withId(R.id.home_pager), withParent(withId(R.id.papa)))).
            check(matches(isCompletelyDisplayed()))

}
Run Code Online (Sandbox Code Playgroud)

如何知道当前屏幕上显示的是哪个片段?

android ui-testing android-fragments kotlin android-espresso

6
推荐指数
0
解决办法
662
查看次数

使用Expresso进行Android UI测试:阶段中没有任何活动已恢复

我目前正在努力在实现LoaderManager.LoaderCallbacks的Android ListActivity上实现功能测试.此Activity有一个简单的布局,其中包含一个EditText,供用户输入一些字符串; ListView,它通过Custom CursorAdapter填充,从自定义内容提供程序获取数据,并使用LoadManager自动更新列表视图内容它改变.

此ListActivity的预期功能仅供用户在EditText上输入一些内容并从ListView中选择一个或多个项目.

为了实现这个功能测试,我正在使用Expresso,这里是我的实现:

public class NewWordActivityFunctionalTest extends ActivityInstrumentationTestCase2<NewWordActivity>{

    public NewWordActivityFunctionalTest() {
        super(NewWordActivity.class);
    }

    @Override
    protected void setUp() throws Exception {
        super.setUp();
        getActivity();
    }

    public void testFillNewThemeFormAndSubmit() throws InterruptedException {
        onView(withId(R.id.submit_new_word_button))
        .perform(click());
    }
}
Run Code Online (Sandbox Code Playgroud)

如果我运行它,我得到的错误堆栈跟踪如下:

com.google.android.apps.common.testing.ui.espresso.NoActivityResumedException: No activities in stage RESUMED. Did you forget to launch the activity. (test.getActivity() or similar)?
at dalvik.system.VMStack.getThreadStackTrace(Native Method)
at java.lang.Thread.getStackTrace(Thread.java:579)
at com.google.android.apps.common.testing.ui.espresso.base.DefaultFailureHandler.getUserFriendlyError(DefaultFailureHandler.java:69)
at com.google.android.apps.common.testing.ui.espresso.base.DefaultFailureHandler.handle(DefaultFailureHandler.java:40)
at com.google.android.apps.common.testing.ui.espresso.ViewInteraction.runSynchronouslyOnUiThread(ViewInteraction.java:159)
at com.google.android.apps.common.testing.ui.espresso.ViewInteraction.doPerform(ViewInteraction.java:90)
at com.google.android.apps.common.testing.ui.espresso.ViewInteraction.perform(ViewInteraction.java:73)
at pt.consipere.hangman.ui.test.NewWordActivityFunctionalTest.testFillNewThemeFormAndSubmit(NewWordActivityFunctionalTest.java:36)
at java.lang.reflect.Method.invokeNative(Native Method)
at android.test.InstrumentationTestCase.runMethod(InstrumentationTestCase.java:214)
at android.test.InstrumentationTestCase.runTest(InstrumentationTestCase.java:199)
at android.test.ActivityInstrumentationTestCase2.runTest(ActivityInstrumentationTestCase2.java:192)
at …
Run Code Online (Sandbox Code Playgroud)

testing android listview ui-testing expresso

5
推荐指数
0
解决办法
3261
查看次数

XCTest UI测试UIElements大小

我在XCode中使用XCTest测试我的应用程序.

有人有例子如何测试UIElement大小?tableView中单元格的高度,或tableView单元格中标签的高度.任何例子将不胜感激.

ui-testing ios xctest swift xcode-ui-testing

5
推荐指数
1
解决办法
2582
查看次数

等待所有HTTP请求在XCode UI测试中完成?

在XCode中测试UI时是否有办法等待所有网络请求完成?

我有一个应用程序发送HTTP请求以从服务器获取一些数据,并且在UI测试中,我想等待在继续之前检索这些数据.目前我正在使用,sleep(1)但这种方法似乎不可靠.

xcode ui-testing ios swift xcode-ui-testing

5
推荐指数
1
解决办法
1028
查看次数

空的测试套件.浓咖啡

我是自动化测试的新手.我想运行一个特定的测试类,即使我有测试套件,它也会输出为

"客户还没准备好......测试运行开始......测试完成了......空测试套件......"

我搜索过并发现了很多解决方案.但他们都没有为我工作.如果我能得到任何帮助,我将不胜感激.这是测试文件.

 package com.smsbits.veridoc.activity;

@RunWith(AndroidJUnit4.class)
public class TempActivityEspressoTest {
public Resources resources;

@Rule
public ActivityTestRule mActivityRule = new ActivityTestRule<>(TempActivity.class);

@Before
public void init() {
    resources = mActivityRule.getActivity().getResources();
}

@Test
public void testCheckInputs() {
    onView(withId(R.id.btnchange)).perform(click());
    onView(withId(R.id.tvrandom)).check(ViewAssertions.matches(withText("hello")));
}} 
Run Code Online (Sandbox Code Playgroud)

这是我的gradle文件.

android {  
... 
packagingOptions {
    ...
    exclude 'META-INF/XXX'
    exclude 'META-INF/DEPENDENCIES.txt'
    exclude 'META-INF/NOTICE'
    exclude 'META-INF/NOTICE.txt'
    exclude 'META-INF/LICENSE'
    exclude 'META-INF/LICENSE.txt'
    exclude 'META-INF/DEPENDENCIES'
}

defaultConfig {
    ...
    multiDexEnabled true
    testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}

testOptions {
    unitTests.returnDefaultValues = true
}

configurations.all {
    resolutionStrategy.force 'com.android.support:support-annotations:23.0.1'
}

 }

dependencies{ …
Run Code Online (Sandbox Code Playgroud)

android ui-testing ui-automation junit-runner android-espresso

5
推荐指数
1
解决办法
440
查看次数

无法确定可命中的tableViewCell的屏幕点

要对我的应用进行UI测试,我必须启用/禁用iCloud.我通过在测试中启动"设置"应用程序,导航到Apple ID场景,然后点击iCloud单元格(参见下图)来完成此操作.

在此输入图像描述

在我的测试中,我检查iCloud单元是否存在并且是可命中的.然后我点击单元格:

// when
let iCloudCell = settingsApp.tables.cells["iCloud"]
let iCloudCellFound = iCloudCell.waitForExistence(timeout: 10)
// then
XCTAssert(iCloudCellFound, "iCloud settings not found")
XCTAssert(iCloudCell.isHittable, "iCloud settings not hittable")

// when
iCloudCell.tap()
Run Code Online (Sandbox Code Playgroud)

这在大多数情况下都有效,但是现在测试在iCloudCell.tap()日志中 停止

t =   113.74s         Find: Descendants matching type Table
t =   113.74s         Find: Descendants matching type Cell
t =   113.74s         Find: Elements matching predicate '"iCloud" IN identifiers'
t =   113.85s     Synthesize event
t =   113.97s         Assertion Failure: <unknown>:0: Failed to determine screen point of …
Run Code Online (Sandbox Code Playgroud)

xcode ui-testing uitableview ios xcode-ui-testing

5
推荐指数
0
解决办法
580
查看次数