Marionette
Marionette copied to clipboard
Page.type() not working
I can't get the page.type() command to work, anyone having the same issue ? Some advice is appreciated, thanks in advance.
Marionette :
firstly {
page.goto(URL(string: "https://www.myurl.com)!)
}.then {
page.type("input[name='username']", "test")
}. etc
Html snippet :
.....
<div class="form-item3">
<label>Username</label>
<div class="widget"><input autofocus type="email" name="username" class="text fw" autocomplete="username" /></div>
</div>
<div class="form-item3">
<label>Password</label>
<div class="widget"><input type="password" name="password" class="text fw" autocomplete="current-password" /></div>
</div>
....
Try replacing page.type("input[name='username']", "test")
with page.evaluate("document.querySelector(\"input[name='username'\").value = 'test';")
Sorry for not seeing this earlier. I'm afraid that it will be hard to debug this without knowing the site you are visiting. I've personally tried this with quite many sites and made refinements to make it work with as many as possible, I'd be very happy to make it work with the site you are using as well!
You can see what the type
function is doing here:
https://github.com/LinusU/Marionette/blob/3c0699e869fdbe13a5d03042884c17d418293a12/Sources/Marionette.swift#L91-L124
A good first step is to attach a debugger via Safari (you might need to use Safari Technology Preview, are you building an iOS or Mac app?) and see if you get any errors in the console.
If you don't get any errors, try setting break-points or adding console.log
s to SwiftMarionetteSimulateType
in order to see where it's going wrong...
(closing for lack of response)