3

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(&#39;gvOnLineUser&#39;,&#39;KickOut$0&#39;)">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?

roger
  • 9,063
  • 20
  • 72
  • 119
  • What is happening in the browser when you click the link? Are you sure there are no other forms with the same `id`? Any iframe elements on the page? Any errors? Can you share a link to the website? Thanks! – alecxe Jul 28 '15 at 14:26
  • @alecxe I have the same case. Can you help me. – donald.sys Aug 09 '21 at 03:53

0 Answers0