我们正在使用Python pywin32 com库编写在Windows上运行的SAP GUI应用程序的脚本
事情一直到昨天都在进行
现在,在尝试访问下面执行maximize()
的代码行时,我们得到
com_error: (-2147417851, 'The server threw an exception.', None, None)
以及在尝试访问SAP窗口中的任何对象(代码中的最后一行)时出现以下错误
AttributeError: Property '.text' cannot be set.
有人能帮忙吗?如果需要更多信息,请告诉我
下面是我们用于获取新脚本会话、启动SAP和执行操作的代码片段:
from subprocess import call
import win32com.client
import time
GUIPath = 'C:/Program Files (x86)/SAP/FrontEnd/SAPgui/'
WinTitle = 'SAP'
SID = 'xxxxxx.sap.xxxxx.com'
InstanceNo = 'xx'
shell = win32com.client.Dispatch("WScript.Shell")
cmdString = os.path.join(GUIPath, 'SAPgui.exe') + " " + SID + " " + InstanceNo
call(cmdString)
while not shell.AppActivate(WinTitle):
time.sleep(1)
checkGUIExists = False
while not checkGUIExists:
try:
SAP = win32com.client.GetObject("SAPGUI").GetScriptingEngine
session = SAP.FindById("/app/con[0]/ses[0]") # session
checkGUIExists = True
except:
time.sleep(1)
continue
//The lines failing//
session.findById("wnd[0]").maximize()
session.findById("wnd[0]/tbar[0]/okcd).text = <transaction>
目前没有回答
相关问题 更多 >
编程相关推荐