public void TestUrlNavigation_OpenAbsoluteBookmark_NavigatesToBookmark() { /* Arrange * Select a random timeline or exhibit. * Generate absolute bookmark url. */ string entityType = (rnd.Next() % 2 == 0) ? "timeline" : "infodot"; var l = getEntityIds(entityType); string id = l[rnd.Next(l.Count)]; // get relative bookmark url of the timeline/exhibit var js = Driver as IJavaScriptExecutor; var bookmarkUrl = js.ExecuteScript("return vcelementToNavString(vc.virtualCanvas('findElement', '" + id + "'));"); // update viewport according to the choosen timeline/exhibit GoToUrl(this.StartPage + "#" + bookmarkUrl); vcPageObj = new VirtualCanvasComponent(Driver); vcPageObj.WaitContentLoading(); //get absolute bookmark url of the timeline/exhibit js = Driver as IJavaScriptExecutor; bookmarkUrl = js.ExecuteScript("var el = vc.virtualCanvas('findElement','" + id + "'); var vp = vc.virtualCanvas('getViewport'); return vcelementToNavString(el, vp);"); /* Act * Go to bookmark url. */ GoToUrl(this.StartPage + "#" + bookmarkUrl); vcPageObj = new VirtualCanvasComponent(Driver); vcPageObj.WaitContentLoading(); var bookmarkItem = new { x = Convert.ToDouble(js.ExecuteScript("return vc.virtualCanvas('findElement','" + id + "').x;")), y = Convert.ToDouble(js.ExecuteScript("return vc.virtualCanvas('findElement','" + id + "').y;")), width = Convert.ToDouble(js.ExecuteScript("return vc.virtualCanvas('findElement','" + id + "').width;")), height = Convert.ToDouble(js.ExecuteScript("return vc.virtualCanvas('findElement','" + id + "').height;")) }; var bookmarkItemCenterX = bookmarkItem.x + bookmarkItem.width / 2; var bookmarkItemCenterY = bookmarkItem.y + bookmarkItem.height / 2; js = Driver as IJavaScriptExecutor; var viewportCenterX = Convert.ToDouble(js.ExecuteScript("return vc.virtualCanvas('getViewport').visible.centerX;")); var viewportCenterY = Convert.ToDouble(js.ExecuteScript("return vc.virtualCanvas('getViewport').visible.centerY;")); /* Assert * Verify that the timeline/exhibit specified * in the absolute bookmark url is visible. */ Assert.AreEqual(viewportCenterX, bookmarkItemCenterX, 1); Assert.AreEqual(viewportCenterY, bookmarkItemCenterY, 1); }
public void TestRegimes_RefreshPage_NavigatorBarSavedItState() { // generate random visible Random rnd = new Random(); double centerX = -65000000 * rnd.NextDouble(); double centerY = 300000 * rnd.NextDouble(); double scale = 500 * rnd.NextDouble(); // performing EllipticalZoom animation to generated visible and wait until animation is over. IJavaScriptExecutor js = Driver as IJavaScriptExecutor; js.ExecuteScript("setVisible(new VisibleRegion2d(" + centerX + ", " + centerY + ", " + scale + "));"); Thread.Sleep(AnimationDuration); // save current width and left CSS properties var regimeNavigator = Driver.FindElement(By.Id("regime_navigator")); var savedState = new Dictionary<string, object>(); savedState.Add("left", regimeNavigator.GetCssValue("left")); savedState.Add("width", regimeNavigator.GetCssValue("width")); // save current url var URL = Driver.Url; // reload page GoToUrl(this.StartPage); var vcPageObj = new VirtualCanvasComponent(Driver); vcPageObj.WaitContentLoading(); GoToUrl(URL); vcPageObj.WaitContentLoading(); // get width and left CSS properties after page reloading regimeNavigator = Driver.FindElement(By.Id("regime_navigator")); var newState = new Dictionary<string, object>(); newState.Add("left", regimeNavigator.GetCssValue("left")); newState.Add("width", regimeNavigator.GetCssValue("width")); // check that old and new width and left CSS properties are the same. Assert.AreEqual(savedState["left"], newState["left"], "ERROR: CSS 'left' changed."); Assert.AreEqual(savedState["width"], newState["width"], "ERROR: CSS 'width' changed."); }
public void TestInitialize() { GoToUrl(); vcPageObj = new VirtualCanvasComponent(Driver); vcPageObj.WaitContentLoading(); }
public void TestUrlNavigation_SharingOfBibliographyWindow_BibliographyWindowOpened() { /* Arrange * Select a random exhibit. * Generate absolute bookmark url. */ string entityType = "infodot"; var l = getEntityIds(entityType); string id = l[rnd.Next(l.Count)]; // get relative bookmark url of the exhibit var js = Driver as IJavaScriptExecutor; // TODO: Remove '@' at the end of this string aftre it will be fixed in scripts of cz var bookmarkUrl = js.ExecuteScript("return vcelementToNavString(vc.virtualCanvas('findElement', '" + id + "'));"); // update viewport according to the choosen exhibit GoToUrl(this.StartPage + "#" + bookmarkUrl); vcPageObj = new VirtualCanvasComponent(Driver); vcPageObj.WaitContentLoading(); var bibliography = id + "__bibliography"; // get screen coordinates of var visible = GetVisibleForCanvasElement(js, bibliography); var canvasElement = Driver.FindElement(By.Id("vc")); var biblWindowElement = Driver.FindElement(By.Id("bibliographyBack")); // check that bibliography window is hidden at this moment string windowDisplay = biblWindowElement.GetCssValue("display"); Assert.AreEqual(windowDisplay, "none", "ERROR: Bibliography window is visible but it shouldn't."); var action = new ActionsExtension(Driver); action.MoveToElement(canvasElement, Convert.ToInt32(visible["x"]) + 5, Convert.ToInt32(visible["y"]) + 5) .Click() .Perform(); // check that bibliography window is visible now windowDisplay = canvasElement.GetCssValue("display"); Assert.AreNotEqual(windowDisplay, "none", "ERROR: Bibliography window is not visible but it should."); var URL = Driver.Url; // change URL to reload page GoToUrl(this.StartPage); vcPageObj.WaitContentLoading(); // open shared bibliography link GoToUrl(URL); vcPageObj.WaitContentLoading(); // check that bibliography window is visible now biblWindowElement = Driver.FindElement(By.Id("bibliographyBack")); windowDisplay = biblWindowElement.GetCssValue("display"); Assert.AreNotEqual(windowDisplay, "none", "ERROR: Share failed. Bibliography window is not visible but it should."); }