public void TestAxisPan()
        {
            IJavaScriptExecutor js = Driver as IJavaScriptExecutor;

            IWebElement axis = Driver.FindElement(By.Id("axis"));

            var previousVisible = (Driver as IJavaScriptExecutor).ExecuteScript("return $('#vc').virtualCanvas('getViewport').visible;") as Dictionary<string, object>; //saving initial visible region

            ActionsExtension pan = new ActionsExtension(Driver);

            pan.MoveToElement(axis,axis.Size.Width/2,axis.Size.Height/2);
            pan.ClickAndHold();
            pan.MoveByOffset(-50, 20);
            pan.Release();
            pan.Perform(); //preforming panning

            pan.SetDefault(); // return mouse position to default

            Thread.Sleep(3000); //waiting the animation to complete

            var newVisible = (Driver as IJavaScriptExecutor).ExecuteScript("return $('#vc').virtualCanvas('getViewport').visible;") as Dictionary<string, object>; //saving new visible region after pan

            Assert.AreEqual(Convert.ToDouble(previousVisible["centerY"]), Convert.ToDouble(newVisible["centerY"])); //the Y must not be changed, as the axis pan is only horizontal
            Assert.IsTrue(Convert.ToDouble(previousVisible["centerX"]) < Convert.ToDouble(newVisible["centerX"])); //the X must ascend
        }
示例#2
0
        public void TestInterruptTourByPan()
        {
            IJavaScriptExecutor js = Driver as IJavaScriptExecutor;

            Thread.Sleep(2000);
            js.ExecuteScript("activateTour(tours[3]);"); // running test tour
            Thread.Sleep(500);

            var state1 = js.ExecuteScript("return {state: tour.state};") as Dictionary<string, object>;

            IWebElement vc = Driver.FindElement(By.Id("vc"));

            pan = new ActionsExtension(Driver);

            pan.MoveToElement(vc, vc.Size.Width / 2, vc.Size.Height / 2);
            pan.ClickAndHold();
            pan.MoveByOffset(-50, 20);
            pan.Release();
            pan.Perform(); //preforming panning

            pan.SetDefault(); // return mouse position to default

            var state2 = js.ExecuteScript("return {state: tour.state}") as Dictionary<string, object>;

            Thread.Sleep(500);

            Assert.AreEqual("play", state1["state"].ToString());
            Assert.AreEqual("pause", state2["state"].ToString());
        }
        public void TestBreadCrumbLink()
        {
            int ellipticZoomTimeWait = 6200;
            IJavaScriptExecutor js = Driver as IJavaScriptExecutor;

            var setVis = (Driver as IJavaScriptExecutor).ExecuteScript(
                "setVisible(new VisibleRegion2d(-692.4270728052991,222750361.2049456,0.35779500398729397));" //going into Humanity timline (coordinates snapshot)
                );
            Thread.Sleep(ellipticZoomTimeWait);

            var zoomedVisible = (Driver as IJavaScriptExecutor).ExecuteScript("return $('#vc').virtualCanvas('getViewport').visible;") as Dictionary<string, object>; //saving visible region after zoom
            IWebElement crumb = Driver.FindElement(By.Id("bc_0")); //finding second bread crumb to test a link of it
            Point crumbPosition = crumb.Location;

            ActionsExtension crumbClick = new ActionsExtension(Driver);
            crumbClick.MoveByOffset(crumbPosition.X + 2, crumbPosition.Y + 2)
                .Click()
                .Perform(); //clicking on the bread crumb
            crumbClick.SetDefault(); // return mouse position to default
            Thread.Sleep(ellipticZoomTimeWait);

            var breadCrumbVisible = (Driver as IJavaScriptExecutor).ExecuteScript("return $('#vc').virtualCanvas('getViewport').visible;") as Dictionary<string, object>; //saving visible region after clicking bread crumb

            Assert.IsTrue(Convert.ToDouble(zoomedVisible["scale"]) < Convert.ToDouble(breadCrumbVisible["scale"])); //scale must ascend
        }
示例#4
0
        public void TestGestures_MouseActivity_GestureBodyIsCorrect()
        {
            Dictionary<string, object> offset, scale;

            const int offsetX = 100;
            const int offsetY = 100;

            // Make pan gesture and check, that body of gesture is correct.
            action = new ActionsExtension(Driver);
            action.MoveByOffset(offsetX, offsetY).Perform();

            action.ClickAndHold();
            action.MoveByOffset(offsetX, offsetY);
            action.Release();
            action.Perform();

            vcPageObj.WaitAnimation();

            offset = ExecuteScriptGetJson("return offset;");

            Assert.AreEqual((double)offsetX, Convert.ToDouble(offset["xOffset"]), 5);
            Assert.AreEqual((double)offsetY, Convert.ToDouble(offset["yOffset"]), 5);

            action.SetDefault();

            // Make zoom gesture and check, that body of gesture is correct.
            GoToUrl();

            action.MoveByOffset(offsetX, offsetY).Perform();

            action.DoubleClick();
            action.Perform();

            vcPageObj.WaitAnimation();

            scale = ExecuteScriptGetJson("return scale;");

            Assert.AreEqual((double)offsetX, Convert.ToDouble(scale["xOrigin"]), 10);
            Assert.AreEqual((double)offsetY, Convert.ToDouble(scale["yOrigin"]), 10);
        }
示例#5
0
        public void TestRegimes_ClickCosmosLink_CosmosTimelineIsVisible()
        {
            Point cosmosLinkPosition = vcPageObj.CosmosLink.Location;
            Point earthLinkPosition = vcPageObj.EarthLink.Location;

            action = new ActionsExtension(Driver);

            // Click on the earth regime link.
            action.MoveByOffset(earthLinkPosition.X + 5, earthLinkPosition.Y + 2).Click().Perform();

            vcPageObj.WaitAnimation();

            action.SetDefault();

            JsVisible visibleBefore = vcPageObj.GetViewport();

            // Click on the cosmos regime link.
            action.MoveByOffset(cosmosLinkPosition.X + 5, cosmosLinkPosition.Y + 2).Click().Perform();

            vcPageObj.WaitAnimation();

            JsVisible visibleAfter = vcPageObj.GetViewport();
            JsTimeline timeline = GetCosmosTimeline();
            double width = timeline.right - timeline.left;
            JsCoordinates timelineCenter = new JsCoordinates(timeline.left + width / 2, timeline.y + timeline.height / 2);

            Assert.IsTrue(IsTimlineInFullSize(visibleAfter, timeline));
            Assert.AreEqual(visibleAfter.CenterX, timelineCenter.X, AnimationImplicity);
            Assert.AreEqual(visibleAfter.CenterY, timelineCenter.Y, AnimationImplicity);
            Assert.AreNotEqual(visibleBefore, visibleAfter);
        }
示例#6
0
        public void TestRegimes_ClickCosmosBarNoOverlay_CosmosTimelineIsVisible()
        {
            var vc = new VirtualCanvasComponent(Driver);
            vc.SetVisible(new JsVisible(-21.173972602739752, 226047946.84065938, 0.02607632093933464));
            vc.UpdateViewport();
            Thread.Sleep(100);

            Point cosmosBarPosition = vcPageObj.CosmosBar.Location;
            Point earthBarPosition = vcPageObj.EarthBar.Location;

            action = new ActionsExtension(Driver);

            // Click on the earth regime bar.
            action.MoveByOffset(earthBarPosition.X + 5, earthBarPosition.Y + 2).Click().Perform();

            vcPageObj.WaitAnimation();

            action.SetDefault();

            JsVisible visibleBefore = vcPageObj.GetViewport();

            // Click on the cosmos regime bar.
            action.MoveByOffset(cosmosBarPosition.X + 5, cosmosBarPosition.Y + 2).Click().Perform();

            vcPageObj.WaitAnimation();

            JsVisible visibleAfter = vcPageObj.GetViewport();
            JsTimeline timeline = GetCosmosTimeline();
            double width = timeline.right - timeline.left;
            JsCoordinates timelineCenter = new JsCoordinates(timeline.left + width / 2, timeline.y + timeline.height / 2);

            Assert.IsTrue(IsTimlineInFullSize(visibleAfter, timeline));
            Assert.AreEqual(visibleAfter.CenterX, timelineCenter.X, AnimationImplicity);
            Assert.AreEqual(visibleAfter.CenterY, timelineCenter.Y, AnimationImplicity);
            Assert.AreNotEqual(visibleBefore, visibleAfter);
        }
        public void TestBreadCrumbLink()
        {
            switch (Browser)
            {
                case BrowserType.Firefox:
                    // 10.1 version of FF doesn't correctly supported by Selenium.
                    //TODO: update this test with new version of Selenium.
                    Assert.Inconclusive("10.1 version of FF doesn't correctly supported by Selenium. Test will be updated with new version of Selenium.");
                    break;
                case BrowserType.InternetExplorer:

                    int ellipticZoomTimeWait = 6200;
                    IJavaScriptExecutor js = Driver as IJavaScriptExecutor;

                    var setVis = (Driver as IJavaScriptExecutor).ExecuteScript(
                        "setVisible(new VisibleRegion2d(-692.4270728052991,222750361.2049456,0.35779500398729397));" //going into Humanity timline (coordinates snapshot)
                        );
                    Thread.Sleep(ellipticZoomTimeWait);

                    var zoomedVisible = (Driver as IJavaScriptExecutor).ExecuteScript("return $('#vc').virtualCanvas('getViewport').visible;") as Dictionary<string, object>; //saving visible region after zoom

                    IWebElement crumb2 = Driver.FindElement(By.Id("bread_crumb_1")); //finding second bread crumb to test a link of it
                    ActionsExtension crumbClick = new ActionsExtension(Driver);
                    crumbClick.MoveToElement(crumb2, crumb2.Size.Width / 2, crumb2.Size.Height / 2);
                    crumbClick.Click();
                    crumbClick.Perform(); //clicking on the bread crumb

                    Thread.Sleep(ellipticZoomTimeWait);

                    var breadCrumbVisible = (Driver as IJavaScriptExecutor).ExecuteScript("return $('#vc').virtualCanvas('getViewport').visible;") as Dictionary<string, object>; //saving visible region after clicking bread crumb

                    crumbClick.SetDefault(); // return mouse position to default

                    Assert.IsTrue(Convert.ToDouble(zoomedVisible["scale"]) < Convert.ToDouble(breadCrumbVisible["scale"])); //scale must ascend
                    break;
            }
        }
        public void TestBreadCrumbs_HoverMouseOverBreadCrumb_BreadCrumbHighlighted()
        {
            GoToUrl("http://localhost:4949/cz.htm#/t55/e165/c477");

            IWebElement breadCrumb = Driver.FindElement(By.Id("bread_crumb_0"));
            ActionsExtension action = new ActionsExtension(Driver);
            switch (Browser)
            {
                case BrowserType.Firefox: // 10.1 version of FF doesn't correctly supported by Selenium.
                    //TODO: update this test with new version of Selenium.
                    Assert.Inconclusive("10.1 version of FF doesn't correctly supported by Selenium. Test will be updated with new version of Selenium.");
                    break;
                case BrowserType.InternetExplorer:
                    // Hover mouse over breadcrumb link.
                    action.MoveToElement(breadCrumb, breadCrumb.Size.Width / 2, breadCrumb.Size.Height / 2)
                        .Perform();

                    var res = (bool)(Driver as IJavaScriptExecutor).ExecuteScript(
                    "var currentColor = $('#bread_crumb_0').css('color');" + // Get the color of breadcrumb link.
                    "return currentColor == 'rgb(255, 255, 255)';"); // Check that this color is rgb(255,255,255). Return result.
                    action.SetDefault();
                    // Check that color is corret.
                    Assert.IsTrue(res);
                    break;
            }
        }
        public void TestBreadCrumbs_BreadCrumbLinkColorIsCorrect()
        {
            GoToUrl("http://localhost:4949/cz.htm#/t55/e165/c477");

            IWebElement breadCrumb = Driver.FindElement(By.Id("bread_crumb_0"));
            ActionsExtension action = new ActionsExtension(Driver);
            switch (Browser)
            {
                case BrowserType.Firefox: // 10.1 version of FF doesn't correctly supported by Selenium.
                    //TODO: update this test with new version of Selenium.
                    Assert.Inconclusive("10.1 version of FF doesn't correctly supported by Selenium. Test will be updated with new version of Selenium.");
                    break;
                case BrowserType.InternetExplorer:
                    var colorBefore = (string)(Driver as IJavaScriptExecutor).ExecuteScript(
                    "var currentColor = $('#bread_crumb_0').css('color');" + // Get the color of breadcrumb link.
                    "return currentColor;"); // Return the color.

                    // Hover mouse over breadcrumb link.
                    action.MoveToElement(breadCrumb, breadCrumb.Size.Width / 2, breadCrumb.Size.Height / 2)
                        .Perform();
                    // Hover mouse out from breadcrumb link.
                    action.SetDefault();

                    var colorAfter = (string)(Driver as IJavaScriptExecutor).ExecuteScript(
                    "var currentColor = $('#bread_crumb_0').css('color');" + // Get the color of breadcrumb link after it was hover by mouse.
                    "return currentColor;"); // Return the color.

                    // Check that initial and current color are the same.
                    Assert.AreEqual(colorBefore, colorAfter);
                    break;
            }
        }
示例#10
0
        public void TestMouseBehavior_SingleClickOnContentItem_ZoomIntoContentItem()
        {
            Thread.Sleep(5000);
            // Compute coordinates of infodot on the screen.
            JsCoordinates offsetVirtual = new JsCoordinates(-3200, 400); // k = 200; time = -16 * k, vyc = 2.0 * k, radv = 0.6 * k;
            JsCoordinates offsetScreen = vcPageObj.PointVirtualToScreen(offsetVirtual);

            JsVisible visibleBefore = vcPageObj.GetViewport();

            // Click on the infodot and wait animation.
            action = new ActionsExtension(Driver);
            action.MoveToElement(vcPageObj.VirtualCanvas, (int)offsetScreen.X, (int)offsetScreen.Y).Perform();
            action.Click().Perform();

            vcPageObj.WaitAnimation();

            action.SetDefault();

            offsetScreen = vcPageObj.PointVirtualToScreen(offsetVirtual);

            // Click on the content item.
            action.MoveToElement(vcPageObj.VirtualCanvas, (int)offsetScreen.X, (int)offsetScreen.Y).Perform();
            vcPageObj.WaitAnimation();
            action.Click().Perform();

            vcPageObj.WaitAnimation();

            JsVisible visibleAfter = vcPageObj.GetViewport();
            Size vcSize = vcPageObj.VirtualCanvas.Size;

            // From Javascript code:
            //
            // var _rad = 450.0 / 2.0; //489.0 / 2.0;
            // var k = 1.0 / _rad;
            // var _wc = 260.0 * k;
            // var _hc = 270.0 * k;

            // Width = _wc * rad, Height = _hc * rad, rad = 120.

            const double Width = 1.155555555555556 * 120;
            const double Height = 1.2 * 120;

            double contentItemScreenWidth = Width / visibleAfter.Scale;
            double contentItemScreenHeight = Height / visibleAfter.Scale;
            double contentItemAspectRatio = contentItemScreenWidth / contentItemScreenHeight;
            double canvasAspectRatio = (double)vcSize.Width / vcSize.Height;
            double ratio = 0;

            // Check the side, that should fit the corresponding side of canvas.
            if (contentItemAspectRatio >= canvasAspectRatio)
            {
                ratio = contentItemScreenWidth / vcSize.Width;
            }
            else
            {
                ratio = contentItemScreenHeight / vcSize.Height;
            }

            // Content item fills more than 90% of canvas' side, but less or equal than 100% of the same side.
            // Also check, that center of viewport in the same point as center of the timeline.
            // It indicates, that timeline is inside of visible region and that timeline fills most of its space.
            Assert.IsTrue(ratio > 0.9 && ratio <= 1);
            Assert.IsTrue(visibleAfter.CenterX == offsetVirtual.X && visibleAfter.CenterY == offsetVirtual.Y);
            Assert.AreNotEqual(visibleBefore, visibleAfter);
        }
示例#11
0
        public void TestMouseBehavior_HoverOverContentItem_Highlight()
        {
            // Compute coordinates of infodot on the screen.
            JsCoordinates offsetVirtual = new JsCoordinates(-3200, 400); // k = 200; time = -16 * k, vyc = 2.0 * k, radv = 0.6 * k;
            JsCoordinates offsetScreen = vcPageObj.PointVirtualToScreen(offsetVirtual);

            // Click on the infodot and wait animation.
            action = new ActionsExtension(Driver);
            action.MoveToElement(vcPageObj.VirtualCanvas, (int)offsetScreen.X, (int)offsetScreen.Y).Perform();
            action.Click().Perform();

            vcPageObj.WaitAnimation();

            action.SetDefault();

            string colorBefore = (string)ExecuteScript("return majorBorder.settings.strokeStyle;");

            offsetScreen = vcPageObj.PointVirtualToScreen(offsetVirtual);

            // Mouse move over the content item.
            action.MoveToElement(vcPageObj.VirtualCanvas, (int)offsetScreen.X, (int)offsetScreen.Y).Perform();

            string colorAfter = (string)ExecuteScript("return majorBorder.settings.strokeStyle;");

            Assert.AreNotEqual(colorBefore, colorAfter);
        }
示例#12
0
        public void TestSearch_SearchQueries_ScreenshotsCreated()
        {
            // Get titles.
            string[] titles = GetTitlesFromResponseDump();

            // Get random titles or range of titles from collection.
            List<string> searchQueries = (RandomRegimeOn) ? GetRandomTitles(titles) : GetRangeOfTitles(titles);

            // Click on the Search button and wait until it expands.
            vcPageObj.SearchButton.Click();
            Thread.Sleep(WaitSearchMenuExpandingMs);

            action = new ActionsExtension(Driver);

            // Regular expression to remove invalid filename characters of screenshots.
            string invalidFileNameChars = new string(Path.GetInvalidFileNameChars());
            Regex regex = new Regex(string.Format("[{0}]", Regex.Escape(invalidFileNameChars)));

            // For alert handling.
            IAlert alert = null;
            bool alertIsActive = false;

            // Enter search queries and click on them.
            foreach (string query in searchQueries)
            {
                alertIsActive = false;

                vcPageObj.EnterSearchQuery(query);
                Thread.Sleep(WaitResultsMs);

                // Move mouse arrow to result and click on it.
                WebDriverWait wait = new WebDriverWait(Driver, TimeSpan.FromMilliseconds(WaitTimeOutMs));

                try
                {
                    IWebElement result = wait.Until<IWebElement>((d) =>
                    {
                        // Return dynamically created search result.
                        return Driver.FindElement(By.XPath(SearchResultXPath));
                    });

                    action.Click(result).Perform();
                    vcPageObj.WaitAnimation();
                }
                catch (TimeoutException)
                {
                    Console.WriteLine("NOT FOUND: " + query);
                }

                // Handling of alert messages.
                try
                {
                    alert = Driver.SwitchTo().Alert();
                    alertIsActive = true;
                    alert.Accept();
                    Console.WriteLine("ALERT: " + query);
                }
                catch (NoAlertPresentException)
                {
                    Console.WriteLine("OK: " + query);
                }

                // Save screenshot of search result. If alert had appeared, then add special string to filename of screenshot.
                // NOTE: Uses user environment variable SELENIUM_SCR.
                if (alertIsActive)
                {
                    WebDriverScreenshotMaker.SaveScreenshot(Driver, "TestSearch", alertString + regex.Replace(query, ""), ImageFormat.Png, true);
                }
                else
                {
                    WebDriverScreenshotMaker.SaveScreenshot(Driver, "TestSearch", regex.Replace(query, ""), ImageFormat.Png, true);
                }

                action.SetDefault();
                vcPageObj.ClearSearchTextBox();
            }
        }
示例#13
0
        public void TestBreadCrumbTimelineClick()
        {
            int ellipticZoomTimeWait = 6200;
            IJavaScriptExecutor js = Driver as IJavaScriptExecutor;

            var setVis = (Driver as IJavaScriptExecutor).ExecuteScript(
                "setVisible(new VisibleRegion2d(-6850000000,3388966248.683534,8124234.157802994));" //going into Canvas timeline (coordinates snapshot)
                );
            Thread.Sleep(ellipticZoomTimeWait);

            Point crumbPosition = new Point(688, 198); //timeline

            ActionsExtension crumbClick = new ActionsExtension(Driver);
            crumbClick.MoveByOffset(crumbPosition.X, crumbPosition.Y)
                .Click()
                .Perform(); //clicking on the bread crumb
            crumbClick.SetDefault(); // return mouse position to default
            Thread.Sleep(ellipticZoomTimeWait);

            var idResTimeline = js.ExecuteScript("return breadCrumbs[1].vcElement.id");
            Assert.AreEqual("t91", idResTimeline); //"Stelliferous (Starry) Epoch" id timeline
        }