mkoehnke / WKZombie

WKZombie is a Swift framework for iOS/OSX to navigate within websites and collect data without the need of User Interface or API, also known as Headless browser. It can be used to run automated tests / snapshots and manipulate websites using Javascript.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Form submission

j-csc opened this issue · comments

commented

Hello, is it possible to submit a form without the form's name or just with the id?

I tried doing:
browser.get(by: .Id("theId") ) or browser.get(by: .Name(""))

browser.submit ()

and the browser.dump just returns ... after it returns the html of the page.

Sorry for having too many questions and thanks in advance!

Hi @jaloo555. Thanks for submitting this issue! I was able to reproduce the situation where I couldn't submit a form using the ID tag. I've added a fix and a test to #33. Please take a look at the feature/swap-branch and check if that fixes your issue. I'll merge it as soon as I've made some more tests.

commented

Hi @mkoehnke , I did
>>> browser.get(by: .Id("site-login-form")) >>> browser.submit

for <form id="site-login-form" action="/podium/blank.html">
and the automation doesn't proceed..

I'm not sure whether it's an error on my side of accessing the wrong form since there is an empty form wrapping around that or it's the bug still existing.

Thanks!

commented

I looked up online and I would suggest adding documents.forms[0].submit() to make it easier

@jaloo555 Very strange. It should work with .Id("site-login-form"). Maybe some HTML-generating JavaScript hasn't been executed yet. Have you tried adding a .Wait() period to submit?

Alternatively, can't you just use something like this to get the first HTML form in the current document:
>>> browser.get(by: .XPathQuery("//form[1]")) >>> browser.submit