Получить UIBUtton без заголовка XCUITest swift - PullRequest
0 голосов
/ 29 ноября 2018

У меня есть UIButton на мой взгляд, я хочу нажать на него в моем случае XCUITest.Эта кнопка не имеет идентификатора доступности или заголовка.В кнопке есть изображение.

Я хочу знать, как получить доступ к UIButton без заголовка или идентификатора.

app.buttons["title"].tap 

будет работать для кнопки с заголовками.

Я пытался использовать опцию регистратора из Xcode, но он предоставляет очень длинный путь, и я ищу какое-либо альтернативное решение.

 let element = app.children(matching: .window).element(boundBy: 0).children(matching: .other).element.children(matching: .other).element.children(matching: .other).element.children(matching: .other).element.children(matching: .other).element.children(matching: .other).element.children(matching: .other).element.children(matching: .other).element.children(matching: .other).element.children(matching: .other).element(boundBy: 2).children(matching: .other).element.children(matching: .other).element.children(matching: .other).element.children(matching: .other).element(boundBy: 0)


XCTAssert(element.children(matching: .button).element.exists, "Button not found")
element.children(matching: .button.element.tap()

ПРИМЕЧАНИЕ: - Я неразрешено вносить любые изменения в код приложения.

Заранее спасибо за помощь.

...