-1

使用UIVeri5SAP UI5应用程序编写测试时:如何以编程方式将一些文本输入到sap.m.Input类型的元素中?我尝试了如下方法:inputKeys

it("should enter some text", function() {

    let inputElement = element(by.control({
        viewName   : "com.example.myapp.View.main",
        controlType: "sap.m.Input"
    }));
    expect( inputElement ).toBeDefined(); // is okay

    inputElement.sendKeys("Some Text"); // fails!

    // ...
});

找到了元素,但语句inputElement.sendKeys("Some Text")失败并出现以下错误:

 Control Element sap.m.Input#__xmlview0--myInput has no dom representation

我在 Protractor 的ElementFinder中找不到任何其他似乎适合实现此目的的方法。

4

2 回答 2

2

发现当添加interaction: "focus"到选择器时它可以工作:

let inputElement = element(by.control({
    viewName   : "com.example.myapp.View.main",
    controlType: "sap.m.Input",
    interaction: "focus" // this is new!
}));

inputElement.sendKeys("Some Text"); // works

另请参阅UIVeri5 文档中的“交互适配器”部分。

于 2019-08-21T06:53:29.127 回答
-1

我为我的问题找到了一种解决方法,即使用 Protractor 方法通过其生成的 IDby.id()引用sap.m.Input元素:

let inputElement = element( by.id("__xmlview0--myInput-inner") ); 

inputElement.sendKeys("Some Text"); // now it works

但是,我认为这是解决方法而不是解决方案,因为UIVeri5 的文档说“避免使用生成的 ID 的 ID 定位器”。

于 2019-08-19T10:32:20.300 回答