小编Bil*_*oyo的帖子

XCUITest发现多个匹配错误

我正在为我的应用程序编写测试,需要找到"查看2个更多优惠"按钮,我的页面上有多个这些按钮,但我只想点击一个.当我尝试这个时,会出现一个错误:"发现多个匹配"所以问题是,我可以通过什么方式解决这个问题,这样我的测试就会搜索并点击一个名为"查看2个更多优惠"的按钮.

这是我目前的代码

let accordianButton = self.app.buttons["View 2 more offers"]
    if accordianButton.exists {
        accordianButton.tap()
    }
    sleep(1)
}
Run Code Online (Sandbox Code Playgroud)

swift xcode-ui-testing

15
推荐指数
3
解决办法
1万
查看次数

XCUITest - 元素和后代都没有键盘焦点

我正在测试向我的应用程序添加评论,在我的其他 UI 测试中,我使用了该typeText功能并且一切正常。我还单击了“连接硬件键盘”关闭。应用程序终止测试并显示错误 UI 测试失败 - 在 addComment 方法期间,元素和任何后代都没有键盘焦点。有任何想法吗?

  func testAddComment() {
    let featuredPage = self.app.tabBars["Featured"]
    if featuredPage.exists {
        featuredPage.tap()
    }
    sleep(2)
    let featuredOffer = self.app.tables.cells.elementBoundByIndex(1)
    if featuredOffer.exists {
        featuredOffer.tap()
    }
    sleep(2)
    let addComment = self.app.staticTexts["Add a comment"]
    if addComment.exists {
        addComment.tap()
        addComment.typeText("Test comment")
    }
    sleep(2)
    let postComment = self.app.buttons["Send"]
    if postComment.exists {
        postComment.tap()
    }
    sleep(2)
}
Run Code Online (Sandbox Code Playgroud)

xcode swift xcode-ui-testing

5
推荐指数
3
解决办法
6277
查看次数

浓缩咖啡点击文本的特定词

在我的 espresso 测试中,我想点击带有 id 的文本元素的某个部分SwitchTextView。全文为“您是会员吗?使用电子邮件登录” 当您单击使用电子邮件登录时,它会切换页面视图。

当我使用onView(withId(R.id.switchTextView)).perform(click());测试通过但因为在我想要点击的文本之前有初始文本不会改变视图。如何确定并仅触摸“使用电子邮件登录”文本?

java ui-testing android-espresso

5
推荐指数
2
解决办法
3171
查看次数

解除警报XCUITest

我正在尝试解除我正在使用的XCUITest套件上的警报

app.alerts.buttons["OK"].tap()
Run Code Online (Sandbox Code Playgroud)

使用此功能会解除警报,但随后应用程序继续尝试点击按钮然后失败并显示错误消息" UI TESTING FAILURE-找不到匹配的警报 "

这是控制台输出

 t =     0.00s     Start Test at 2016-11-03 14:07:30.827
t =     0.00s     Set Up
t =     0.00s         Launch uk.co.myapp
t =     4.89s             Waiting for accessibility to load
t =    12.55s             Wait for app to idle
t =    18.46s         Snapshot accessibility hierarchy for uk.co.myapp
t =    19.24s         Find: Descendants matching type Button
t =    19.25s         Find: Elements matching predicate '"Enable notifications" IN identifiers'
t =    19.26s         Tap "Enable notifications" Button
t =    19.26s             Wait …
Run Code Online (Sandbox Code Playgroud)

xcode swift xcode7 xcode-ui-testing

4
推荐指数
1
解决办法
3691
查看次数

XCUITest 中是否有“存在”的反义词

我正在 XCUITest 上编写测试,并检查已删除的项目是否不再存在...我找不到任何可用于 XCTAssert 元素不存在的内容。

有谁知道是否有一个 BOOL 值可以用来检测元素是否不可见?

或者是否有任何解决方法?

提前致谢,

xcode swift xcode-ui-testing xcode8

3
推荐指数
1
解决办法
1715
查看次数

ui测试xcode,如何使用cellquery点击表格视图单元格按钮

我正在为我的应用程序进行ui测试,并坚持点击我的应用程序的登录按钮.我无法找到我给出标识符注册按钮的元素(元素是索引的第3个,这不是问题).

let cellQuery = self.app.tables.cells.element(boundBy: 3)

let signInButton = cellQuery.buttons["signup button"]
if signInButton.exists {
    signInButton.tap()
}
Run Code Online (Sandbox Code Playgroud)

xcode ui-testing uitableview ios xcode-ui-testing

2
推荐指数
1
解决办法
6468
查看次数

Swift 错误“变量在其自身的初始值内使用”

我正在为我的应用程序编写 XCUITest。我声明警报是为了waitForExpectationsWithTimeout使我的测试异步......但是它在第 5 行Variable used within its own initial value的声明中抛出错误alert

    let timeout = NSTimeInterval()
    let app = XCUIApplication()

    let exists = NSPredicate(format: "exists == 1")
    let alert = alert.buttons["OK"]


    testCase.addUIInterruptionMonitorWithDescription("Enable Notifications") { (alert) -> Bool in
            alert.buttons["OK"].tap()
        return true
    }

    self.buttons["Enable notifications"].tap()
    testCase.expectationForPredicate(exists, evaluatedWithObject: alert, handler: nil)
    testCase.waitForExpectationsWithTimeout(timeout, handler: nil)
    app.tap()
Run Code Online (Sandbox Code Playgroud)

有人能告诉我为什么它会抛出这个错误以及我能做些什么来解决这个问题。提前致谢。

xcode ios swift xcode-ui-testing

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

在回收站视图中点击第一个匹配的文本 Android espresso 测试

我试图点击我的应用程序中匹配文本的第一个元素。但是目前我收到一个错误,告诉我由于我当前的代码行有多个匹配项。 onView(allOf(withId(R.id.offerSummaryLayout))).perform(RecyclerViewActions.actionOnItem(Matchers.allOf(hasDescendant(withText("Online sale"))), click()));

我怎样才能改变它,让它点击第一个匹配的元素?提前致谢

android android-espresso uitest

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

使用arc4random生成随机数以添加到字符串以进行UI测试登录xcode UI测试

我正在测试注册应用程序,使用xcode UI测试我想知道如何使用arc4random生成一个随机数,将被输入到应用程序?

这是我的代码,但得到一个类型canont将类型为UInt32的值转换为预期的参数类型字符串.

 let emailBox = self.app.textFields["Email"]
    if emailBox.exists {enter code here
        emailBox.tap()
        emailBox.typeText("testing" + arc4random() + "gmail.com")
    }
Run Code Online (Sandbox Code Playgroud)

testing xcode arc4random ios xcode-ui-testing

-1
推荐指数
1
解决办法
274
查看次数