Selenium does not register button presses

I have a problem with Selenium IDE on one of my AJAX pages. There is an HTML button with javascript onclick submit that causes a new form element to appear after the button is clicked. The button also only appears via AJAX after the selected value has been selected in the previously dropdown list.

Selenium sees the button appear and thinks that it is clicking on it, but the click doesn't actually work.

I temporarily do not have access to the source code for reasons that I will not go into. I know I'm probably a little vague here ... I'll try to post more details when I can.

Greetings

EDIT: just to clarify, I use the waitForVisible command on a button that passes and then a click that also passes, but then it gets stuck on the next item that makes a selection from the dropdown box. Selenium thinks it does it, but it doesn't :(

+2


source to share


3 answers


If the button click is simply not being recorded, you will need to step into the code to manually record this step by specifying the correct XPath expression or DOM path. Selenium can automatically generate the wrong DOM path, but the only way to make sure you look at the code.

The most likely answer is a matter of time. Selenium tends to fire faster than the DOM can render changes, and this causes errors. You might want to try setting a two second pause directly between the generation of the button and the click of the button.



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

0


source


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

Try replacing the click action with mouse mouseDown and mouseUp one by one using your locator as a 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!

+1


source


I have tried many ways to do this in IE8 64bit and Windows 7. I found that the MouseDownAt

and method works fine MouseUpAt

. For example, I used the following code:

 mouseDownAt(locator, "10,10");
 mouseUpAt(locator, "10,10");

      

+1


source







All Articles