标签: xcode-ui-testing

测试。如何检查键盘是否存在?

XCTAssertTrue(app.keyboards.elementBoundByIndex(0).exists)导致崩溃。那怎么做呢?是否可以检查keaboard是否存在?

xcode ios swift ios9 xcode-ui-testing

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

使用 Xcode7 在 UITest 中使用“-[XCUIElement swipeDown]”时如何设置滑动距离

XCUIElement.h类文件显示
- (void)scrollByDeltaX:(CGFloat)deltaX deltaY:(CGFloat)deltaY;
- (XCUICoordinate *)coordinateWithNormalizedOffset:(CGVector)normalizedOffset;功能。但这些不能在 iOS 设备上使用。XCUIElement.h提供- (void)swipeDown滑动tableview。因为向下滑动的距离不够,所以像MJRefresh这样的pull-to-refresh框架无法响应。
那么如何自定义位置或使用存在功能来编辑向下滑动的距离?

objective-c ios xcode-ui-testing

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

UI测试滑动到删除表视图单元格

我正在尝试在基本购物列表应用程序中构建UI测试,确保滑动删除表视图单元格确实从表视图中删除单元格.

我正在运行下面的测试代码,但是当需要向左滑动表格视图单元格(以显示删除按钮)时,它不会滑动.它似乎可能正在点击它,但它不会滑动.因此,尝试点击"删除"按钮时测试失败,因为"找不到匹配按钮".

如何在表格视图中滑动删除以进行删除?

    func testDeletingCell() {
       let app = XCUIApplication()
       app.navigationBars["ShoppingList.ShoppingListView"].buttons["Add"].tap()

       let element = app.otherElements.containing(.navigationBar, identifier:"ShoppingList.AddShoppingListItemView").children(matching: .other).element.children(matching: .other).element.children(matching: .other).element
       let textField = element.children(matching: .textField).element(boundBy: 0)
       textField.tap()
       textField.typeText("abc")

       let textField2 = element.children(matching: .textField).element(boundBy: 1)
       textField2.tap()
       textField2.typeText("123")
       app.navigationBars["ShoppingList.AddShoppingListItemView"].buttons["Save"].tap()

       let tablesQuery = app.tables
       tablesQuery.children(matching: .cell).element(boundBy: 0).staticTexts["123"].swipeLeft()
       tablesQuery.buttons["Delete"].tap()

       XCTAssert(app.tables.cells.count == 0)
   }
Run Code Online (Sandbox Code Playgroud)

uitableview ios swift xcode-ui-testing

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

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
查看次数

MKAnnotation通过XCTest UI测试

如何通过XCTest的UI测试访问MKMapView上的引脚?

我想计算数字,验证具体的数字(基于可访问性ID或标题)等.

MKAnnotation似乎没有XCUIElementType.

我很难找到关于MKMapView + XCTest的任何文档.

mkannotation xctest xcode-ui-testing swift3 xcode8

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

如何在UITests的`tableViewCell`中访问`detailTextLabel`?

我想检查tableViewCell.detailTextLabel我的UITest中是否有一个给定的字符串.问题是,当我搜索app.tables.cells.children(matching: .staticText)它时,它只会查找标签tableViewCell.textLabel.关于如何查询的任何想法detailTextLabel

testing xcode ios swift xcode-ui-testing

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

iOS UITests - 如何获取当前视图中存在的 XCUIElement 列表

我需要获取当前视图中存在的 XCUIElement 列表。例如,

let app = XCUIApplication()
let allElements = app.otherElements.allElementsBoundByIndex
Run Code Online (Sandbox Code Playgroud)

返回 xcuielements 的完整列表,但我只想获取可命中且存在于当前视图中的元素。

testing xcode automated-tests ios xcode-ui-testing

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

如何在 UITesting 上存根网络请求

有没有办法为用 Swift 编写的 UITests 存根网络请求?

我已经安装了 OHHTTPStubs pod,但无法通过使用它的方法来存根我的网络请求,这是因为 UITest 目标和应用程序目标在不同的线程中执行。

我将不胜感激任何建议。

mocking ui-testing stubbing ohhttpstubs xcode-ui-testing

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

为自动UITesting设置模拟器

我需要设置我的Simulators for Automated UITesting.特别是从键盘上删除Autocorrection,Spellchecking,Prediction等.

我正在为一个模拟器这样做:

plutil -replace KeyboardAutocapitalization -bool NO -- ~/Library/Developer/CoreSimulator/Devices/319FF855-F54C-4BB7-BDED-F0CC4B1FF8FC/data/Library/Preferences/com.apple.Preferences.plist
Run Code Online (Sandbox Code Playgroud)

问题是,当测试在另一台设备上运行时,它将不会设置模拟器,因为UUID是硬编码的.

我也能够像这样启动/选择模拟器:

currentUUID="$(xcrun simctl list devices | grep "iPhone 7 (" | egrep -o -i "[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}")"
Run Code Online (Sandbox Code Playgroud)

我必须放在哪里iPhone 7 (才能获得UUIDiPhone 7而不是7+.这也只有在我之前在Xcode中选择iPhone 7作为模拟器时才有效.另一种方法是更换iPhone 7 (with booted.

但为了使其工作,脚本需要模拟器已经运行.当它已经运行时,更改plist文件实际上不会更新模拟器上的设置.

我怎样才能启动模拟器,然后在设置之前抓住它的UUID?

谢谢.

automated-tests simulator ios run-script xcode-ui-testing

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

如何从我的UI测试访问我的swift类?

我有这样的UI测试:

    func testHome(){
         if(isRedOrange.clear()){
                //code
            }
    }
Run Code Online (Sandbox Code Playgroud)

如何通过UI测试从isRedOrange.swift文件访问isRedOrange.clear函数?

xcode ios swift xcode-ui-testing xcuitest

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