Click not working on changing buttons

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

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?

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.

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

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.

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.

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.

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.

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.

You can email us at team AT a9t9.com

After exchanging a number of videos of the problem the way this was solved was by

  1. Switching to DESKTOP automation mode

  2. Running Kantu from one browser, but actually testing in a different browser.

  3. Ensuring that the window being tested is located before the Kantu window.

  4. Using XClick ocr=‘button name’ instead of just the click command.

This then allowed the apply button to be clicked as required and for the test to complete successfully.

1 Like

Hi Adrian,
It seems I have a similar issue.
Can you explain point 2 and 3 please?