MickeDG MickeDG - 1 year ago 61
iOS Question

Xcode UI Test - how to tap() link in WKWebView?

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!

Answer Source

For some reason I now actually got

let haloLink = app.links.elementBoundByIndex(1)
haloLink.tap()

to work! Probably missed something before.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download