public void TestTest()
        {
            action = new ActionsExtension(Driver);
            var element = Driver.FindElement(By.Id("search_button"));
            action.MoveToElement(element, 0, 0);
            action.Click();
            action.Perform();
            Thread.Sleep(1000);
            var searchTextBox = Driver.FindElement(By.Id("searchTextBox"));
            searchTextBox.SendKeys("Humanity");
            Thread.Sleep(300);

            var res = (Driver as IJavaScriptExecutor).ExecuteScript(@"return $('#loadingImage:visible').length;");
            var resInt = Convert.ToInt32(res);
            Assert.AreEqual<bool>(true, resInt > 0, "Expected loading hasn't appeared");
        }
示例#2
0
        public void TestMouse_MoveAndClick_Circle()
        {
            GoToUrl();

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

            actions = new ActionsExtension(Driver);
            // building mouse moves on the virtual canvas element
            actions.MoveToElement(vc, vc.Size.Width / 2, vc.Size.Height / 2);
            actions.Click();
            actions.MoveByOffset(-100, -100);
            actions.Perform();

            var res = (Driver as IJavaScriptExecutor).ExecuteScript("return isMovedIn;");
            Assert.AreNotEqual(0.0, Convert.ToDouble(res));
            res = (Driver as IJavaScriptExecutor).ExecuteScript("return isMovedOut;");
            Assert.AreNotEqual(0.0, Convert.ToDouble(res));
            res = (Driver as IJavaScriptExecutor).ExecuteScript("return isClicked;");
            Assert.AreNotEqual(0.0, Convert.ToDouble(res));
        }
示例#3
0
        public void TestMouseBehavior_SingleClickOnTimeline_ZoomIntoTimeline()
        {
            // Compute coordinates of timeline's center on the screen.
            // k = 200; timeStart: -18.7 * k, timeEnd: 0, top: 0, height: 5 * k
            const double Width = 3740;
            const double Height = 1000;
            JsCoordinates offsetVirtual = new JsCoordinates(-3740 + Width / 2, 0 + Height / 2);
            JsCoordinates offsetScreen = vcPageObj.PointVirtualToScreen(offsetVirtual);

            JsVisible visibleBefore = vcPageObj.GetViewport();

            action = new ActionsExtension(Driver);
            action.MoveToElement(vcPageObj.VirtualCanvas, (int)offsetScreen.X, (int)offsetScreen.Y).Perform();
            action.Click().Perform();

            vcPageObj.WaitAnimation();

            JsVisible visibleAfter = vcPageObj.GetViewport();
            Size vcSize = vcPageObj.VirtualCanvas.Size;
            double timelineScreenWidth = Width / visibleAfter.Scale;
            double timelineScreenHeight = Height / visibleAfter.Scale;
            double timelineAspectRatio = timelineScreenWidth / timelineScreenHeight;
            double canvasAspectRatio = (double)vcSize.Width / vcSize.Height;
            double ratio = 0;

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

            // Timeline 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.
            Console.WriteLine(ratio);
            Assert.IsTrue(ratio > 0.9 && ratio <= 1);
            Assert.IsTrue(visibleAfter.CenterX == offsetVirtual.X && visibleAfter.CenterY == offsetVirtual.Y);
            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;
            }
        }
示例#5
0
        public void TestMouseBehavior_SingleClickOnInfodot_ZoomIntoInfodot()
        {
            // 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();

            action = new ActionsExtension(Driver);
            action.MoveToElement(vcPageObj.VirtualCanvas, (int)offsetScreen.X, (int)offsetScreen.Y).Perform();
            action.Click().Perform();

            vcPageObj.WaitAnimation();

            JsVisible visibleAfter = vcPageObj.GetViewport();
            Size vcSize = vcPageObj.VirtualCanvas.Size;
            double infodotVirtualSize = 240; // k = 200; radv = 0.6 * k;
            double infodotScreenSize = infodotVirtualSize / visibleAfter.Scale;

            // Infodot fills more than 90% of canvas' height. This condition can be regulated.
            // Also check, that center of viewport in the same point as center of the infodot.
            // It indicates, that infodot is inside of visible region and that infodot fills most of its space.
            double ratio = infodotScreenSize / vcSize.Height;

            Assert.IsTrue(ratio > 0.9 && ratio < 1);
            Assert.IsTrue(visibleAfter.CenterX == offsetVirtual.X && visibleAfter.CenterY == offsetVirtual.Y);
            Assert.AreNotEqual(visibleBefore, visibleAfter);
        }
示例#6
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);
        }
示例#7
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);
        }
示例#8
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();
            }
        }
示例#9
0
        public void SearchLengthTest1()
        {
            //maximum length of the inbox string
            int max_length = 700;
            //offset number of literals for test
            int offset = 10;
            string short_string = "";
            string big_string = "";
            string large_string = "";
            bool b1, b2, b3;
            //click on searchbox and get ready to type in it
            action = new ActionsExtension(Driver);
            var element = Driver.FindElement(By.Id("search_button"));
            action.MoveToElement(element, 0, 0);
            action.Click();
            action.Perform();
            var searchTextBox = Driver.FindElement(By.Id("searchTextBox"));
            //define random strings
            short_string = RussianSymbolString(10);
            big_string = RandomString(max_length);
            large_string = RandomString(max_length + offset);
            //Test1.regular size random english symbol string
            searchTextBox.SendKeys(short_string);
               // var searchbox_string = (Driver as IJavaScriptExecutor).ExecuteScript("return  $('#searchTextBox').val();");
            var searchbox_string = (Driver as IJavaScriptExecutor).ExecuteScript("return searchString;");
            b1 = searchbox_string.Equals(short_string);
            vcPageObj.ClearSearchTextBox();
            Trace.Write(b1);        //must be true
                //Test2.boundary maxsize size english random symbol string
            char[] c = new char[1];
            for (int i = 0; i <= max_length - 1; i++)
            {
                c[0] = big_string[i];
                string s = new string(c);
                searchTextBox.SendKeys(s);
            }
            //searchbox_string = (Driver as IJavaScriptExecutor).ExecuteScript("return  $('#searchTextBox').val();");
            searchbox_string = (Driver as IJavaScriptExecutor).ExecuteScript("return searchString;");
            b2 = searchbox_string.Equals(big_string);
            vcPageObj.ClearSearchTextBox();
            Trace.Write(b2);        //must be true
                //Test3.large maxsize+offset size english random symbol string(doesn't fit in searchbox)

            for (int i = 0; i <= max_length + offset - 1; i++)
            {
                c[0] = large_string[i];
                string s = new string(c);
                searchTextBox.SendKeys(s);
            }
            searchbox_string = (Driver as IJavaScriptExecutor).ExecuteScript("return searchString;");
            bool b31 = searchbox_string.Equals(large_string);       //false
            string cut_string = large_string.Remove(max_length);
            bool b32 = searchbox_string.Equals(cut_string);         //true
            vcPageObj.ClearSearchTextBox();
            b3 = (!b31) && b32;
            Trace.Write(b31);
            Trace.Write(b32);
            Trace.Write(b3);        //must be true
            //Test4.large maxsize+offset size random symbol string(doesn't fit in searchbox)
            bool b = b1 & b2 & b3;
            Assert.IsTrue(b);
            return;
        }