Marionette icon indicating copy to clipboard operation
Marionette copied to clipboard

Page.type() not working

Open fvvliet opened this issue 5 years ago • 2 comments

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>
....

fvvliet avatar Nov 24 '19 16:11 fvvliet

Try replacing page.type("input[name='username']", "test") with page.evaluate("document.querySelector(\"input[name='username'\").value = 'test';")

n2nco avatar Feb 10 '20 21:02 n2nco

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.logs to SwiftMarionetteSimulateType in order to see where it's going wrong...

LinusU avatar Feb 11 '20 11:02 LinusU

(closing for lack of response)

LinusU avatar Mar 21 '24 13:03 LinusU