I'm trying to tap a link in a WKWebView using UI Test. The link is defined like so:
<a data-toggle="tab" href="#haloLogin">
<img src=/Images/Halo_small.png">
</a>
I'm able to locate the link like this:
let haloLink = app.links.elementBoundByIndex(1)
(There's another link at index 0)
This is what I get when I print out haloLink.debugDescription:
haloLink: Attributes: Link 0x1257094e0: traits: 146029019138, {{143.0, -392.0}, {32.0, 32.0}}
Element subtree:
→Link 0x1257094e0: traits: 146029019138, {{143.0, -392.0}, {32.0, 32.0}}
Image 0x125709cf0: traits: 146029019142, {{143.0, -392.0}, {32.0, 32.0}}
I've tried using
app.links["#haloLogin"]
without success.
My problem is that I'm not getting
haloLink.tap()
to work.
Any suggestions are welcome!
If the element in wkwebviw like this.
<a href="#">your link text</a>
Then the test code is below
app.links["your link text"].tap()
Look more in the article. UI Testing Cheat Sheet and Examples
Access the link via the contained image. In your question your image's filename is Halo_small.png, so you can tap() it with:
let app = XCUIApplication()
app.images["Halo_small.png"].tap()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With