Wait After Send Keys Causes Clear Text To Fail

read

#1

I have an HTML table that has filters on each column. I want to send text to the filter, check the table to be sure the rows in that column each contain the filter text, then clear the text so I can do the same thing for the next column. My issue is that Katalon is executing things way too fast. It sends the text then clears it so fast that the table doesn’t have time to filter down to the rows. I’ve tried adding various waits, but none of them worked. I added a Delay of one second, which seemed to work as it gave the table enough time to filter. However, then the Clear Text step wasn’t executing. It says it passed, but if I watch, the text is not cleared. How can I make Katalon wait for the table to filter and also clear the filter text?


#2

That’s not quite true. The issue is, the browser has a lot of work to do to render the changes in the data in the table column. Katalon doesn’t know how long that will take, so YOU need to teach it how to do that. As you’ve already guessed, you do that with various “waits”.

It would help us if you showed us your code and what you’ve tried that didn’t work.

So it was executing but not doing what you would expect. Again, we can’t guess what’s wrong, we need to see the code (and errors if you have them).

Follow the advice I posted here:


#3

Hi Russ,

Unfortunately, I can’t post the code here, but I can try to better explain what is going on. When I type text into the filter on a column, it takes about one second for the table to completely filter. From what I can tell, it’s using Angular JS for this. If I use Set Text or Send Keys, then Clear Text, what happens is that the text is input and cleared instantly, then the same actions are performed for the next column. Because I want to verify the filter is working, I need the execution to wait after entering the text so the table can filter and I can verify that each cell in the column has the filter text. If I try this without an explicit delay, my verification fails because it runs on all cells, not the filtered subset. However, if I put an explicit delay, something strange happens. Clear Text passes, verify element text = “” passes, and I see the text cleared for a split second. But then on the next step (send text to the next column), the filter text on the previous column comes back. Therefore, my filters accumulate such that no rows in the table are present, then my verification fails. So I believe something about the delay is causing Katalon to execute the Clear Text step in a strange way. None of the built in waits seem to be working. I think I need something like Wait Until Condition Is True, then be able to specify the condition (such as the table only has 4 rows). Wait for JQuery, Wait for Angular, and Wait for Page Load have not worked. I’ve tried other things to keep execution busy until the table can filter, such as clicking or focusing on random other elements, but it seems that I would need a lot of steps to amount to one second of execution.

Update: I thought the delay was the problem, but I just ran only the first part of the filter test, so I send the text to the filter, then cleared it. It does appear to be cleared. However, if I then manually type text in the next filter, when I stop typing, the old text comes back in the previous filter. So somehow the element is retaining the text and showing it again after it’s supposedly been removed. This is either during the send keys/set text step or the clear text step. I cannot reproduce this issue when manually performing these steps, so it has something to do with the way the automated test is performing these actions.


#4

Okay, that’s a lot to digest. But before I spend a ton of time thinking that through…

1 - I hope you are not testing 3rd party code!. Example, if this is Angular JS code that is being used to apply a filter to a column and you are not employed by ng/google to do that testing, stop. You are doing someone else’s job! Do you think you can do a better job testing their code than 50+ top-notch programmers can do?

2 - Waiting for jQuery/Angular/Page Load is not going to help anything. It sounds as though this is code directly on the page that does not call back to the server, so none of those waits will do anything to help you.

In general terms, testing filter outcomes is pretty much ALWAYS a flaky test. The issues are related to how the filtering is applied:

  1. Wait until user has finished typing, then apply the filter.
  2. Respond to each keypress/keyup event and reapply the filter.
  3. Apply filters asynchronously, maybe with server callbacks/ajax.
  4. Apply filters continuously via interrupts (timer intervals) (A terrible way to do it but I have seen this done in the past)

All and any of which make for tricky testing challenges.

Now, lastly, if you can’t share your code here, I’d treat everything I said as useless for a very simple reason: The code I can’t see is the code most likely to be broken. No amount of help from me (like the advice above) will help fix buggy code. In short, you can’t polish a turd. :wink:


#5

Russ,

I’m not sure if the code is third-party or if one of our developers created it. I got around this issue by refreshing the page after each column filter test section. Not ideal, but it keeps the phantom text from coming back. I imagine some day, when I’m smarter than I am today, I will come back to this test and make it beautiful.


#6

Try with the keyword “waitforelementvisible” before the action.


#7

hello,

do a some poll loop where you are polling if element is visible, present or clickable

Calendar calendar = Calendar.getInstance();
calendar.add(Calendar.SECOND, 30);poll 30 seconds
long stopPollingTime = calendar.getTimeInMillis();
System.out.println(System.currentTimeMillis());
System.out.println("Polling "+stopPollingTime);
int second = 0;
while (System.currentTimeMillis() < stopPollingTime) {
    System.out.println("Polling "+second++);
    try {
        Thread.sleep(1000);
    } catch (InterruptedException e) {
    }
}

not sure is this the trick :slight_smile: