FYI, I was able to investigate the issue and pinpoint a probable cause. It seems that when selenium performs a 'click' event it actually sends twice a mouseDown/mouseUp event sequence. The first one has the correct location on the map: a couple of positive > 0 coordinates (say x=200,y=210) The second one instead has totally bogus coordinates, negative coordinates (say x=-20,y=-70)
Tha last event is registered as the last position at which a mouseDown occurred and therefore when the click handler evaluates this condition ( https://github.com/openlayers/openlayers/blob/master/lib/OpenLayers/Handler/Click.js#L403) it returns false and the event is discarded, together with the first one (which had correct coordinates). As a POC I have hacked a local copy of OL and changed the mouseDown event handler as follows: /** * Method: mousedown * Handle mousedown. * * Returns: * {Boolean} Continue propagating this event. */ mousedown: function(evt) { console.log('mousedown'); if(evt.xy && (evt.xy.x <= 0.0 && evt.xy.y <= 0.0)) { return true; } this.down = this.getEventInfo(evt); this.last = this.getEventInfo(evt); console.log('mousedown '+this.down.xy); console.log(evt); return true; }, You can see the original code at: https://github.com/openlayers/openlayers/blob/master/lib/OpenLayers/Handler/Click.js#L220 Note the logging statements and the check for <=0 coordinates. Events with x,y both <=0 are discarded. With these modifications I was able to successfully trigger the getfeatureinfo control from selenium. While using the map myself I did not find any negative side effect. This looks pretty much like a Selenium issue to me, and I am going to report it to them, but I just wanted to share the findings with you in the hope that someone's light bulb turns itself on ;-) Umberto On Mon, Nov 12, 2012 at 5:32 PM, Umberto Nicoletti < [email protected]> wrote: > Hi all, > I need (actually it's more want) to test an application that uses > OpenLayers internally with selenium IDE (http://seleniumhq.org/). > > Unfortunately it seems I can't find the right event combination to > reproduce a 'click' on the map which then triggers a getfeatureinfo request. > > I have already tried all possible permutations of > mouseDownAt/mouseUpAt/click events, then played with timings and playback > speed but without success. > > Interestingly enough if I try to record events with Selenium IDE nothing > is recorded when I pan/click on the map. > > STFW did not help either: Openlayers and Selenium are mentioned only once, > and with similar, unresolved issues as the ones I am seeing. > > So here I am asking the great OL community: has anyone, ever got > OpenLayers to work, and how, with Selenium or any other in browser > automated testing tool? > > Thanks in advance, > Umberto >
_______________________________________________ Users mailing list [email protected] http://lists.osgeo.org/mailman/listinfo/openlayers-users
