ui5-community / wdi5

official UI5 end-to-end test framework for UI5 web-apps. wdi5 = Webdriver.IO + UI5 Test API
https://ui5-community.github.io/wdi5/
Apache License 2.0
102 stars 43 forks source link

object is not iterable #325

Closed marco-paciucci closed 2 years ago

marco-paciucci commented 2 years ago

Hello, I've coded this test here:

        const listSelector = { 
             selector: {
                    controlType: "sap.m.List",
                    viewName: "sap.ui.demo.todo.view.App" 
             }
        }

        const checkedItems = await browser.asControl(listSelector).getItems();
        const checked = 0
        for (const item of checkedItems) {
          if (await item.getChecked()) { checked++ }
        }
        expect(checked).toBe(2);

But I'm getting: checkedItems is not iterable The list is displayed on the screen and I don't know why I am getting that error. I have added await browser.debug(); which stops the execution but in the console I cannot type await browser.asControl(listSelector).getItems(); because the console is not attached to the current flow of execution and I don't know if it's ever possible to debug and to what extent (I don't want to debug the original javascript file but the spec js).

vobu commented 2 years ago

debuggin a wdi5 test is pretty easy as it adheres to Node.js debugger/--inspect setting. E.g. in VS Code, start a "JavaScript Debug Terminal"... image ...and run wdi5 from there, e.g. via npm run wdi5 (or whatever npm script you've chosen). Then add breakpoints in the test source... image ...and wdi5 will halt execution at that point. (Reminds me: we'll still need a recipe for debugging, will put it in the issues list.) Then you can look at checkedItems in the debugger and examine why it's not iterable.

marco-paciucci commented 2 years ago

Hello, thank you very much for giving the recipe to debug. I don't know why but it seems that the list of items is empty even though in the last image you can see that it's not. What could the issue be? image image

vobu commented 2 years ago

i guess you're missing interaction: "root" on the selector - see #319

selector: {
  controlType: "...",
  // other props here
  interaction: "root"
}
marco-paciucci commented 2 years ago

Thank you very much, that did the trick. One more question. If I need to add some text to sap.m.input and fire the change event, how can this be done? Do I need to raise a separate issue?

image

image

The statement I've added doesn't raise the change event. How can this be done in wdi5?

marco-paciucci commented 2 years ago

Hello, I've managed to find a solution: await oControl.enterText("Restart the server"); I think that you should enhance the "Recipe" sections with more examples. Thanks .

vobu commented 2 years ago

I've managed to find a solution: await oControl.enterText("Restart the server"); I think that you should enhance the "Recipe" sections with more examples.

given how easy it is to contribute to the documentation, would you mind giving this a shot? as you stated, many would benefit from that. thanks in advance!

github-actions[bot] commented 2 years ago

hey 👋 - silence for 30 days 🤐 ... anybody? 😀

github-actions[bot] commented 2 years ago

closed 📴 because silencio 🤫 since an additional 14 days after staleness 📠