While running a Selenium Java program, I am attempting to create a JavaScript alert window with a specific string message. I came across a method that involves executing JavaScript within Selenium by interacting with hidden elements:
WebDriver driver;
JavascriptExecutor js = (JavascriptExecutor) driver;
js.executeScript("document.getElementById('auth_login_password').setAttribute('value', val );");
driver.ExecuteScript(string.Format("document.getElementById('cred-password-inputtext').value='{0}';",password));
I would like to know how I can modify this code snippet to trigger a JavaScript alert instead. It would be great if I could also use this as a debugging tool.