From 4ac9cace137e2fe44329ee7d46dffeeb6f58f277 Mon Sep 17 00:00:00 2001 From: ShamarYarde Date: Sun, 17 Dec 2023 23:23:13 -0400 Subject: [PATCH] updated popup interaction code with working code (#30577) Previous version of code wouldn't produce desired results. Co-authored-by: Hamish Willee --- .../your_own_automation_environment/index.md | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/files/en-us/learn/tools_and_testing/cross_browser_testing/your_own_automation_environment/index.md b/files/en-us/learn/tools_and_testing/cross_browser_testing/your_own_automation_environment/index.md index 04dc0eca193b2a9..1bce050186acda5 100644 --- a/files/en-us/learn/tools_and_testing/cross_browser_testing/your_own_automation_environment/index.md +++ b/files/en-us/learn/tools_and_testing/cross_browser_testing/your_own_automation_environment/index.md @@ -292,15 +292,17 @@ Try running your test again; the button will be clicked, and the `alert()` popup You can interact with the popup too. Add the following to the bottom of the function, and try testing it again: ```js -await driver.wait(until.alertIsPresent()); +(async function example() { + await driver.wait(until.alertIsPresent()); -const alert = driver.switchTo().alert(); + const alert = driver.switchTo().alert(); -alert.getText().then((text) => { - console.log(`Alert text is '${text}'`); -}); + alert.getText().then((text) => { + console.log(`Alert text is '${text}'`); + }); -alert.accept(); + alert.accept(); +})(); ``` Next, let's try entering some text into one of the form elements. Add the following code and try running your test again: