gpt4 book ai didi

c# - 如何使用 Selenium、Webdriver、C# 在 Esri map 上绘制多边形

转载 作者:行者123 更新时间:2023-12-05 05:15:13 26 4
gpt4 key购买 nike

我还有一个关于 Selenium webdriver 的问题,我正在编写一个测试,我需要在 map 上绘制一个多边形( map 基于 Esri API)。我已成功放大,但找不到任何示例,如何在 map 上绘制多边形或如何使用 map 中的 x、y 坐标放置多边形顶点。

这是我的代码部分,我不能显示 url,它是私有(private)的:

namespace MK_edit

{
class Program
{
static void Main(string[] args)
{
IWebDriver driver = new ChromeDriver(@"C:\Users\ProjectLibre");
driver.Url = "----";
driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(60);
driver.Manage().Window.Maximize();

//close popup
driver.FindElement(By.CssSelector("div.whatsnew-content"));
driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(30);
driver.FindElement(By.CssSelector("button.btn.btn-success")).Click();
driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(60);

//open element for editing
var lab = driver.FindElement(By.CssSelector("a[title=\"-\"]"));
var icon = driver.FindElement(By.CssSelector("span.glyphicon.glyphicon-edit"));
var loadingBackgrop = driver.FindElement(By.ClassName("overlay"));

IJavaScriptExecutor js = (IJavaScriptExecutor)driver;
js.ExecuteScript("arguments[0].style='display: none;'", icon);

var wait= new WebDriverWait(driver, new TimeSpan(0, 0, 60));
WaitForNotVisible(loadingBackgrop, driver);
wait.Until(ExpectedConditions.ElementToBeClickable(lab));
lab.Click();
//choose layer form the list
var layer_list = driver.FindElement(By.CssSelector("#edit-layerlist-holder .combobox-wrapper .selectize-input.items"));
WaitForNotVisible(loadingBackgrop, driver);
wait.Until(ExpectedConditions.ElementToBeClickable(layer_list));
layer_list.Click();

var forest = driver.FindElement(By.CssSelector("body > div:nth-child(12) > div > div:nth-child(15) > div:nth-child(21)"));
forest.Click();
//zoom in map x,y
var map = driver.FindElement(By.CssSelector("#map_gc"));
map.Click();
js.ExecuteScript("ng.geometryTools.zoomToXY(***177, ***289)");
var edit = driver.FindElement(By.CssSelector("#edit-drawbtn"));
edit.Click(); }

Chrome 版本 67.0.3396.99,64 位视觉 C# 2017Webdriver 版本 3.13.1.0

希望您有一些想法!谢谢。

最佳答案

我已经找到了解决方案,可能有人也会需要它。在我的任务中,我设法通过 Actions 绘制了一个多边形:

// polygon vertex
Actions vertex1 = new Actions(driver);
vertex1.MoveToElement(map).MoveByOffset(100, 100).Click();
IAction clickNextPoint = vertex1.Build();
clickNextPoint.Perform();

Actions vertex2 = new Actions(driver);
vertex2.MoveToElement(map).MoveByOffset(10,100).Click();
IAction clickNextPoint2 = vertex2.Build();
clickNextPoint2.Perform();

Actions vertex3 = new Actions(driver);
vertex3.MoveToElement(map).MoveByOffset(10, 10).Click();
IAction clickNextPoint3 = vertex3.Build();
clickNextPoint3.Perform();

Actions vertex4 = new Actions(driver);
vertex4.MoveToElement(karte).MoveByOffset(100, 10).DoubleClick();
System.Threading.Thread.Sleep(3000);

关于c# - 如何使用 Selenium、Webdriver、C# 在 Esri map 上绘制多边形,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51816018/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com