gpt4 book ai didi

swift - 找不到 Find : Elements matching predicate '""IN identifiers' from input 的匹配项

转载 作者:行者123 更新时间:2023-11-28 07:46:02 27 4
gpt4 key购买 nike

我在单元测试中遇到这个错误:

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"

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

最佳答案

可以尝试将 accessibility 属性设置为 true

此属性的默认值为 false,除非接收器是标准 UIKit 控件,在这种情况下值为 true。

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

关于swift - 找不到 Find : Elements matching predicate '""IN identifiers' from input 的匹配项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51009250/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com