0

I'm trying to automate a SAP task in which a HTMLViewercontrol is used to disply some data and update if required.

The HTMLViewercontrol looks like below after loading.

HTMLViewer control

I tried to record the loading of the page but sadly, don't get any event in it.

After scratching my head for hours I tried to record the script while editing values and got below script.

session.findById("wnd[0]/usr/cntlMAIN_CONTAINER/shellcont/shell/shellcont[1]/shell/shellcont[1]/shell/shellcont[1]/shell/shellcont[1]/shell").sapEvent "","COMMAND=NEW&ELEMENT=INP_I_5_I_=123456789&INP_I_6_I_=1.000&INP_I_7_I_=&INP_I_8_I_=16.99&INP_I_9_I_=16.99&INP_I_10_I_=5.50&INP_I_11_I_=","sapevent:A1F1"
session.findById("wnd[0]/usr/cntlMAIN_CONTAINER/shellcont/shell/shellcont[1]/shell/shellcont[1]/shell/shellcont[1]/shell/shellcont[1]/shell").sapEvent "","COMMAND=ENT&ELEMENT=INP_I_5_I_=123456789&INP_I_6_I_=1.000&INP_I_7_I_=&INP_I_8_I_=16.99&INP_I_9_I_=16.99&INP_I_10_I_=5.50&INP_I_11_I_=","sapevent:A1F1"

I'm not getting how can I read sapevent value before editing.

Can any one please share their expertise in this.

Sandra Rossi
  • 11,934
  • 5
  • 22
  • 48
Ashok
  • 1,868
  • 6
  • 36
  • 70

1 Answers1

1

I managed to edit data on SAP HTMLViewer by below code:

//Record the script.
//Assign `RecordFile` name as your choice
_session.RecordFile = @"SalesScript.vbs";
//Start recording
_session.Record = true;
//Get session window handle
var handle = _session.ActiveWindow.Handle;
//Set the handle as foreground.
if (SetForegroundWindow(handle))
{
 //Send Enter key
 SendKeys.SendWait("{ENTER}");                                      
 Thread.Sleep(1000);
}
//Get the recording file path to open and get the required fields from it.
var scriptPath = _session.RecordFile;
//Stop the recording.
_session.Record = false;
//You will get the recording script file. You can get the file contains by opening it with `StreamReader`


//Method to set SAP screen foreground.
[DllImport("user32.dll")]
    public static extern bool SetForegroundWindow(
        int hWnd // handle to window
        );
Ashok
  • 1,868
  • 6
  • 36
  • 70