找不到匹配项Find:匹配输入中谓词““” IN标识符”的元素

时间:2018-06-24 10:59:02

标签: swift unit-testing uitest xctestcase

在单元测试中出现此错误:

No matches found for Find: Elements matching predicate '"addressSearchBar" IN identifiers' from input {(
    SearchField, 0x60000038a420, traits: 146029151232, label: 'Search on Google Maps', placeholderValue: 'Search on Google Maps'
)}

这是单元测试:

func testTypeSearch() {
    app.searchFields["addressSearchBar"].typeText("Springfield")
}

我一直在看这篇文章: Xcode UITest sometimes does not find property of XCUIElement

我已经设置了isAccessibilityElement

override func viewWillAppear(_ animated: Bool) {
    super.viewWillAppear(true)
    view.isAccessibilityElement = false
    view.backgroundColor = UIColor.white
    navigationController?.setNavigationBarHidden(true, animated: true)
}

在这里:

searchBar = UISearchBar()
searchBar.isAccessibilityElement = false
searchBar.accessibilityIdentifier = "addressSearchBar"

我尝试了多种解决方案,但未能解决问题。

0 个答案:

没有答案