18 January 2026:


This forum is now archived and is in read-only mode. Please continue discussions on our improved new Sahi Pro Community forum.



Sahi Pro is an enterprise grade test automation platform which can automate web, mobile, API, windows and java based applications and SAP.

Can't click imagesubmit button

ghillie14ghillie14 Members
edited November -1 in Sahi - Open Source
How does sahi recognise the imagesubmitbuttons?
I have two submit buttons on one form and sahi can't click on a single imagesubmitbutton, and sahi wont click on either of the submit buttons.

_click(_imageSubmitButton(" Place Order on Hold "));
_click(_imageSubmitButton(" Cancel this order and update the status history "));

I tried this but this doesn't work either..
_click(top.document.images[13]);


Any ideas? Cheers for the help!

Comments

  • narayannarayan Administrators
    It should have worked. Can you post the html for the buttons or point us to a website?
  • I have this problem in two places in our system, where sahi will not click on an imagesubmitbutton; there are multiple imagesubmitbuttons which are dynamically generated and calling different actions.

    When running the sahi scripts, sahi clicks on the imagesubmitbuttons, but nothing happens and it errors on the next line.

    Here is the code for the buttons...

    <a href="**site**.php?action=cancel"><img src="images/gd/button_gen.php?text=Cancel" border="0" alt="Cancel" title=" Cancel "></a><input type="image" src="images/gd/button_gen.php?text=Next" border="0" alt="Next" title=" Next " name="sm" value="submit">

    Does sahi handle imagesubmitbuttons differently when dealing with values on a form?

    Hope this helps, Narayan, thank you very much for help with this issue.
  • I'm also running IE 6, and I'm familiar with an issue where IE 6 handles mutliple imagesubmitbuttons differently by passing different values for the X,Y position of the button. Think that might have something to do with this issue?

    Thanks again!
  • Must be a Sahi issue.

    For IE6: the browser refreshes the page, but the submit button is not clicked, with no errors

    For Firefox: I get these errors...
    <code>
    _click(_imageSubmitButton(" Cancel this order and update the status history ")); TypeError: el has no properties
    https://dev.avowsystems.com/_s_/spr/concat.js:307
    https://dev.avowsystems.com/_s_/spr/concat.js:311
    https://dev.avowsystems.com/_s_/dyn/Player_script/script.js:2
    https://dev.avowsystems.com/_s_/dyn/Player_script/script.js:2
    https://dev.avowsystems.com/_s_/spr/concat.js:2210
    https://dev.avowsystems.com/_s_/spr/concat.js:2124
    </code>

    Not sure what the issue is, but would really like some help resolving this issue. Thanks!
  • narayannarayan Administrators
    On the case. give me a day.
  • I can provide $_GET and $_POST variables for when the imagesubmitbutton is clicked, if you think those would help?

    I'm developing a testing system for our company and sahi is perfect for the job. Really appreciate the effort you've put in as I've been able to customize sahi to fit our testing needs. Thanks again!
  • Figured it out! Everything else is working except a few imagesubmitbutton commands in my sahi system. So I spent a few hours to figure out the reason why the button was not being clicked but the page was refreshing.

    Here is the $_POST statement for when I click with the mouse, on an imagesubmitbutton
    Array ( [comments] => [private_comments] => [notify_comments] => 1 [cancel_x] => 60 [cancel_y] => 10 )
    Here is the $_POST returned when sahi is running and clicks on _click(_imageSubmitButton("cancelbutton"));
    Array ( [comments] => [private_comments] => [notify_comments] => 1 [cancel_x] => 0 [cancel_y] => 0 )

    The submit button does not recognize programmatic clicking, hence the co-ords are (0,0) instead of with a mouse click (60,10). We POST the co-ord of the button to get around an IE6 bug.

    The only api I have found that clicks on a given set of co-ordinates is _dragDropXY ?? Is there another for a static single click?

    Also, how should I incorporate that into the _click(_imageSubmitButton( statement?

    Cheers, Narayan!
  • narayannarayan Administrators
    That was quite interesting! Do you use the coords on the server side to know which button was invoked?

    For IE, Sahi calls element.click(); It is a JS method exposed by the browser itself. Not sure why it does not have the coords.

    Here is an explicit way to invoke a click with x, y coords.
    _call(_sahi.simulateMouseEventXY(_imageSubmitButton(...), "click", x, y));
    
    where x and y are numbers.

    The full signature of that function is:
    Sahi.prototype.simulateMouseEventXY = function (el, type, x, y, isRight, isDouble)
    
    Note that this method will give only the click event. Not mouseup/mousedown etc.
    Let me know what you find.
  • Resolved the issue with a work-around. I wasn't able to detect the click on the server-side, so I used the onclick method of the submit button when the button is drawn to create a cookie using jscript. Then for the submitting of the form using php, if the button wasn't clicked, it checks to see if a cookie with a certain value is present, if so, it continues to submit, then deletes the cookies directly after the submit.

    Does't fix the issue of sahi not recognizing the click, but its a work-around that is running nightly on our system and works great.
Sign In or Register to comment.