SAPGuiTree:TreeView 激活项目问题
SAPGuiTree : TreeView Activate item issue
我正在使用 SAPGuiTree 并希望通过参数传递值来激活项目。如果有人知道这件事,请帮助我,这是我的代码
代码:
SAPGuiSession("guicomponenttype:=12").SAPGuiWindow("guicomponenttype:=21").SAPGuiTree("treetype:=SapColumnTree","index:=0").ActivateItem "Inbound Monitor;03.05.2016;9395;Sales Movement","Sales Movement"
这里的粗体字母是数据而不是硬编码我想从数据表中提供输入。
日期= 03.05.2016
日期=参数("DATE")
这是我使用参数而不是数据的代码,但出现错误 "Cannot identify the required object"
SAPGuiSession("guicomponenttype:=12").SAPGuiWindow("guicomponenttype:=21").SAPGuiTree("treetype:=SapColumnTree","index:=0").ActivateItem "Inbound Monitor;date;9395;Sales Movement","Sales Movement"
我得到了答案。
SAPGuiSession("guicomponenttype:=12").SAPGuiWindow("guicomponenttype:=21").SAPGuiTree("treetype:=SapColumnTree","index:=0").ActivateItem "Inbound Monitor;"&date&";"9359" ;销售变动","Sales Movement"
所以,您使用的是 .ActivateItem 方法,它有两个参数:Path 和 Item。 Path 需要是包含以分号分隔的项目的字符串,Item 是包含要激活的 SAP 项目的文本的字符串。
您收到的错误可能是由于您的 Path 参数无法匹配控件 SAPGuiTree("treetype:=SapColumnTree","index:=0") 中的项目引起的。但是,我认为很明显您已经理解了这一点。您似乎不了解如何构建 Path 所需的字符串,所以让我们继续努力。
我假设 "Inbound Monitor;03.05.2016;9395;Sales Movement" 有效。因此,您需要从数据表中构建它。由于它是一个字符串,我们使用连接来构建它。在 QTP 使用的 VBScript 中,这是通过 & 运算符完成的。
好的,让我们建立概念。
您有一个包含名为 DATE 的列的数据表,以及一个字段值为“03.05.2016”的记录
'set a variable called date to the value of the datatable field "DATE" mentioned above
date = DataTable("DATE")
'concatenate strings together into a variable called Path
Path = "Inbound Monitor;" & date & ";9395;Sales Movement"
'the other parameter
Item = "Sales Movement"
SAPGuiSession("guicomponenttype:=12").SAPGuiWindow("guicomponenttype:=21").SAPGuiTree("treetype:=SapColumnTree","index:=0").ActivateItem Path, Item
这应该有效。但是...我尽量不在QTP中使用变量,所以...
SAPGuiSession("guicomponenttype:=12").SAPGuiWindow("guicomponenttype:=21").SAPGuiTree("treetype:=SapColumnTree","index:=0").ActivateItem "Inbound Monitor;" & DataTable("DATE") & ";9395;Sales Movement", "Sales Movement"
我正在使用 SAPGuiTree 并希望通过参数传递值来激活项目。如果有人知道这件事,请帮助我,这是我的代码
代码:
SAPGuiSession("guicomponenttype:=12").SAPGuiWindow("guicomponenttype:=21").SAPGuiTree("treetype:=SapColumnTree","index:=0").ActivateItem "Inbound Monitor;03.05.2016;9395;Sales Movement","Sales Movement"
这里的粗体字母是数据而不是硬编码我想从数据表中提供输入。
日期= 03.05.2016 日期=参数("DATE")
这是我使用参数而不是数据的代码,但出现错误 "Cannot identify the required object"
SAPGuiSession("guicomponenttype:=12").SAPGuiWindow("guicomponenttype:=21").SAPGuiTree("treetype:=SapColumnTree","index:=0").ActivateItem "Inbound Monitor;date;9395;Sales Movement","Sales Movement"
我得到了答案。
SAPGuiSession("guicomponenttype:=12").SAPGuiWindow("guicomponenttype:=21").SAPGuiTree("treetype:=SapColumnTree","index:=0").ActivateItem "Inbound Monitor;"&date&";"9359" ;销售变动","Sales Movement"
所以,您使用的是 .ActivateItem 方法,它有两个参数:Path 和 Item。 Path 需要是包含以分号分隔的项目的字符串,Item 是包含要激活的 SAP 项目的文本的字符串。
您收到的错误可能是由于您的 Path 参数无法匹配控件 SAPGuiTree("treetype:=SapColumnTree","index:=0") 中的项目引起的。但是,我认为很明显您已经理解了这一点。您似乎不了解如何构建 Path 所需的字符串,所以让我们继续努力。
我假设 "Inbound Monitor;03.05.2016;9395;Sales Movement" 有效。因此,您需要从数据表中构建它。由于它是一个字符串,我们使用连接来构建它。在 QTP 使用的 VBScript 中,这是通过 & 运算符完成的。
好的,让我们建立概念。
您有一个包含名为 DATE 的列的数据表,以及一个字段值为“03.05.2016”的记录
'set a variable called date to the value of the datatable field "DATE" mentioned above
date = DataTable("DATE")
'concatenate strings together into a variable called Path
Path = "Inbound Monitor;" & date & ";9395;Sales Movement"
'the other parameter
Item = "Sales Movement"
SAPGuiSession("guicomponenttype:=12").SAPGuiWindow("guicomponenttype:=21").SAPGuiTree("treetype:=SapColumnTree","index:=0").ActivateItem Path, Item
这应该有效。但是...我尽量不在QTP中使用变量,所以...
SAPGuiSession("guicomponenttype:=12").SAPGuiWindow("guicomponenttype:=21").SAPGuiTree("treetype:=SapColumnTree","index:=0").ActivateItem "Inbound Monitor;" & DataTable("DATE") & ";9395;Sales Movement", "Sales Movement"