How to draw a polygon on the Esri map using Selenium, Webdriver, C#

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP



How to draw a polygon on the Esri map using Selenium, Webdriver, C#



I have one more issue with Selenium webdriver, I am writing a test, where I need draw a polygon on the map (map is based on Esri API). I have successfully managed to zoom in, but couldn't find any examples, how to draw a polygon on the map or how to put polygon vertex using x,y coordinate from the map.



Here is my code part, I cannot show url, it's private:


namespace MK_edit

{
class Program
{
static void Main(string args)

IWebDriver driver = new ChromeDriver(@"C:UsersProjectLibre");
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 version 67.0.3396.99, 64 bit
Visual C# 2017
Webdriver version 3.13.1.0



Hope, you have some ideas! Tnx.




1 Answer
1



I have found a solution, probably, someone will need it, too. In my task, I have managed to draw a polygon by 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);






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

make 2 or more post in bootsrap

Store custom data using WC_Cart add_to_cart() method in Woocommerce 3

Firebase Auth - with Email and Password - Check user already registered