WKZombie icon indicating copy to clipboard operation
WKZombie copied to clipboard

Submit form doesn't work

Open Wiingaard opened this issue 7 years ago • 1 comments

Hey, I'm planning to use WKZombie in an upcoming project. I'm trying to login to a website, by setting the value attributes of some input elements and submit a form. I Have experience as an iOS developer, but I'm quite new to the web development (HTML/CSS/Javascript), so maybe I'm misunderstanding something. I'm using the same process as the WKZombie Demo Application.

let action = open(loginUrl)
    >>* get(by: SearchType.id("m_Content_username2"))
    >>> setAttribute("value", value: credentials.username)
    >>* get(by: SearchType.id("password2"))
    >>> setAttribute("value", value: credentials.password)
    >>* get(by: SearchType.id("aspnetForm"))
    >>> submit(then: PostAction.wait(3.0))
    >>* get(by: SearchType.id("s_m_HeaderContent_picctrlthumbimage"))
        
action.start { (result) in
    print(result)
}

This gives me the following Log:

REQUEST
https://www.lectio.dk/lectio/163/login.aspx
[....]

SCRIPT
getElementByXpath("//*[@id='m_Content_username2']").setAttribute("value", "xxx"); document.documentElement.outerHTML;
[]

SCRIPT
getElementByXpath("//*[@id='password2']").setAttribute("value", "yyy"); document.documentElement.outerHTML;
[]

SCRIPT
document.getElementById('aspnetForm').submit();
[..................................]

It find all elements and sets the right attributes. When it's has submitted the form and waited for 3 seconds, it can't find the last element. When looking at the snapshots, I see that the attributes get set right, but on the last screenshot I see that the browser is still on the login page, with the password reset. I sure it's the right credentials. It seems that the form isn't submitted right. The printet result is "Element Not Found". Here is the HTML of the form:

<form method="post" action="./login.aspx" onsubmit="javascript:return WebForm_OnSubmit();" onkeypress="javascript:return WebForm_FireDefaultButton(event, 'm_defaultformbtn')" id="aspnetForm" class="ls-master-container2" autocomplete="off">
<!— Lots of HTML and stuff —>
</form>

I've also tried:

  • with a local instance of WKZombie, but with same result.
  • to execute the JavaScript, by running execute("WebForm_OnSubmit()"). The JavaScript result was a Success, but I could seem to go on from there. How would I load the following page?
  • finding the Login-button element and running click, but doesn't work either. It is executing for a while, and the I get the "Cancelling Rendering"-error.

This might not be an issue with WKZombie, but any clues would be much appreciated!! :) Great work with this project 👍

Wiingaard avatar Dec 02 '17 13:12 Wiingaard

Have you figured this out @Wiingaard ? If you are working with a website built with asp , it may be the cause of the error. check https://github.com/dejanstojanovic/MVC-Honeypot . let me know if you find a solution!

MasterSwift avatar Jun 06 '18 03:06 MasterSwift