views:

919

answers:

3

Hey all,

I have a problem running Selenium IDE over one of my AJAX pages. There is a HTML button with a javascript onclick submit that causes a new form element to appear once the button is clicked. The button also only appears through AJAX after a select value has been selected on a previously displayed drop down.

Selenium sees the button appear and thinks it clicks it, but the click doesn't actually work.

I temporarily do not have access to the source code for reasons I won't get into. I know I'm probably being a bit vague here... I'll try to post more specifics when I can.

Cheers

EDIT: Just to clarify, I'm using the waitForVisible command on the button, which passes, and then the click, which also passes, but then it gets stuck on the next element which is making a selection from a drop down box. Selenium thinks it's doing this but it's not :(

A: 

If the click of the button is simply not being recorded you will have to go into the code to manually write that step in while specifying the correct XPath expression or DOM path. Selenium could be auto generating an incorrect DOM path, but the only way to be sure is to look at the code.

The most probable answer is a timing issue. Selenium tends to fire steps faster than the DOM can render changes, and that causes errors. You might want to try specifying a two second pause directly between the generation of the button and the clicking of the button.

If the problem is something different you will have to be more specific.

Yeah, I don't think it's a timing issue because I've used pauses to no avail. I might be getting access to the code soon so I might be able to provide more specific information on how the page was structured soon.All I know at the moment is that selenium sees the generated button, then thinks it is clicking it and it is not. The button is a standard input type='button' with an onclick submission.
Evernoob
+1  A: 

Sometimes, depending on how the things are triggered in a page, selenium's click doesn't work. This could be because the real onClick is later assigned with javascript somewhere else (even if the html tells you it has an "onClick" action.

Try replacing the click action with mouseDown and mouseUp one after the other using your locator as the parameter:

<tr>
    <td>mouseDown</td>
    <td>button_id</td>
    <td></td>
</tr>
<tr>
    <td>mouseUp</td>
    <td>button_id</td>
    <td></td>
</tr>

good luck!

Santi
A: 

I have the similar issue but using yui buttons. I tried the mouseDown & movesUp without any success. Any help is greatly apprecuated.

Edit: I am able to get the focus on to this button (i.e. OK button). But click is not working (as well as movesDown & Up). On contrary, Cancel button is working just fine.

Ravi