Selenium webdriver 还有一个问题,我正在编写一个测试,我需要在地图上绘制一个多边形(地图基于 Esri API)。我已成功放大,但找不到任何示例,如何在地图上绘制多边形或如何使用地图中的 x,y 坐标放置多边形顶点。
这是我的代码部分,我无法显示 url,它是私有的:
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 位 Visual C# 2017 Webdriver 版本 3.13.1.0
希望,你有一些想法!肿瘤坏死因子。