Posts: 997
Threads: 239
Joined: Jul 2022
Similar situations exist where, likewise, delays need to be added, otherwise there's a chance of failure.
100.ms();
var e3 = w2.Elm["PANE", navig: "la"]["BUTTON"].Find(3);
e3.PostClickR();
//e3.MouseClickR();
100.ms();
Posts: 997
Threads: 239
Joined: Jul 2022
04-14-2024, 11:47 PM
(This post was last modified: 04-14-2024, 11:51 PM by Davider.)
For solving the issue #31, I have the following suggestions:
Support a control for text input, its role might be TEXT OR web:TEXT.
When operating this control, automatically activate and wait for the following status before executing(Default implementation in relevant functions of LA, no longer manually adding relevant code.).
role: TEXT OR web:TEXT
State: FOCUSED, FOCUSABLE
Posts: 12,028
Threads: 139
Joined: Dec 2002
#31 and #32: does it happen after opening a Chrome tab? I did not test much, but very likely immediately after it Chrome is still not ready for some actions, and need to wait.
#33: can you confirm that the UI element sometimes does not have
FOCUSED state immediately after calling
e.Focus(); but has it after some time? To test it:
e.Focus();
if (!e.IsFocused) {
print.it("not fucused after e.Focus");
wait.until(3, () => e.IsFocused);
}
keys.send("test");
Posts: 997
Threads: 239
Joined: Jul 2022
04-15-2024, 05:32 AM
(This post was last modified: 04-15-2024, 06:04 AM by Davider.)
Quote:can you confirm that the UI element sometimes does not have FOCUSED state immediately after calling e.Focus()
Yes, I've encountered this several times, but the probability of this issue occurring isn't very high.
It's also possible that the webpage elements before these codes haven't fully loaded yet.
#32 Code
The code works unstably in the class file. I added a delay, and so far, I haven't encountered any issues.
If the code is in the main file, it seems to work reliably without adding a delay.
I'm a bit confused now and don't know the root cause of the problem.
#31
I think there might be other external factors at play, such as system notifications, foreground software, etc. In such cases, the best approach is to add retry mechanisms.
Posts: 997
Threads: 239
Joined: Jul 2022
04-24-2024, 12:21 PM
(This post was last modified: 04-24-2024, 12:36 PM by Davider.)
How to wait for two states of an Elm? EState.
FOCUSED and EState.
FOCUSABLE
wait.until(30, () => e.State == EState.FOCUSABLE???);
Would it be more appropriate to use
wait.retry?
I want to implement: If the state of element e is not FOCUSED and FOCUSABLE, then execute e.MouseClick() until the state meets the requirements.
var w = wnd.find(1, "*Google Chrome", "Chrome_WidgetWin_1").Activate();
var e = w.Elm["web:TEXT", "Message ChatGPT…"].Find(3);
e.MouseClick();
//wait.until(30, () => e.State == EState.FOCUSABLE???); //wait state: FOCUSED And FOCUSABLE
//wait.retry();
Posts: 12,028
Threads: 139
Joined: Dec 2002
04-24-2024, 01:02 PM
(This post was last modified: 04-24-2024, 01:03 PM by Gintaras.)
Quote:How to wait for two states of an Elm? EState.FOCUSED and EState.FOCUSABLE
wait.until(30, () => e.State.Has(EState.FOCUSED | EState.FOCUSABLE));
Quote:I want to implement: If the state of element e is not FOCUSED and FOCUSABLE, then execute e.MouseClick() until the state meets the requirements.
wait.retry(30, () => { e.MouseClick(); wait.until(.5, () => e.State.Has(EState.FOCUSED | EState.FOCUSABLE)); });
Not tested.