Hello,
how do force SF to automatically close (hit ok) these types of dialogs, which sometimes appear during script running?

Thank you!
M. Bert F.
- Marek Bert Fuchs @bert
I figured it out.
// Wait for confirmation dialog const confWin = sf.ui.proTools.confirmationDialog const isThereAConfWin = confWin.elementWaitFor({ timeout: 500, onError: "Continue" }).success // Accept confirmation dialog if (confWin) { sf.ui.proTools.windows.first.buttons.whoseTitle.is("OK").first.elementClick(); };
Helping source: Stop script upon cancel....how? #post-2
Christian Scheuer @chrscheuer2023-11-20 16:52:51.456Z
That looks almost perfect.
Your if block is testing something that always will be true though, which means it'll try to run the
elementClick
action even if theconfirmationDialog
wasn't found.Your if block should instead be:
// Wait for confirmation dialog const confWin = sf.ui.proTools.confirmationDialog const isThereAConfWin = confWin.elementWaitFor({ timeout: 500, onError: "Continue" }).success // Accept confirmation dialog if (isThereAConfWin) { sf.ui.proTools.windows.first.buttons.whoseTitle.is("OK").first.elementClick(); };
Or:
// Wait for confirmation dialog const confWin = sf.ui.proTools.confirmationDialog; const elementWaitResult = confWin.elementWaitFor({ timeout: 500, onError: "Continue" }); // Accept confirmation dialog if (elementWaitResult.success) { elementWaitResult.element.buttons.whoseTitle.is("OK").first.elementClick(); };
Or:
// Wait for confirmation dialog const confWin = sf.ui.proTools.confirmationDialog; const elementWaitResult = confWin.elementWaitFor({ timeout: 500, onError: "Continue", }); // Accept confirmation dialog if (confWin.exists) { confWin.buttons.whoseTitle.is("OK").first.elementClick(); };
Marek Bert Fuchs @bert
Thank you! My goal is to have the most possible short code and fast script results. Which one would be the fastest?
Christian Scheuer @chrscheuer2023-11-21 12:12:17.709Z
#2 or #3 would be ever so slightly faster, since they forego querying the UI a 2nd time. My personal preference would the #3 (I'm counting the 3 replies/examples I shared), because it's easier to read/reason about, which is important.
Generally speaking, all of this would be so fast that you're unlikely to see any actual performance differences in real-world scenarios.