I encountered a javascript alert in my program that I was able to interact with by reading the text and clicking on the buttons. However, when I tried to verify the alert text using assertequals function, I faced an error. Here is the code snippet:
String test = driver.switchTo().alert().getText();
System.out.println(test);
Assert.assertEquals(test, "You are sharing your report with \"Limited Overall-10000 \".\n\nThis will share your report with \"179\" people. Continue?");
While System.out.println successfully displayed the alert text, I received the following error message when attempting to use assertequals. Interestingly, this issue only occurs for this specific alert, as similar steps work fine for other javascript alerts on the page.
org.openqa.selenium.WebDriverException: [JavaScript Error: "e is null" {file: "file:///C:/Users/IBM_AD~1/AppData/Local/Temp/anonymous2086351268768311654webdriver-profile/extensions/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="a4c2dcc0d6cdd2c1d6e4c3cbcbc3c8c1c7cbc0c18ac7cbc9">[email protected]</a>/components/command_processor.js" line: 7716}]