【发布时间】:2015-09-11 18:16:57
【问题描述】:
我要测试一个使用 OpenLayers 2.x、使用 Java 中的 Selenium Web 驱动程序和 Firefox(我在 Windows 7 上)的网络地图应用程序。
我发现只有这个问题How to use OpenLayers DrawFeature with Selenium WebDriver in Java (double click issue)? 不能解决我的问题。
我必须在地图上的特征上测试识别功能,所以:
1) 选择我工具栏上的识别按钮(我可以这样做...所以没问题...)
2) 点击地图上的一个点特征(我不能这样做....)
3) 关闭显示特征描述数据的对话框(我不能这样做......)
我不能提供我的应用程序的 url,它不是公开的,但我可以使用这个简单的测试用例
http://dev.openlayers.org/releases/OpenLayers-2.13.1/examples/markers.html
这显示了我的用例。
单击地图,您将看到功能详细信息,然后关闭对话框。
这里你是我的代码不起作用
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();
}
}
建议?样品?
编辑:
我有一些关于这个问题的消息(不幸的是仍然不是解决方案......)。
如果你使用这个 OpenLayers 示例运行我的代码
http://dev.openlayers.org/releases/OpenLayers-2.13.1/examples/getfeatureinfo-popup.html
你会看到它有效,所以问题似乎与坐标无关。
我认为问题在于使用此示例
http://dev.openlayers.org/releases/OpenLayers-2.13.1/examples/markers.html
特征的描述数据放在一个DIV中,如图所示......
点击后如何显示此 DIV?
对此有何帮助?
提前非常感谢您!!!
【问题讨论】:
标签: java selenium selenium-webdriver openlayers