Robot click successful but UI hasn't registered it

Hello,

I have been struggling with a problem related to Click-keyword. In some instances the click event itself has been successful, but the UI hasn’t somehow registered(?) the click which creates a deadlock where Robot reports that the step has been successfully completed, while the UI stays unchanged.

I have not been able to come up with a good solution to this, in some cases the cheap trick of adding eg. 2000ms sleep before the problematic part helps to make the test more stable, but these fails still remain.

Is there any neat way to tackle such problem? All I can think of is somehow retrying the previous keyword, but this doesn’t seem like a very elegant solution.

I can think of two things that can play a rol here:
1 The click hat Browser Library executes doesn’t trigger the right events for the UI.
2 The events are properly fired, but processing the actions that are being triggered takes very long, which leads to a timeout.

1 Like

I’m no developer, but the first point sounds possible. The times I experience these failures I can see the click event taking place (eg. the element changes color, edges are highlighted or whatever) but the action is not taking place, which leads to the situation I described.

Is the website/ web application you are trying to automate publicly accessible?

Unfortunately not, client web-app.

I went through the elements which are causing these problems and in one instance I’m trying to open a drop-down menu by clicking the outer div element and then proceed by selecting an option from the menu. In about 75% of runs the click event opens the menu correctly and the test succeeds, but sometimes the menu won’t open despite the click event.

Could it be that clicking the div element itself is not a good idea? The relative path looks like this:

//div//div//material-input-drop-down-component//div//mat-form-field

Can you post the complete HTML from the menu?

I have seen things like this, sometimes it’s a delay in the menu opening, even if it’s just 1/2 a second.

I find it’s a good idea to use Wait For Elements State with the visible state on the menu item you intended to click as a step between opening the menu and clicking on the menu item.

Hopefully that will help,

Dave.

1 Like

@damies13 Do you now how I can edit a post?

@anzza What I do when I a menu expands when you click or hover with your mouse on it is this:
1: Perform the click or mouse over.
2: Wait until the menu is expanded.
3: Then perform the click action in the expanded menu

I beleive that gets enabled when you reach trust level 1:

Note: I’m not an admin, I have no control over how this forum works, I’m just a community member like you.

Dave.

Sorry cannot paste it publicly :confused:

I find it’s a good idea to use Wait For Elements State with the visible state on the menu item you intended to click as a step between opening the menu and clicking on the menu item.

Yeap I have tried this approach as well but no success so far, the problem is not that the element would not be there, but instead the element is visible and clickable but the click event won’t trigger the event I want, eg. open the dropdown menu.

Another workaround is to find the element which appears last on the UI, find that with Get Element and then click the element I want. Was wondering am I doing something wrong that I keep getting this problem randomly.

What is the wait mechanism you are using in your 2nd step and do you ever have the issue that the menu won’t actually open?

@anzza Well the current project I’m working on doesn’t use Browser Library but Selenium Webdriver. But what I do is a Wait For Element Is Present for this XPath:
//div[@class=‘t-animation-container’ and contains(normalize-space(@style), ‘display: block’)]/ul[contains(@style,‘margin-top: 0px’)]
This XPath is the DIV that contains the sub menu items when I mouse over the menu bar. It some sort of animation. When the animation is finished the margin-top = 0px, and that’s what I check.
For Browser Library you should use like @damies13 said a Wait For Elements State

2 Likes

Hi,
I made a mistake in the config.
Only Level 2 users could edit posts.
I lowered that to level 1 now.

1 Like

Click does also wait for visibility and actionability.

As Wait For Elements State does.
So that should not really make a difference.

I know that some pages do register the onclick event after the element has been created. These elements were already visible and enabled. But at that time, they appear, the are not doing anything.

And because Browser lib is really fast, it is faster that the poorly implemented code :wink:

However, what may help is either Wait Until Network Is Idle which waits until all data are transferred from the server + 500ms or you could maybe (never tested) fetch the onclick property of the button and wait for it containing anything.

That could be done by Wait For Condition with Property

But I actually do not know, what property it has before or after being actually doing something.
But you could try to call in a WHILE loop for 2 seconds Get Property <selector> onclick and log it.

Maybe you can debug it.

4 Likes

Yes! This matches exactly what I’m experiencing, in these instances the Wait For Elements State is redundant as Click already has that implicitly.

And yeap, Browser is just too fast for some apps :smiley:

I tried Wait Until Network Is Idle on the landing page and after about a dozen runs it did the trick, the first click-event was successful 100% of times, so I could get rid of the annoying 2000ms sleep.

I’ll try further debuggin with this last tip, but situation well under control for now. Thank you everybody!

3 Likes

Hi

I am noob to robotframework (been using for about 3 months.)

I am having this problem on public training website UIPlayground where I have been practising.
The page Class attribute: Class Attribute
requires you to click the button which class contains “btn-primary”, after the click there should be Alert you must handle. I started my practicing with selenium and got this done no problem, now I switched to Browser and tried to change my code but Click keyword only highlights the correct button, mutta doesnt give the alert. If I keep waiting the test timeouts since the allert never shows and fails, if I click the button my selfwhile test runs then the tests goes on and passes.

My script is:
new Browser browser=chromium headless=false #slowMo=0:00:01
New Context viewport= {‘width’: 1280, ‘height’: 720}
New Page http://uitestingplayground.com/
Click xpath=//a[text()=‘Class Attribute’]
Sleep 2s
Click xpath= //button[contains(concat(’ ', normalize-space(@class), ’ '), ’ btn-primary ') and @class]
Sleep 2s
Wait For Alert action=ACCEPT
I added the Sleeps thinking there is some problem with the elements not showing up fast enough but others have pointed out thats not the problem since click waits for the elements already (and you can see the click does something to correct button)
The test fails on Wait For Alert since the dialog is not showing, the click only highlits the button:
image

Any ideas whats wrong?

Additional detail:
I managed to get a Pass by switching “Wait for Alert” to “Handle Future Dialogs”. But I feel there is some issue still, since the Alert is not actually shown at any point in browser after the button click. I tried putting 30s sleep after the button click → browser waits for the 30s, then the tests PASSes with no issue, but the alert is not shown (compared you manually click the button or when using Selenium → the Alert is shown).