Show TOC

Pitfalls and TroubleshootingLocate this document in the navigation structure

Tips and tricks if OPA is not behaving or reacting the way you expect it to.

Why can't OPA find the control I'm looking for?

OPA checks a lot of conditions before it passes a control to your matchers/actions/success functions. If your control does not match these conditions, you will never be able to set a breakpoint. For such instances, OPA logs a lot of information into the browser's console, if you turn on the SAPUI5 debug mode. You can either use the sap-ui-debug=true URL parameter or the SAPUI5 Diagnostics Window. The diagnostics may also be helpful to see the state of your UI.

After turning on the debug mode, you can have a look at the log and also filter it by looking for opa or matchers.

A frequent cause of error are typos in the view name or control IDs. These are easily found by looking through the logs.

Sometimes my test fails, sometimes it doesn't

Is it the startup that's failing?

Maybe the app is loading too slowly for the OPA tests. If there's a local index file that does not contain the library dependencies your application needs, the SAPUI5 bootstrap is very slow. To fix this, add the dependencies you need in your application descriptor's sap.ui.dependencies namespace. If you do not have a descriptor, use the bootstrap option libs. For more information, see Descriptor for Applications, Components, and Libraries and Configuration Options respectively.

It's failing during the execution

If this happens, your test is probably executing actions faster than it should. If you encounter a failure, look at the current state of the UI - in almost all cases an action could not be triggered or a JavaScript error occurred. This error should be included in the console logs. If an action could not be executed, please make sure you use the action parameter of OPA5's waitFor function. When using the success function for triggering actions, OPA5 does not check a lot of things.

Here are some examples that have occurred in known applications:

  • An application was using the bindingContext of a control in a press handler. OPA5 was way faster than a human user, so the HTTP-Request that was sometimes finished by the time OPA5 was executing the check, was sometimes still pending and so an exception was thrown. The test failed because OPA was trying to reach a page that could not be shown because of this error. This had to be fixed in the application coding.

  • When there was no action parameter available, a ListItem got rerendered while a press action was executed on it. Due to the rerendering, the List was not able to perform the click, meaning it was not executed and the test failed. This only happened on certain occasions, depending on the execution speed of the machine executing the test. This is now detected automatically when using actions.

OPA5 is failing on a specific browser: what should i do?

Am i comparing language-dependent texts and the browser has a different language?

Check the logs to see if your matcher is failing because it's checking a text against a different language. If you want to always execute your tests with the same language, use the sap-ui-language= URL or bootstrap parameter.

It is only Internet Explorer that's affected?

If you are using an IFrame to launch your application, Internet Explorer is more strict when it comes to objects from removed IFrames. If you are using the OPA context to remember objects, then destroy your frame and then execute a function on the object, you will get a JavaScript exception. How do you avoid it? By only remembering values like strings or integers when destroying the frame, or by using the component startup in OPA5.

OPA is not even starting and there's no logging either

If you require sinon-qunit.js, it overwrites the browser functions setTimeout and setInterval. OPA needs these functions and without them, the tests will not start. You can either set the fakeTimers to false in your test setup, or maybe consider not using sinon together with OPA.

module("Opatests", {
    beforeEach : function () {
        sinon.config.useFakeTimers = false;
    },
    afterEach : function () {
        sinon.config.useFakeTimers = true;
    }
});