Question

How can you access the main JavaScript scope of the browser in a functional test? For example, I want to obtain a reference to a Dojo widget and check it's attributes. In a browser JavaScript console I could for example run:

    dijit.registry.byId("widget_id")

...and get a reference to that widget. But how can I do this in the scope of a functional test? I've tried experimenting with the .eval() promise as well as just trying to access objects such as "window" in various promise callbacks but to no avail.

I'm sure there is a simple solution to this but I've not been able to find it.

Was it helpful?

Solution

OK... I have this working:

.eval("window.dijit.registry.byId('MI1').id")
    .then(function(id) {
        console.log("Checking Menu Item ID: "+ id);
        assert(id == "MI1", "The menu item did not have the expected ID");
    })

However, I've noticed that the eval only works when it is returning a String. For example, I'd also like to be able to call ".setValue()" on a widget but this doesn't seem to work. In fact anything that returns an object seems to generate an error.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top