Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to access the getUI5 function from outside the test context? #1

Open
mikezaschka opened this issue Jun 13, 2019 · 0 comments
Open

Comments

@mikezaschka
Copy link

Hi Timo,

first of all I am really impressed by the ui5TestcafeSelector and also your ui5TestAutomation chrome plugin. While searching for an E2E test framework for UI5 apps, I first came across UIVeri5, but didn't like it much due to the bewildered code base and the hard dependencies (Jasmine, etc.). Testcafé seemed a much more flexible and better approach and with your awesome work, it definitly is!
However... I came across an issue and may need your help:

I want to get some information from the browser in my test for later reuse. The following snippet actually works and gets the BindingContext information from the CustomListItem.

test('Startseite', async t => {
  // ...
  var oItem = UI5Selector({ metadata: { elementName : "sap.m.CustomListItem" }, parent: { identifier: { ui5Id : "master--list" } } }).propValue.with({ boundTestRun: t });
  var e = await oItem.getUI5(({ element }) => element.context.undefined.Address );
  console.log(e);
  // ...
}

But since I want to leverage Cucumber.js for the test definition and execution, the setup is slightly different and things break. My setup is based on the following links:

Blogpost
GitRepository

The cucumber step definition actually looks like this:

Then('the address should be created', async function () {
  var oItem = UI5Selector({ metadata: { elementName : "sap.m.CustomListItem" }, parent: { identifier: { ui5Id : "master--list" } }, context: { undefined: { Contact : "Name 1" } } }).propValue.with({ boundTestRun: testController });
  var e = await oItem.getUI5(({ element }) => element.context.undefined.Address );
  console.log(e);
  await t.expect(oItem.exists).ok();
});

The test actually breaks when accessing the getUI5 function with the following error message:

getUI5 cannot implicitly resolve the test run in context of which it should be executed. If you need to call getUI5 from the Node.js API callback, pass the test controller manually via getUI5's .with({ boundTestRun: t }) method first. Note that you cannot execute getUI5 outside the test code.

According to the official documentation it is mandatory to actually rebind the ClientFunction to the TestController using the with method (which is somehow required in the Cucumber.js step definitions). But the following code just throws an error that this is not possible:

var e = await oItem.getUI5(({ element }) => element.context.undefined.Address ).with({ boundTestRun: testController });

TypeError: oItem.getUI5(...).with is not a function

Sadly I couldn't get it to work even after fiddling around with all sorts Promises, TestController and other stuff combinations.

Do you have any idea how to solve this issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant