Click not working on changing buttons


#1

Hi,

I’ve got a simple web page with a couple of buttons in a box. These buttons change their text when they are clicked as they have different context based uses.

They start as “edit” and “clear”. If “edit” is pressed they change to “cancel” and “apply”. Clicking “cancel” or “apply” returns the buttons to the original values, but “apply” also performs a POST command.

I’ve got the following test script to click the “edit” button and then click the “apply” button in a loop.

{
“Name”: “Untitled”,
“CreationDate”: “2019-3-7”,
“Commands”: [
{
“Command”: “open”,
“Target”: “http:”,
“Value”: “”
},
{
“Command”: “store”,
“Target”: “1”,
“Value”: “loopcounter”
},
{
“Command”: “while”,
“Target”: “({loopcounter} <= 10)", "Value": "" }, { "Command": "click", "Target": "//*[@id=\"button-box\"]/button[contains(text(),'edit')]", "Value": "" }, { "Command": "click", "Target": "//*[@id=\"button-box\"]/button[contains(text(),'apply')]", "Value": "" }, { "Command": "storeEval", "Target": "{loopcounter}+1”,
“Value”: “loopcounter”
},
{
“Command”: “endWhile”,
“Target”: “”,
“Value”: “”
}
]
}

The clicking of the “edit” button works as expected, but the “apply” doesn’t do anything (but I can see on the screen the button go green as if it has been clicked) and the loop fails next time round because the “edit” button is no longer available.

I’ve tried the latest Chrome and Firefox browsers with the same results.

Any help is greatly appreciated.

Thanks in advance

Adrian


#2

but I can see on the screen the button go green as if it has been clicked

If you change from click to XClick, does it work then?


#3

Hi Timo,

No, I get the same situation. I have tried a few different ways of specifying the button.
When I created the test script the button was defined as “//*[@id=“button-box”]/button[2]”.
I also grabbed a screen shot of the apply button and used that as an image for XClick.

What I find strange is that the button seems to click (if you watch the browser you can see what the script is doing and it does select the correct button) but the underlying Javascript is not triggered.


#4

Is this snipped? Otherwise there appears to be some closing brackets and stuff missing


#5

The code was copied from the Kantu JSON View window. It’s not formatted very well but I think it’s OK.
The script is running OK, just not doing what I expected.


#6

As a test, try using computer vision with XClick (image of button) or XClick (ocr=text on button)

If the xclick it works with a visual locator, then we know that something is wrong with the current html-locator.


#7

I tried using computer vision but it doesn’t help. I can see the screen turn green and the cursor moves to the correct place, but the script behind the button doesn’t run so the buttons stay as ‘cancel’ and ‘apply’.
The macro then fails because it can’t find the ‘edit’ button.


#8

and the cursor moves to the correct place, but the script behind the button doesn’t run

This is very surprising to hear. We have not seen a case so far where XClick (image) fails. If you can share the website with us via email, we would be interested to look at this further. Alternatively, a screencast would also be useful.


#9

It’s hard to share the website as this is part of a much larger project. I might be able to cut it down to just the applicable pieces. I do have a screencast of the buttons, but I don’t think it shows very much. How do I upload that?

After installing the ShareX application the test worked twice, but after closing and restarting browser it’s still failing.


#10

You can email us at team AT a9t9.com