I've to test a web mapping application that use OpenLayers 2.x, using Selenium Web Driver in Java and using Firefox (I'm on Windows 7).
I've found only this issue https://stackoverflow.com/questions/28682195/how-to-use-openlayers-drawfeature-with-selenium-webdriver-in-java-double-click that doesn't solve my problem.
I've have to test the identify function on features on the map, so:
1) select the identify button on my toolbar (I'm able to do this ... so no problem ...)
2) click on a point feature on the map (I'm not able to do this ....)
3) close the dialog that shows the felatire descriptive data (I'm not able to do this ....)
I can't give the url of my application that it's not public but I can use this simple test case
http://dev.openlayers.org/releases/OpenLayers-2.13.1/examples/markers.html
that shows my use case.
Clicking on the map, you'll see the feature details and then close the dialog.
Here you're my code that doesn't work
package myTestProjects;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.interactions.Actions;
public class identifyOpenLayersTest_02 {
private static WebDriver driver = null;
public static void main(String[] args) throws InterruptedException {
// Create a new instance of the Firefox driver
System.out.println("Create a new instance of the Firefox driver ...");
driver = new FirefoxDriver();
//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("Maximize the window ...");
driver.manage().window().maximize();
Thread.sleep(3000L);
// Launch the OpenLayers 2.x marker sample
System.out.println("Launch the OpenLayers 2.x marker sample ...");
Thread.sleep(3000L);
driver.get("http://dev.openlayers.org/releases/OpenLayers-2.13.1/examples/markers.html");
// Create a new Action instance
System.out.println("Create a new Action instance ...");
Actions act = new Actions(driver);
// Find the viewport inside in witch there is the map
System.out.println("Find the viewport inside in witch there is the map ...");
Thread.sleep(3000L);
WebElement el = driver.findElement(By.id("OpenLayers_Map_2_OpenLayers_ViewPort"));
// Start the action sequence
System.out.println("Start the action sequence ...");
Thread.sleep(3000L);
act.click().perform();
// Identify marker
System.out.println("Identify marker at 285, 111 ...");
Thread.sleep(3000L);
act.moveToElement(el, 285, 111).click().build().perform();
// Print TEST = OK!!
System.out.println("TEST = OK !!");
//driver.quit();
}
}
Suggestions? Samples?