XCUITest - What else can I use besides sleep to find an item on the screen after the back button was clicked? - xcuitest

We have multiple iOS XCUITests for which a back button was clicked. After this click, we do something else in the test ( many various things depending on the test ). However, on certain screens in our app, no matter what step is next ( another button click, an assertion, etc. ), the test will fail unless a sleep is used. It seems like the test is not waiting for the next screen to finish what it is doing. This could be drawing ui elements, background items running, etc. When I add a sleep of 5 seconds, the tests are fine and continue to completion with no issues. In automation, it's my understanding that sleeps are not ideal and should be avoided if possible. Also, I believe the XCUITests have some built in wait time to wait for elements. However, in this case, without the sleep, the test fails then.
So, to improve out automation tests, what are some suggestions we can try besides sleep for screen transitions like this back button click?

You can either wait for an element on new screen to appear or wait for an element on the previous screen to disappear.
Use newElement.waitForExistence(timeout: 5)
or
previousElement.waitForDisappearance(timeout: 5)
Grab waitForDisappearance here https://github.com/devexperts/screenobject

Related

Sikuli opening windows start menu without reason

Im trying to create a script that works on two differents windows simultaneously, but everytime the script clicks, it opens the windows start menu without reason which hides part of my screen and cause FindFailed errors.
What can I do to prevent that ? What causes this issue ?
Clicks with SikuliX are not "simultaneously" but always sequentially one after the other.
So tell a bit more about your setup.
A relevant snippet of your script code might help as well.
Have you tried "run in slow motion", where you can better watch, where the mouse moves and clicks?

Click does not work on iPad when pressed for too long

I have developed a webapp which we usually run on an ipads browser, usually Chrome. There is a problem for a older users when they need to press on a button. They usually press hard and longer than average users, thus the click never gets registered.
The app is an angular app and I've tried to bind a (mousedown) event in hopes of making it fire the event when first touch it. But it seems like that when you hold it down longer on an ipad, it just starts to focus on the text.
Any ideas on how to improve the UX in this case? A lot of older users gets frustrated because to them it does not work.
When you hold your finger on the button you may never reach the mouse events, especially if you move your finger a little. You may check the order of events here https://patrickhlauke.github.io/touch/tests/event-listener_all-no-timings.html
To handle your issue you may handle either pointerdown or touchstart event.

Apple Safari Buttons onclick takes to long

i have a simple system to register who is present at a party.
I created an easy numkeypad with buttons, and that works. But when I try it in Safari (or any other mobile browser), it takes about a second before I can press the next button. It has to be quick, so this is too long.
Is there any way to shorten this "waiting" time between button presses.
click events are delayed in mobile browsers due to the fact the browser has to ensure the user isn't double-tapping or tap-holding an element.
I have written a jQuery plugin that can handle touch and mouse events in a convenient way, and allows you to bind one event to trigger without a delay (tap). You can check it out here:
https://github.com/benmajor/jQuery-Mobile-Events

Java - How to delay after clicking a button

I have a homework assignment to make a game of concentration. The only thing I can't figure out is delaying flipping back the cards after the second card is clicked (just the delay part). I have it so that on click, it shows the card, if it isn't a match, it should delay, then hide the card. If I use Thread.sleep after it should show the card, it just sleeps before that and never actually shows it.
Is there a way to do this with Thread.sleep or do I have to use timers? I didn't try hard yet, but I wasn't able to get the timers working right because it should stop allowing input until the delay is over and the cards are flipped back.
Edit: Never mind, I just used timers and checked if it was running already before doing anything.

How to know in Flex when the user has completed resizing the browser window

I need to do some updates to components after a user has resized the browser window. Is there a good solution to determine when a user has completed resizing? I wasn't able to find any flex events that would cover this case.
There's no "perfect" solution unfortunately. All you get is repeated RESIZE events. The user can stop resizing, and resume again, at any time, which is not foreseeable.
Probably the best (but not nearly perfect) solution would be to start a timer when you get a RESIZE event. When the timer fires, do what you have to do (resize complete). When you get a RESIZE event while the timer is still running, ignore the event and restart the timer.