SAPUI5 OPA5 TypeError: sap.ui.test.matchers.Properties 不是构造函



我在 SAPUI5 应用程序的 OPA 测试中遇到问题。

我正在尝试对 SAPUI5 视图执行 OPA 测试,我在视图中创建了一个下拉列表,并为相应的视图编写了 OPA 脚本。

当我运行 OPA Sctipt 时,我编写的脚本无法在下拉列表中选择"项目",并且我收到一个错误说.. TypeError: sap.ui.test.matchers.Properties 不是构造函数

我不明白为什么应用程序不获取 sap.ui.test.matchers.Properties 类

以下是该问题的代码。

翻译.视图.xml

<Select id="toolsDocType" width="100%" change="onToolsDocChange" forceSelection="true">
<items>
<core:Item text="--Select1--" key="X" enabled="false"/>
<core:Item text="Link" key="Link"/>
<core:Item text="Atatchment" key="attachment"/>
</items>
</Select>

js 文件

此函数将开始执行测试脚本"fillAttachment(("函数

opaTest("Select Attachment", function (Given, When, Then) {
// Arrangements
//Given.iStartMyApp();
//Actions
When.onTheTranslationPage.fillAttachment();
// Assertions
Then.onTheTranslationPage.CustNameShouldGetFilled();
});

运行上面的代码后,下面的函数将开始执行。

fillAttachment : function () {
return this.waitFor({
id:"toolsDocType",
actions: new Press(),
success: function(oSelect) {
this.waitFor({
controlType: "sap.ui.core.Item",
matchers: [
new sap.ui.test.matchers.Ancestor(oSelect),
new sap.ui.test.matchers.Properties({ key: "link"})
],
actions: new Press(),
success: function() {
Opa5.assert.strictEqual(oSelect.getSelectedKey(), "Link", "Selected link");
},
errorMessage: "Cannot select link from mySelect"
});
},
errorMessage: "There was no Input"
});
},

我看到以下错误.. 没有输入 测试代码引发的异常:"类型错误:sap.ui.test.matchers.Properties 不是构造函数 TypeError: sap.ui.test.matchers.Properties 不是构造函数 在F.成功(https://webidetesting4022059-w3446edba.dispatcher.int.sap.hana.ondemand.com/webapp/test/integration/pages/Translation.js?eval:240:10( 在F.R.成功(https://webidetesting4022059-w3446edba.dispatcher.int.sap.hana.ondemand.com/resources/sap/ui/test/Opa5.js?eval:6:2978(

你能帮我修复这个错误吗? 提前谢谢你。

您需要在sap.ui.require中定义路径才能加载 JS 文件。请阅读此处的示例。

sap.ui.require([
"sap/ui/test/opaQUnit",
"sap/ui/test/actions/Press",
"sap/ui/test/matchers/Properties",
"sap/ui/test/matchers/Ancestor"
],  function (opaTest, Press, Properties, Ancestor) {
//Your code here
});

另一件事是您应该为Item提供正确的值。

匹配器:[ new sap.ui.test.matchers.Ancestor(oSelect(, new sap.ui.test.matchers.Properties({ key: ">Link"}( ],

我已经尝试过,它应该可以解决您的问题。

相关内容

最新更新