Question
![](/profiles/pega_profile/modules/pega_user_image/assets/user-icon.png)
![](/profiles/pega_profile/modules/pega_user_image/assets/user-icon.png)
EY
US
Last activity: 7 Jun 2019 9:26 EDT
Pega Robotics invoke file upload not working - Chrome Browser
I have a Universal Web adapter(chrome) open a web page which has a file upload function. I'm able to interrogate this control but not able to perform click or invoke proper events to open chose file dialog. Any ideas or suggestion to solve it?
the HTML is :
<input size="78" type="file" name="param.AttachFile" id="AttachFile" onchange="uploadSelectedFile();" contenteditable="false">
Any raised onchanged event for the control is also not working?
-
Like (0)
-
Share this page Facebook Twitter LinkedIn Email Copying... Copied!
![](https://accounts.pega.com/sites/default/files/styles/user_image/public/1689973000/3a78fee4-a7e7-4a05-b0f7-356e3689e691.png?itok=nN1zP2KU)
![](https://accounts.pega.com/sites/default/files/styles/user_image/public/1689973000/3a78fee4-a7e7-4a05-b0f7-356e3689e691.png?itok=nN1zP2KU)
Pegasystems Inc.
US
Hey! I've actually ran into this issue before. After spending too many hours researching this... I found that Chrome stops JavaScript from invoking an action that would open up access to the local system. In this case, the onchange event would open up the "Select a file" dialog but since the event is not started by the user, Chrome will block it entirely.
The only option I found to get around this security policy was to use SendKeys to get the file dialog to open. I called a Focus() on the web control, then sent a SendKeys("{Enter}") to the window. Then I was able to automate the dialog with UI Automation (Microsoft's automation framework). In my case, the system also stopped me from clicking the "Open" button in the dialog (with UI Automation)...again another security policy... so I passed another SendKeys("{Enter}") to the dialog.
Let me know if this helps!
![](/profiles/pega_profile/modules/pega_user_image/assets/user-icon.png)
![](/profiles/pega_profile/modules/pega_user_image/assets/user-icon.png)
EY
US
Hello Mitchell,
Thank you for the reply.
Hello Mitchell,
Thank you for the reply.
Issue is mostly with the control as my automation web control does not show any SendKey() methods(After selecting all options from configure type window) to pass {ENTER} with it.
Can you please help with any alternative to it?
Also
Can you please provide more information on "Automating the dialog with UI Automation (Microsoft's automation framework)"?
![](https://accounts.pega.com/sites/default/files/styles/user_image/public/1689973000/3a78fee4-a7e7-4a05-b0f7-356e3689e691.png?itok=nN1zP2KU)
![](https://accounts.pega.com/sites/default/files/styles/user_image/public/1689973000/3a78fee4-a7e7-4a05-b0f7-356e3689e691.png?itok=nN1zP2KU)
Pegasystems Inc.
US
SendKeys method is only available on the window frame control. With chrome, you have to access the window frame through a proxy of the BrowserForm of the webpage. Refer to the screenshot below:
How do I extract a proxy?
- https://help.roboticautomation.pega.com/80/Automations/Automations_-_Extract_Proxy.htm
- https://collaborate.pega.com/question/robotics-studio-how-create-proxy-object
UI Automation
SendKeys method is only available on the window frame control. With chrome, you have to access the window frame through a proxy of the BrowserForm of the webpage. Refer to the screenshot below:
How do I extract a proxy?
- https://help.roboticautomation.pega.com/80/Automations/Automations_-_Extract_Proxy.htm
- https://collaborate.pega.com/question/robotics-studio-how-create-proxy-object
UI Automation
- https://docs.microsoft.com/en-us/dotnet/framework/ui-automation/ui-automation-overview
- https://docs.microsoft.com/en-us/dotnet/framework/ui-automation/invoke-a-control-using-ui-automation
UI Automation Examples with a C# Script component
- https://collaborate.pega.com/discussion/automating-ie-download-bar
- https://collaborate.pega.com/question/not-able-interrogate-google-chrome-message-pop
-
Viorel Dolhascu
![](/profiles/pega_profile/modules/pega_user_image/assets/user-icon.png)
![](/profiles/pega_profile/modules/pega_user_image/assets/user-icon.png)
EY
US
Hello Mitchell,
I am getting below error on send key step in the automation.
Do you have any suggestions for me ?
I have attached snap shop of automation below.
Message: Error executing link in Automation: Test_P_ActivateCustomer - From: Test_P_ActivateCustomer.iBrowserWindowProxy1.Proxy To: CEL_P_ActivateCustomer.iBrowserWindowProxy1.SendKeys()
The method or operation is not implemented.
Inner Exception: System.NotImplementedException: The method or operation is not implemented.
at OpenSpan.Adapters.Web.WebBase.VirtualBrowserFormTarget.SendKeys(String keys, Boolean focus)
![](https://accounts.pega.com/sites/default/files/styles/user_image/public/1689973000/3a78fee4-a7e7-4a05-b0f7-356e3689e691.png?itok=nN1zP2KU)
![](https://accounts.pega.com/sites/default/files/styles/user_image/public/1689973000/3a78fee4-a7e7-4a05-b0f7-356e3689e691.png?itok=nN1zP2KU)
Pegasystems Inc.
US
Ah, my bad... I think you actually have to call a different SendKeys method. You can do it pretty easily with a C# Script... example is below. Use the handle from the iBrowserProxy. It will be a property on the control. Then pass that handle and the keys to the method.
Ah, my bad... I think you actually have to call a different SendKeys method. You can do it pretty easily with a C# Script... example is below. Use the handle from the iBrowserProxy. It will be a property on the control. Then pass that handle and the keys to the method.
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Windows.Forms;
using System.Xml;
using System.Windows.Automation;
using System.Runtime.InteropServices;
using OpenSpan.Adapters;
using OpenSpan.Diagnostics;
using OpenSpan.Utils;
using System.Windows.Forms;
namespace Dynamic.Script_8D5FD497EEED346
{
// Script generated by Pega Robotics Studio 8.0.1100.0
// Please use caution when modifying class name, namespace or attributes
[OpenSpan.TypeManagement.DynamicTypeAttribute()]
[OpenSpan.Design.ComponentIdentityAttribute("Script-8D5FD497EEED346")]
public sealed class Script
{
//required to call the SetForegroundWindow method.
[DllImport("user32.dll")]
public static extern bool SetForegroundWindow(IntPtr hWnd);
//This method will bring the window to the foreground, then sendkeys to the window.
//Ensure that focus is already set on the control that you want to sendkeys to.
//The handle can be found as a property (or sometimes a method) on the control.
public void SendText(string text, IntPtr handle)
{
if (handle == IntPtr.Zero)
{
MessageBox.Show("invalid handle");
return;
}
//From the user32.dll - this brings the window into focus.
SetForegroundWindow(handle);
//System.Windows.Forms.SendKeys(string keys)
SendKeys.Send(text);
}
}
}
![](/profiles/pega_profile/modules/pega_user_image/assets/user-icon.png)
![](/profiles/pega_profile/modules/pega_user_image/assets/user-icon.png)
EY
US
Hello Mitchell,
Thank you for quick reply yesterday.
I have tried provided script in automation as shown below and It was throwing error as given.
Automation :
Error:
Hello Mitchell,
Thank you for quick reply yesterday.
I have tried provided script in automation as shown below and It was throwing error as given.
Automation :
Error:
@Error : I have tried new .SendWait method as well. While using .SendWait method it was not throwing any error but it was also not performing any click event as expected (No Action on screen).
Can you please share your thoughts or suggestion on it ?
![](/profiles/pega_profile/modules/pega_user_image/assets/user-icon.png)
![](/profiles/pega_profile/modules/pega_user_image/assets/user-icon.png)
EY
US
Hello,
I am still looking for the solution to fix this issue while working on chrome browser.
![](/profiles/pega_profile/modules/pega_user_image/assets/user-icon.png)
![](/profiles/pega_profile/modules/pega_user_image/assets/user-icon.png)
Pegasystems Inc.
IN
Attached a working solution. Here you need two adapters as focusing "Choose File" control need to be handled by web adapter and passing Enter key simulation need to be handled by windows adapter.
Steps to Configure both Adapters:
1. Create a Universal web adapter. In it's properties perform below changes.
- StartMethod = MonitorAll
- StartPage= https://cgi-lib.berkeley.edu/ex/fup.html
- HookChildProcesses= True
2. Create a windows adapter. In windows adapter properties perform below changes.(in "Arguments" property specify "StartPage" property that you have specified in web adapter)
- Arguments=https://cgi-lib.berkeley.edu/ex/fup.html
- Path=C:\Program Files\internet explorer\iexplore.exe
- HookChildProcesses= True
Steps to Start Interrogation:(always start universal web adapter first, then only windows adaptor)
1. Click on Start Interrogation button on Web Adapter. wait till bulls eye pops out.
2. Click on Start Interrogation button on Windows Adapter.
Note: Follow above steps in specified order.
You will be having two bulls eye windows for two adapters.
3. Interrogate "Choose File" web control with universal web adapter bulls eye.
Attached a working solution. Here you need two adapters as focusing "Choose File" control need to be handled by web adapter and passing Enter key simulation need to be handled by windows adapter.
Steps to Configure both Adapters:
1. Create a Universal web adapter. In it's properties perform below changes.
- StartMethod = MonitorAll
- StartPage= https://cgi-lib.berkeley.edu/ex/fup.html
- HookChildProcesses= True
2. Create a windows adapter. In windows adapter properties perform below changes.(in "Arguments" property specify "StartPage" property that you have specified in web adapter)
- Arguments=https://cgi-lib.berkeley.edu/ex/fup.html
- Path=C:\Program Files\internet explorer\iexplore.exe
- HookChildProcesses= True
Steps to Start Interrogation:(always start universal web adapter first, then only windows adaptor)
1. Click on Start Interrogation button on Web Adapter. wait till bulls eye pops out.
2. Click on Start Interrogation button on Windows Adapter.
Note: Follow above steps in specified order.
You will be having two bulls eye windows for two adapters.
3. Interrogate "Choose File" web control with universal web adapter bulls eye.
4. Then Interrogate Chrome frame where "Choose File" control is loaded with help of window adapter bulls eye.
Designing Automation:
1. Invoke Focus() method on "Choose File" web control, so that it is focused.
2. Then Immediately invoke Sendkeys() with {Enter} parameter on chrome frame control in which "Choose File" web page is loaded, this simulation opens the window to choose file.
- Attached project developed in 8.0.2016.0
-
Hardik Vora Song Liu Daniel Quinlog