Question

Unable to Close / Unable to Interrogate ALERT Pop-up box

Hi All,

I have a url automating in Chrome. In a page, there is a alert box appears which needs to be closed by clicking OK. But I am not able to interrogate the alert box.

Please help me with this.

Attached is a screenshot of the alert message.

Comments

Keep up to date on this post and subscribe to comments

Pega
November 21, 2019 - 4:48pm

The post below is pretty close to what you'll need to do. This isn't supported out-of-the-box, so you'll need to use some C# using UIAutomation to get it to work. In the latest version of Studio/Runtime, you do have the ability to SendKeys to the Chrome Browser as well, which might work.

https://community1.pega.com/community/pega-support/question/not-able-interrogate-google-chrome-message-pop

November 22, 2019 - 7:09am

I faced similar problem to perform login operation of a web page.
Used below piece of code and it worked for me.
 

  1. using System;
  2. using System.Collections;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Diagnostics;
  6. using System.IO;
  7. using System.Linq;
  8. using System.Windows.Forms;
  9. using System.Xml;
  10. using System.Runtime.InteropServices;
  11. using System.Windows;
  12.  
  13. namespace Dynamic.Script_8D764454627C233
  14. {
  15. // Script generated by Pega Robotics Studio 8.0.2012.0
  16. // Please use caution when modifying class name, namespace or attributes
  17. [OpenSpan.TypeManagement.DynamicTypeAttribute()]
  18. [OpenSpan.Design.ComponentIdentityAttribute("Script-8D764454627C233")]
  19. public sealed class Script
  20. { [DllImportAttribute("User32.dll")]
  21. public static extern IntPtr FindWindow(String ClassName, String WindowName);
  22. [DllImportAttribute("User32.dll")]
  23. public static extern IntPtr SetForegroundWindow(IntPtr hWnd);
  24. [DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
  25. public static extern IntPtr SendMessage(IntPtr hwnd, uint Msg, IntPtr wParam, IntPtr lParam);
  26. [DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
  27. public static extern IntPtr FindWindowEx(IntPtr hwndParent, IntPtr hwndChildAfter, string lpszClass, string lpszWindow);
  28.  
  29. public void LoginWindow(string Uname,string Password)
  30. {
  31. try
  32. {
  33. System.Threading.Thread.Sleep(2000);
  34. IntPtr hWnd = FindWindow(null, "Windows Security");
  35. // Windows Security is the title of the alert box
  36. SetForegroundWindow(hWnd);
  37. System.Threading.Thread.Sleep(2000);
  38.  
  39. SendKeys.SendWait(Uname);
  40. System.Threading.Thread.Sleep(1000);
  41. SendKeys.SendWait("{Tab}");
  42.  
  43. SendKeys.SendWait(Password);
  44. System.Threading.Thread.Sleep(1000);
  45.  
  46. SendKeys.SendWait(@"{Enter}");
  47. }
  48. catch(Exception ex)
  49. {
  50. OpenSpan.Diagnostics.Diagnostic.PublishException(ex, null);
  51. }
  52.  
  53. }
  54. }

In your case sending the Enter key  alone will solve your problem.