C# SAP GUI 自动化:DoubleClickNode 生成运行时错误
C# SAP GUI Automation: DoubleClickNode Generates Runtime Error
我正在使用 C# 以通过 sapfewse.ocx 自动化 SAP GUI 7.40
(灵感来自 How do I automate SAP GUI with c#)
当脚本必须双击树叶时,我遇到了运行时错误。
private GuiApplication sapEngine { get; set; }
private GuiConnection sapConnexion { get; set; }
private GuiSession sapSession { get; set; }
sapEngine = new GuiApplication();
sapConnexion = sapEngine.OpenConnection(sapGUIConfig.EndPoint,Sync:true);
sapSession = (GuiSession)sapConnexion.Sessions.Item(0);
// ...
GuiTree treeFilters = getTreePath("wnd[0]/usr/ssub%_SUBSCREEN_%_SUB%_CONTAINER:SAPLSSEL:2001/ssubSUBSCREEN_CONTAINER2:SAPLSSEL:2000/cntlSUB_CONTAINER/shellcont/shellcont/shell/shellcont[1]/shell");
treeFilters.ExpandNode(" 1");
treeFilters.SelectNode(" 16");
treeFilters.TopNode = " 15";
treeFilters.DoubleClickNode(" 16");
// Crash Here after DoubleClickNode Method
SAP 错误:“由于 ABAP 运行时错误,SAP 应用程序不得不终止。”
注:
使用 sapRotWrapper (SapROTWr.CSapROTWrapper) 管理的相同自动化脚本有效
sapROTWrapper = new SapROTWr.CSapROTWrapper();
sapGUIROT = _sapROTWrapper.GetROTEntry("SAPGUI");
//Get the reference to the Scripting Engine
sapEngine = sapGUIROT.GetType().InvokeMember("GetScriptingEngine", System.Reflection.BindingFlags.InvokeMethod, null, sapGUIROT, null);
sapConnexion = sapEngine.OpenConnection(sapGUIConfig.EndPoint);
sapSession = sapConnexion.Children(0);
// ...
sapSession.FindById("wnd[0]/usr/ssub%_SUBSCREEN_%_SUB%_CONTAINER:SAPLSSEL:2001/ssubSUBSCREEN_CONTAINER2:SAPLSSEL:2000/cntlSUB_CONTAINER/shellcont/shellcont/shell/shellcont[1]/shell").expandNode(" 1");
sapSession.FindById("wnd[0]/usr/ssub%_SUBSCREEN_%_SUB%_CONTAINER:SAPLSSEL:2001/ssubSUBSCREEN_CONTAINER2:SAPLSSEL:2000/cntlSUB_CONTAINER/shellcont/shellcont/shell/shellcont[1]/shell").selectNode(" 16");
sapSession.FindById("wnd[0]/usr/ssub%_SUBSCREEN_%_SUB%_CONTAINER:SAPLSSEL:2001/ssubSUBSCREEN_CONTAINER2:SAPLSSEL:2000/cntlSUB_CONTAINER/shellcont/shellcont/shell/shellcont[1]/shell").topNode = " 15";
sapSession.FindById("wnd[0]/usr/ssub%_SUBSCREEN_%_SUB%_CONTAINER:SAPLSSEL:2001/ssubSUBSCREEN_CONTAINER2:SAPLSSEL:2000/cntlSUB_CONTAINER/shellcont/shellcont/shell/shellcont[1]/shell").doubleClickNode(" 16");
有人可以帮助我吗?
注意:我在执行过程中在屏幕上遇到了同样的图形问题,所有组件都没有很好地显示,有一个 link 吗? (如问题)
自从我之前的 post 以来,经过长时间尝试不可能的解决方案,我找到了解决这个问题的方法。
它将是我提到的不同代码集的混合体。
用于管理连接和会话的对象必须用sapRotWrapper (
using SAPFEWSELib;
//...
sapROTWrapper = new SapROTWr.CSapROTWrapper();
sapGUIROT = _sapROTWrapper.GetROTEntry("SAPGUI");
//Get the reference to the Scripting Engine
sapEngine = sapGUIROT.GetType().InvokeMember("GetScriptingEngine", System.Reflection.BindingFlags.InvokeMethod, null, sapGUIROT, null);
sapConnexion = sapEngine.OpenConnection(sapGUIConfig.EndPoint);
sapSession = sapConnexion.Children(0);
但是对树的访问必须通过 GuiTree 对象完成
GuiTree treeFilters = getTreePath("wnd[0]/usr/ssub%_SUBSCREEN_%_SUB%_CONTAINER:SAPLSSEL:2001/ssubSUBSCREEN_CONTAINER2:SAPLSSEL:2000/cntlSUB_CONTAINER/shellcont/shellcont/shell/shellcont[1]/shell");
treeFilters.ExpandNode(" 1");
treeFilters.SelectNode(" 16");
treeFilters.TopNode = " 15";
treeFilters.DoubleClickNode(" 16");
我正在使用 C# 以通过 sapfewse.ocx 自动化 SAP GUI 7.40 (灵感来自 How do I automate SAP GUI with c#)
当脚本必须双击树叶时,我遇到了运行时错误。
private GuiApplication sapEngine { get; set; }
private GuiConnection sapConnexion { get; set; }
private GuiSession sapSession { get; set; }
sapEngine = new GuiApplication();
sapConnexion = sapEngine.OpenConnection(sapGUIConfig.EndPoint,Sync:true);
sapSession = (GuiSession)sapConnexion.Sessions.Item(0);
// ...
GuiTree treeFilters = getTreePath("wnd[0]/usr/ssub%_SUBSCREEN_%_SUB%_CONTAINER:SAPLSSEL:2001/ssubSUBSCREEN_CONTAINER2:SAPLSSEL:2000/cntlSUB_CONTAINER/shellcont/shellcont/shell/shellcont[1]/shell");
treeFilters.ExpandNode(" 1");
treeFilters.SelectNode(" 16");
treeFilters.TopNode = " 15";
treeFilters.DoubleClickNode(" 16");
// Crash Here after DoubleClickNode Method
SAP 错误:“由于 ABAP 运行时错误,SAP 应用程序不得不终止。”
注:
使用 sapRotWrapper (SapROTWr.CSapROTWrapper) 管理的相同自动化脚本有效
sapROTWrapper = new SapROTWr.CSapROTWrapper();
sapGUIROT = _sapROTWrapper.GetROTEntry("SAPGUI");
//Get the reference to the Scripting Engine
sapEngine = sapGUIROT.GetType().InvokeMember("GetScriptingEngine", System.Reflection.BindingFlags.InvokeMethod, null, sapGUIROT, null);
sapConnexion = sapEngine.OpenConnection(sapGUIConfig.EndPoint);
sapSession = sapConnexion.Children(0);
// ...
sapSession.FindById("wnd[0]/usr/ssub%_SUBSCREEN_%_SUB%_CONTAINER:SAPLSSEL:2001/ssubSUBSCREEN_CONTAINER2:SAPLSSEL:2000/cntlSUB_CONTAINER/shellcont/shellcont/shell/shellcont[1]/shell").expandNode(" 1");
sapSession.FindById("wnd[0]/usr/ssub%_SUBSCREEN_%_SUB%_CONTAINER:SAPLSSEL:2001/ssubSUBSCREEN_CONTAINER2:SAPLSSEL:2000/cntlSUB_CONTAINER/shellcont/shellcont/shell/shellcont[1]/shell").selectNode(" 16");
sapSession.FindById("wnd[0]/usr/ssub%_SUBSCREEN_%_SUB%_CONTAINER:SAPLSSEL:2001/ssubSUBSCREEN_CONTAINER2:SAPLSSEL:2000/cntlSUB_CONTAINER/shellcont/shellcont/shell/shellcont[1]/shell").topNode = " 15";
sapSession.FindById("wnd[0]/usr/ssub%_SUBSCREEN_%_SUB%_CONTAINER:SAPLSSEL:2001/ssubSUBSCREEN_CONTAINER2:SAPLSSEL:2000/cntlSUB_CONTAINER/shellcont/shellcont/shell/shellcont[1]/shell").doubleClickNode(" 16");
有人可以帮助我吗?
注意:我在执行过程中在屏幕上遇到了同样的图形问题,所有组件都没有很好地显示,有一个 link 吗? (如问题
自从我之前的 post 以来,经过长时间尝试不可能的解决方案,我找到了解决这个问题的方法。
它将是我提到的不同代码集的混合体。
用于管理连接和会话的对象必须用sapRotWrapper (
using SAPFEWSELib;
//...
sapROTWrapper = new SapROTWr.CSapROTWrapper();
sapGUIROT = _sapROTWrapper.GetROTEntry("SAPGUI");
//Get the reference to the Scripting Engine
sapEngine = sapGUIROT.GetType().InvokeMember("GetScriptingEngine", System.Reflection.BindingFlags.InvokeMethod, null, sapGUIROT, null);
sapConnexion = sapEngine.OpenConnection(sapGUIConfig.EndPoint);
sapSession = sapConnexion.Children(0);
但是对树的访问必须通过 GuiTree 对象完成
GuiTree treeFilters = getTreePath("wnd[0]/usr/ssub%_SUBSCREEN_%_SUB%_CONTAINER:SAPLSSEL:2001/ssubSUBSCREEN_CONTAINER2:SAPLSSEL:2000/cntlSUB_CONTAINER/shellcont/shellcont/shell/shellcont[1]/shell");
treeFilters.ExpandNode(" 1");
treeFilters.SelectNode(" 16");
treeFilters.TopNode = " 15";
treeFilters.DoubleClickNode(" 16");