java - Selenium Web Driver and OpenLayers 2.x: how to do a identify on a map? -
i've test web mapping application use openlayers 2.x, using selenium web driver in java , using firefox (i'm on windows 7).
i've found issue how use openlayers drawfeature selenium webdriver in java (double click issue)? doesn't solve problem.
i've have test identify function on features on map, so:
1) select identify button on toolbar (i'm able ... no problem ...)
2) click on point feature on map (i'm not able ....)
3) close dialog shows feature descriptive data (i'm not able ....)
i can't give url of application it's not public can use simple test case
http://dev.openlayers.org/releases/openlayers-2.13.1/examples/markers.html
that shows use case.
clicking on map, you'll see feature details , close dialog.
here you're code 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 new instance of firefox driver system.out.println("create new instance of firefox driver ..."); driver = new firefoxdriver(); //put implicit wait, means search elements on page take time implicit wait set before throwing exception driver.manage().timeouts().implicitlywait(10, timeunit.seconds); // advisable maximize window before performing dragndrop action system.out.println("maximize window ..."); driver.manage().window().maximize(); thread.sleep(3000l); // launch openlayers 2.x marker sample system.out.println("launch openlayers 2.x marker sample ..."); thread.sleep(3000l); driver.get("http://dev.openlayers.org/releases/openlayers-2.13.1/examples/markers.html"); // create new action instance system.out.println("create new action instance ..."); actions act = new actions(driver); // find viewport inside in witch there map system.out.println("find viewport inside in witch there map ..."); thread.sleep(3000l); webelement el = driver.findelement(by.id("openlayers_map_2_openlayers_viewport")); // start action sequence system.out.println("start action sequence ..."); thread.sleep(3000l); act.click().perform(); // identify marker system.out.println("identify marker @ 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?
edit:
i've news question (not still solution unfortunately ....).
if run code using openlayers sample
http://dev.openlayers.org/releases/openlayers-2.13.1/examples/getfeatureinfo-popup.html
you'll see works, the problem seems not coordinates.
i think problem using sample
http://dev.openlayers.org/releases/openlayers-2.13.1/examples/markers.html
the description data of features put in div can see in picture ....
how can show div after click?
any this?
thank in advance!!!
i've solved!!
here you're code works!
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.firefox.firefoxprofile; import org.openqa.selenium.firefox.internal.profilesini; import org.openqa.selenium.interactions.actions; public class identifyopenlayerstest_02 { private static webdriver driver = null; public static void main(string[] args) throws interruptedexception { //create new profile , load firefox default profile system.out.println("creo un nuovo profilo e vi carico il profilo firefox di default ..."); thread.sleep(3000l); profilesini profile = new profilesini(); firefoxprofile ffprofile = profile.getprofile("default"); // create new instance of firefox driver using new firefox profile system.out.println("creo una nuova sessione del browser firefox ..."); thread.sleep(3000l); driver = new firefoxdriver(ffprofile); //put implicit wait, means search elements on page take time implicit wait set before throwing exception driver.manage().timeouts().implicitlywait(10, timeunit.seconds); // advisable maximize window before performing dragndrop action system.out.println("maximize window ..."); driver.manage().window().maximize(); thread.sleep(3000l); // launch openlayers 2.x marker sample system.out.println("launch openlayers 2.x marker sample ..."); thread.sleep(3000l); driver.get("http://dev.openlayers.org/releases/openlayers-2.13.1/examples/markers.html"); // create new action instance system.out.println("create new action instance ..."); actions act = new actions(driver); // find viewport inside in witch there map system.out.println("find viewport inside in witch there map ..."); thread.sleep(3000l); //webelement el = driver.findelement(by.id("openlayers_map_2_openlayers_viewport")); webelement el = driver.findelement(by.classname("olalphaimg")); // start action sequence system.out.println("start action sequence ..."); thread.sleep(3000l); act.click().perform(); // perform click operation opens new window // identify marker system.out.println("identify marker @ 285, 111 ..."); thread.sleep(3000l); act.movetoelement(el, 285, 111).click().build().perform(); // print test = ok!! system.out.println("test = ok !!"); //driver.quit(); } }
in case solution you've consider markers directly on map image, components of browser page, you've refer right element.
the "core" code rows
//webelement el = driver.findelement(by.id("openlayers_map_2_openlayers_viewport")); webelement el = driver.findelement(by.classname("olalphaimg"));
the commented row wrong code row referring viewport, right code row refers object "olalphaimg".
that's all!
i hope useful others!
cesare
Comments
Post a Comment