I am using selenium to perform click a link:
<form method="post" action="example.com" id="form1">
<input type="hidden" name="__EVENTTARGET" id="__EVENTTARGET" value="" />
<input type="hidden" name="__EVENTARGUMENT" id="__EVENTARGUMENT" value="" />
<a href="javascript:__doPostBack('gvOnLineUser','KickOut$0')">click Me</a>
</form>
so as you see when I click the link, it execute a javascript snippet
:
var theForm = document.forms['form1'];
if (!theForm) {
theForm = document.form1;
}
function __doPostBack(eventTarget, eventArgument) {
if (!theForm.onsubmit || (theForm.onsubmit() != false)) {
theForm.__EVENTTARGET.value = eventTarget;
theForm.__EVENTARGUMENT.value = eventArgument;
theForm.submit();
}
}
First, I tried to submit it with click:
el = browser.find_element_by_xpath("//form[@id='form1']/a").click()
but this does not execute as I expect, this means it doesn't submit the form.
Then I tried to simulate a post request, but it seems that selenium
doesn't supply a post
method.
At last I tried to use submit()
method, but how can I change the value of these two hidden element value?