Simulated click() not firing

I am attempting to automate testing on an internal site from the client-side.

I have been able to run through the all the DOM elements and find the one div that contains the “button”. (It not a button, just text styled to look like a button.) I tried the click() method but it never fires.

This can only be done on the client-side. I cannot adjust the source code to contain any ID’s or names. I only have the method for locating the button.

Here is my Javascript code from the scratch pad. This does find the div that contains the “button”.

var bDivClass = "v-rasterlayout-slot";
var divs = document.getElementsByClassName(bDivClass);
for (var i = 0, len = divs.length; i < len; i++) {
.textContent.localeCompare("Submit Query") == 0){
    console.log("Submit Button found \n" + divs[i]
.click(); <--- the problem

It outputs:

If I inspect the element, I can see a couple of the DIVs have click listeners attached.

Here is the event listener. It is the same for both the child and the parent.

Without changing the source code, how do I simulate a click?


Whilst my javascript foo is somewhat crusty after a working on backend systems for quite a while, I think that this javascript would be clicking on the v-button-caption element.

You actually need to click on the v-button element. In terms of a jQuery selector, you’d want something like

.v-rasterlayout-slot .v-button [.v-button-caption:contains(‘Submit Query’)]

[/code]i.e. select the v-button element within the v-rasterlayout-slot that has a v-button-caption div with the content of “Submit Query”

Within the code structure you have there, you’d probably need to do

div[i] [/i] (Where parent is a function that gets the parent element - you want the great grandparent of the v-caption element)

HTH a little,



Thanks Charles! I’ll try this in a bit and let you know how it worked!