RE: Selenium Web Driver and OpenLayers 2.x – (Request number 2): How to do an identify on a map?

Hi all,

this a new question on this stuff. The previous one on a simpler use case, is this one and the response  that Virender Singh  (thanks a lot!) gave me it’s working in that case.

My new request is about the same functionality  but in a more complex web application, and with features on the map that are not markers, but in this case the map is buil completely server side so I need to give to OpenLayers the coordinates of my click on the viewport, then will be the OpenLayers javascript libraries that knows how to manage this coordinates.

Here you’re my java code that, at the moment, doesn’t work

package myTestProjects;

import java.util.concurrent.TimeUnit;

import org.openqa.selenium.By;
import org.openqa.selenium.Keys;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.firefox.FirefoxProfile;
import org.openqa.selenium.firefox.internal.ProfilesIni;
import org.openqa.selenium.interactions.Actions;

public class aeraTest_04 {

private static WebDriver driver = null;

public static void main(String[] args) throws InterruptedException {
// TODO Auto-generated method stub
//Create a new profile and load my Firefox Test profile
System.out.println(“Creo un nuovo profilo e vi carico il profilo Firefox di test con DEMO 27 …”);
ProfilesIni profile = new ProfilesIni();
FirefoxProfile ffProfile = profile.getProfile(“default”);

// Create a new instance of the Firefox driver using my Firefox Test profile
System.out.println(“Creo una nuova sessione del browser Firefox …”);
driver = new FirefoxDriver(ffProfile);

//Put a Implicit wait, this means that any search for elements on the page could take the time the implicit wait is set for before throwing exception
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);

// It is always advisable to Maximize the window before performing DragNDrop action
System.out.println(“Massimizzo la finestra del browser …”);

//Launch the “Sistema Piemonte” Home Page
System.out.println(“Mi collego a AERA Piemonte …”);

// Close the modal browser window to select layers
System.out.println(“Chiudo la finestra modale di selezione layers …”);

// Change the basemap setting OpenLayers as basemap
System.out.println(“Modifico la mappa di sfondo impostano OpenLayers (RadioButton) …”);
WebElement baseRadioButton = driver.findElement(By.xpath(“/html/body/div[1]/div/div[1]/div[2]/div[2]/div/div/div/div/div/div/div/div/div/div/div[2]/div/div/div[1]/div[2]/div[2]/div/div/div/ul/div/li[3]/ul/li[3]/div/input”));;

// Create a new Action instance
System.out.println(“Creo un oggetto di tipo \”Action\” …”);
Actions act = new Actions(driver);

// Find the viewport inside in witch there is the map
System.out.println(“Individuo il viewport al cui interno c’è la mappa …”);
WebElement el = driver.findElement(By.xpath(“/html/body/div[1]/div/div[1]/div[2]/div[2]/div/div/div/div/div/div/div/div/div/div/div[1]/div/div[2]/div/div/div[2]/div[3]”));

// Click on the identify button
System.out.println(“Seleziono il bottone dell’identify …”);

// Perform the click operation that opens new window
System.out.println(“Identify marker at 730, 504 …”);
act.moveToElement(el, 730, 504).click().build().perform();

// Print TEST = OK!!
System.out.println(“TEST = OK !!”);



You can execute this code because my application is public on the web.

To execute manually:

1) close the first modal dialog that appears when the web application starts
2) in the toolbar over the map, click on the blue button with an “i”
3) click on the map where there are points

You’ll see a pop-up appears with some information inside.

This is what I’d like to wee after my click on the map in my java test code.

Thank you very much in advance!!


cesare Train Asked on June 30, 2015 in Selenium WebDriver.
Add Comment
3 Answers

Hi Cesare,

Do keep me informed as I am really interested in understanding the GeoExplorer API’s. If you get any developer documentation, that will be great and do let me know.



Professor Answered on July 1, 2015.
Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.