简体   繁体   中英

How to .click() a button using WebKit in Swift 3?

I'm running Xcode 8 and swift 3. I created a Cocoa app and imported WebKit. When I run my small app it opens web view browser and navigates to the website that I need. I can "getElementById", but how do I invoke clicking on a link?

my goal is to have a little automated test app on my website. thanks.

这是一个古老的问题,但是对于任何偶然发现它的人来说,你可以使用webKit.evaluateJavaScript("document.getElementById('ID OF DESIRED ELEMENT HERE').click();")

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM