如何从Openlayers的中心查找多边形的偏移值

时间:2018-08-01 12:36:18

标签: java selenium selenium-webdriver openlayers vaadin8

i计算了(x1,Y1)和(x2,Y2)并计算了它们之间的差异(蓝线),并将这些像素值提供给驱动程序单击,但我无法单击多边形(点)。 1.首先,鼠标将根据窗口移至地图的中心,其中(x1,y1)=(960,520),但驱动程序会将这些值视为(0,0)。 2.现在,我需要计算从中心到地图上每个多边形的偏移值。(x1,y1)=(960,520)和(x2,y2)=(1000,232)

  

(x1,y1)和(x2,y2)之差将给我   点到中心的距离。例如:(x3,y3)

enter image description here

下面的代码

try {
            driver.get("http://localhost:8090/demo/");
            System.out.println("demo opened");
            Thread.sleep(15000);

            WebElement can = driver.findElements(By.tagName("canvas")).get(0);
            Actions builder = new Actions(driver);
            builder.moveToElement(can,0,0).click().perform();
            Thread.sleep(12000);

            WebElement eler1x = driver
                    .findElement(By.xpath("/html/body/div[2]/div/div/div/div[3]/div/div/div[17]/div"));
            String val1 = eler1x.getText();
            System.out.println(val1);
            WebElement eler1y = driver
                    .findElement(By.xpath("/html/body/div[2]/div/div/div/div[3]/div/div/div[19]/div"));
            String val2 = eler1y.getText();
            System.out.println(val2);
            double x1 = Double.parseDouble(val1);
        //error line    double y1 = Double.parseDouble(val1);
            double y1 = Double.parseDouble(val2);
            int r2x1 = (int) x1;
            int r2y1 = (int) y1;
            builder.moveByOffset(r2x1, r2y1);
            builder.click().build().perform();
            System.out.println("executed");

        } catch (Exception e) {
            System.out.println(e);
        }

i给出(x3,Y3)作为驱动程序的偏移值之间的差,测试用例通过但没有单击该点或多边形。任何人都可以举例或建议如何在Openlayers上计算偏移值

0 个答案:

没有答案