I’m searching for a solution how to test Openlayers (a JS Libary for visualisation of geographic data) with Katalon Studio.
I have got some Javascript code from a developer, but I don’t know how to use it with Katalon.
// get OpenLayers map
var map = Ext.ComponentQuery.query("pp-map")[0].map;
// get Layer "modifyLocation"
var layer = map.getLayersBy("layerId", "Geometry.modifyLocation")[0];
// get the correct feature to edit
var feature;
var features = layer.features;
for (var i = 0; i<features.length; i++){
if(features[i].geometry.components && !features[i].geometry.parent){
feature = features[i];
}
}
Can someone give me a hint?
Thanks
Hello,
you can execute Javascript directly from Katalon.
String myJs = '''var map = Ext.ComponentQuery.query("pp-map")[0].map;
// get Layer "modifyLocation"
var layer = map.getLayersBy("layerId", "Geometry.modifyLocation")[0];
// get the correct feature to edit
var feature;
var features = layer.features;
for (var i = 0; i<features.length; i++){
if(features[i].geometry.components && !features[i].geometry.parent){
feature = features[i];
}
}'''
WebUI.executeJavaScript(myJs, null)
Thanks for your quick reply.
But when I execute the command I got the error
Unable to execute JavaScript.
Are the line breaks the problem?
No, Groovy supports multi line Strings enclosed in triple-single-quotes.
Can you share full exception?
oh, I found the “error”. I have to add a delay before I execute the js-code.
Now it works, thanks.