/// <summary>
        /// Method performing a control click on multiple IWebElement objects.
        /// </summary>
        /// <param name="driver">IWebDriver object to execute method.</param>
        /// <param name="elements">The set of elements to perform the clicks.</param>
        public static void ControlClick(this IWebDriver driver, params IWebElement[] elements)
        {
            try
            {
                if (elements == null)
                {
                    return;
                }
                if (elements.Length == 0)
                {
                    return;
                }

                var action = new OpenQA.Selenium.Interactions.Actions(driver);

                action.KeyDown(Keys.Control);
                foreach (IWebElement element in elements)
                {
                    action.MoveToElement(element);
                    action.MoveToElement(element).Click();
                }
                action.KeyUp(Keys.Control);
                action.Build().Perform();
            }
            catch { }
        }
Esempio n. 2
0
        public static void ContextClick(this IWebDriver driver, IWebElement element)
        {
            try
            {
                var action = new OpenQA.Selenium.Interactions.Actions(driver);

                action.MoveToElement(element);
                action.MoveToElement(element).ContextClick();
                action.Build().Perform();
            }
            catch { }
        }
Esempio n. 3
0
        public static void ContextClick(this IWebElement element)
        {
            try
            {
                var wrappedElement = element as IWrapsDriver;
                var driver         = wrappedElement.WrappedDriver;
                var action         = new OpenQA.Selenium.Interactions.Actions(driver);

                action.MoveToElement(element);
                action.MoveToElement(element).ContextClick();
                action.Build().Perform();
            }
            catch { }
        }
Esempio n. 4
0
        // Purpose - to click search/view button

        public void ToClickSearchViewbutton()
        {
            string getQuestionName = DatabaseTools.GetQuestionName(Enumerations.QuestionType.SCO);

            WebDriver.FindElement(By.Id("_ctl0_InnerPageContent_ucSearchPanel_txtSearch")).SendKeys(getQuestionName);
            WebDriver.FindElement(By.Id("_ctl0_InnerPageContent_ucSearchPanel_cmdSearchGo")).Click();
            WebDriver.SwitchTo().ActiveElement();
            IWebElement toverifytablecontent = WebDriver.FindElement(By.Id("dgContentLibrary$contentCntr"));

            if (toverifytablecontent.Displayed)
            {
                GenericHelper.Logs("SCO Questions table has been loaded successfully", "Passed");
            }
            IWebElement menu    = WebDriver.FindElement(By.XPath("//table[@id='dgContentLibrary']/descendant::td[contains(@class, 'es_qlTD')]"));
            Actions     builder = new Actions(WebDriver);

            builder.MoveToElement(menu).Build().Perform();
            IWebElement menu1 = WebDriver.FindElement(By.XPath("//table[@id='dgContentLibrary']/descendant::td[contains(@class, 'es_qlTD2')]"));

            builder.MoveToElement(menu1).Click().Perform();
            IWebElement submenu = WebDriver.FindElement(By.PartialLinkText("Preview"));

            builder.MoveToElement(submenu).Click().Perform();
            Thread.Sleep(3000);
            GenericHelper.SelectWindow("Tryout");
            bool toVerifyFlash = WebDriver.FindElement(By.XPath("//div[starts-with(@id,'divSCOFrame')]")).Displayed;

            if (toVerifyFlash)
            {
                GenericHelper.Logs("SCO Frame is displayed successfully", "Passed");
            }
            bool toVerifyFlashFrame = WebDriver.FindElement(By.XPath("//iframe[starts-with(@id, 'iFrameSCO')]")).Displayed;

            if (toVerifyFlashFrame)
            {
                GenericHelper.Logs("SCO Content is displayed successfully", "Passed");
            }

            WebDriver.SwitchTo().Frame(0);

            IWebElement isErrorPresent = WebDriver.FindElement(By.TagName("body"));

            if (isErrorPresent.Text.Contains("Server"))
            {
                GenericHelper.Logs("There is no SCO Content", "Failed");
            }
            Thread.Sleep(3000);
            WebDriver.Close();
        }
Esempio n. 5
0
        public static void ClickAndWait(this IWebDriver driver, IWebElement element, string title, int timespan = 5)
        {
            try
            {
                var action = new OpenQA.Selenium.Interactions.Actions(driver);
                var wait   = new WebDriverWait(driver, TimeSpan.FromSeconds(timespan));

                action.MoveToElement(element);
                action.MoveToElement(element).Click();
                action.Build().Perform();

                wait.Until(d => d.Title.Equals(title, StringComparison.CurrentCultureIgnoreCase));
            }
            catch { }
        }
Esempio n. 6
0
 public void Hover(Element element)
 {
     var sequenceBuilder = new OpenQA.Selenium.Interactions.Actions(selenium);
     var actionSequenceBuilder = sequenceBuilder.MoveToElement((IWebElement) element.Native);
     var action = actionSequenceBuilder.Build();
     action.Perform();
 }
        public void MoveMouseTo(IWebDriver driver, IWebElement element)
        {
            var customWaiters = new CustomWaiters();
            var actions       = new OpenQA.Selenium.Interactions.Actions(driver);

            actions.MoveToElement(customWaiters.WaitUntilClickable(element)).Build().Perform();
        }
Esempio n. 8
0
        public void How_To_Automate_Slider()
        {
            IWebElement slider            = chromedriver.FindElement(By.Id("slider"));
            IWebElement sliderEndPosition = chromedriver.FindElement(By.Id("slider"));

            //Oneway
            OpenQA.Selenium.Interactions.Actions action = new OpenQA.Selenium.Interactions.Actions(chromedriver);
            action.DragAndDropToOffset(slider, 30, 30)
            .Build()
            .Perform();

            //Another way
            action.DragAndDrop(slider, sliderEndPosition)
            .Build()
            .Perform();
            //Anotherway(loop by how many times you want to shift)
            slider.SendKeys(Keys.Right);

            //One more way
            action.MoveToElement(slider)
            .ClickAndHold()
            .MoveByOffset(0, 250)
            .Release()
            .Perform();
        }
Esempio n. 9
0
        public void NewHomepage()
        {
            string handle = driver.CurrentWindowHandle;

            var comment2 = driver.FindElement(By.XPath("/html/body/div[1]/div/myapp/section[3]/div/div/div/div[1]/div/section[1]/div/div/div[1]/div/a"));

            //string title = driver.FindElement(By.XPath("/html/body/div[1]/div/myapp/section[3]/div/div/div/div[1]/div/section[1]/div/div/div[1]/div/h2")).Text;


            var action1 = new OpenQA.Selenium.Interactions.Actions(driver);

            ((IJavaScriptExecutor)driver).ExecuteScript("window.scrollTo(document.body.scrollHeight, 0)");
            action1.MoveToElement(comment2);
            action1.Perform();

            comment2 = new WebDriverWait(driver, new TimeSpan(0, 1, 0))
                       .Until(driver => driver.FindElement(By.XPath("/html/body/div[1]/div/myapp/section[3]/div/div/div/div[1]/div/section[1]/div/div/div[1]/div/a")));
            Thread.Sleep(2000);
            comment2.Click();
            Thread.Sleep(2000);

            driver.SwitchTo().Window(handle);


            /*if (title.Contains("Cricket News"))
             *
             * {
             *  driver.FindElement(By.XPath("/html/body/div[1]/div/myapp/section[3]/div/div/div/div[1]/div/section[1]/div/div/div[1]/div/a")).Click();
             *
             * }*/
        }
Esempio n. 10
0
        public static void ClickAndWait(this IWebDriver driver, IWebElement element, By newObject, int timespan = 5)
        {
            try
            {
                var action = new OpenQA.Selenium.Interactions.Actions(driver);
                var wait   = new WebDriverWait(driver, TimeSpan.FromSeconds(timespan));

                action.MoveToElement(element);
                action.MoveToElement(element).Click();
                action.Build().Perform();

                wait.Until(ExpectedConditions.ElementExists(newObject));
                wait.Until(ExpectedConditions.ElementIsVisible(newObject));
            }
            catch { }
        }
Esempio n. 11
0
        /// <summary>
        /// Method performing a mouse click with hold and no release.
        /// </summary>
        /// <param name="driver">IWevDriver provided.</param>
        /// <param name="element">IWebElement element that receives the click and hold action.</param>
        public static void ClickAndHold(this IWebDriver driver, IWebElement element)
        {
            try
            {
                var action = new OpenQA.Selenium.Interactions.Actions(driver);

                action.MoveToElement(element);
                action.MoveToElement(element).ClickAndHold();
                action.Build().Perform();
            }
            catch (Exception e)
            {
                throw new InternalActionException(string.Format("Unable to click and hold object \"{0}\".\r\nSee:\r\n\t- {1}{2}", element,
                                                                e.Message, (e.InnerException == null ? "" : string.Format("\r\n\t- {0}", e.InnerException.Message))), e);
            }
        }
Esempio n. 12
0
        public void UploadSuccessful()
        {
            string url = "http://testpan.chinacloudapp.cn/";
            string userName = "******";
            string Password = "******";
            var driver = Helper.DMLogin(url, userName, Password);
            driver.FindElement(By.CssSelector("a.menuBtn_upload > span.icontxt")).Click();
            driver.FindElement(By.CssSelector("a.a-pw_add > span.icontxt")).Click();

            //使用autoit操作windows窗口
            Helper.AutoitHelper(@"D:\temp\test.xls");
            Thread.Sleep(2000);
            driver.FindElement(By.Id("upload-done")).Click();
            Thread.Sleep(2000);

            //找到上传的文件,删除,测试通过
            var ExistTableElement =
                driver.FindElement(
                    By.CssSelector("table[data-name='test.xls']"));

            var mouseOverAction = new OpenQA.Selenium.Interactions.Actions(driver);
            mouseOverAction.MoveToElement(ExistTableElement);
            mouseOverAction.Perform();
            ExistTableElement.FindElement(By.CssSelector("div.menuBtn > a.delete")).Click();
            driver.FindElement(By.XPath("//*[@id='window_delete']/div/div[3]/table/tbody/tr/td[1]/a")).Click();

            driver.Quit();
        }
Esempio n. 13
0
        public IWebElement GetYellowcardData()
        {
            var DropDown = driver.FindElement(By.CssSelector(".si-stats-dropdown-container"));
            var action1  = new OpenQA.Selenium.Interactions.Actions(driver);

            ((IJavaScriptExecutor)driver).ExecuteScript("window.scrollTo(document.body.scrollHeight, 0)");
            action1.MoveToElement(DropDown);
            action1.Perform();
            DropDown = new WebDriverWait(driver, new TimeSpan(0, 1, 0))
                       .Until(driver => driver.FindElement(By.CssSelector(".si-stats-dropdown-container")));


            var players = new List <players>
            {
                Firstplayer()
            };

            var allDivs = driver.FindElements(By.CssSelector(".si-tRow")).Skip(2);

            foreach (var div in allDivs)
            {
                var name       = div.FindElement(By.CssSelector(".si-fullName ")).Text;
                var id         = div.GetAttribute("data-playerid");
                var yellowcard = div.FindElement(By.CssSelector(".si-plyStats-gamplyd ")).Text;

                players.Add(new players {
                    Name = name, Id = id, Yellowcard = yellowcard
                });
                TestContext.Out.WriteLine($"NAME: { name }| Id:{id}|Yellowcard: { yellowcard } ");
            }


            CreateXlSheet(players);
            return(null);
        }
Esempio n. 14
0
        public players Firstplayer()

        {
            var DropDown = driver.FindElement(By.CssSelector(".si-stats-dropdown-container"));
            var action1  = new OpenQA.Selenium.Interactions.Actions(driver);

            ((IJavaScriptExecutor)driver).ExecuteScript("window.scrollTo(document.body.scrollHeight, 0)");
            action1.MoveToElement(DropDown);
            action1.Perform();
            DropDown = new WebDriverWait(driver, new TimeSpan(0, 1, 0))
                       .Until(driver => driver.FindElement(By.CssSelector(".si-stats-dropdown-container")));

            var name = driver.FindElement(By.CssSelector(".si-awdPlyrName")).Text;
            var id   = driver.FindElement(By.CssSelector(".si-statHeadRow")).GetAttribute("data-playerid");

            var redcard = driver.FindElement(By.CssSelector(".si-points span")).Text;

            return(new players
            {
                Name = name,
                Id = id,

                Redcard = redcard
            });
        }
Esempio n. 15
0
        public void Test_4_1()
        {
            var howHelp  = new HowHelp();
            var homePage = new HomePage();

            PageFactory.InitElements(driver, homePage);
            PageFactory.InitElements(driver, howHelp);
            var action = new OpenQA.Selenium.Interactions.Actions(driver);

            //Clicking on the tabs
            action.MoveToElement(homePage.weAreWabash).Perform();
            System.Threading.Thread.Sleep(500);
            homePage.ourCulture.Click();

            System.Threading.Thread.Sleep(2000);

            //Scroll page down
            ((IJavaScriptExecutor)driver).ExecuteScript("window.scrollTo(0, document.body.scrollHeight - 150)");

            //Choose Choice
            howHelp.choice.Click();
            System.Threading.Thread.Sleep(500);
            howHelp.secondChoice.Click();

            //Choose Country
            howHelp.country.Click();
            System.Threading.Thread.Sleep(500);
            howHelp.canada.Click();

            //Type Name
            howHelp.name.SendKeys("T-800");

            //Type Company
            howHelp.company.SendKeys("SkyNet");

            //Type E-Mail
            howHelp.email.SendKeys("*****@*****.**");

            //Type Phone number
            howHelp.phone.SendKeys("123-456-789");

            //Type Comments
            howHelp.comments.SendKeys("Can you give me your dress and motorbike?");
            System.Threading.Thread.Sleep(2000);
            howHelp.submit.Click();
            System.Threading.Thread.Sleep(2000);

            //Scroll page down
            ((IJavaScriptExecutor)driver).ExecuteScript("window.scrollTo(0, document.body.scrollHeight - 150)");
            System.Threading.Thread.Sleep(3000);

            IWebElement element = driver.FindElement(By.ClassName("sfSuccess"));

            bool res = CheckForm.result(element);

            System.Threading.Thread.Sleep(2000);

            Assert.IsTrue(res, "The form was not submited");
        }
Esempio n. 16
0
        public static void HoverOpe(IWebDriver driver,
                                    TestPart testPart)
        {
            IWebElement mouseTarget = driver.FindElement(SelectItem(testPart: testPart));
            var         builder     = new OpenQA.Selenium.Interactions.Actions(driver);

            builder.MoveToElement(mouseTarget).Perform();
        }
Esempio n. 17
0
 // Tries to click an element at offset taking into account a predefined timeout
 // This can generate a variety of exception that are all handled in this method
 /// <param name="driver"></param>
 /// <param name="by"></param>
 /// <param name="x"></param>
 /// <param name="y"></param>
 public static void ClickAtOffSet(this IWebDriver driver, By by, int x, int y)
 {
     driver.Interact(by, ElementToBeClickable(by), element =>
     {
         var actions = new OpenQA.Selenium.Interactions.Actions(driver);
         actions.MoveToElement(element, x, y).Click().Build().Perform();
     });
 }
Esempio n. 18
0
        public void Hover(Element element)
        {
            var sequenceBuilder       = new OpenQA.Selenium.Interactions.Actions(_selenium);
            var actionSequenceBuilder = sequenceBuilder.MoveToElement((IWebElement)element.Native);
            var action = actionSequenceBuilder.Build();

            action.Perform();
        }
Esempio n. 19
0
        public static void HoverAndSelect(IWebElement hoverElement, string clickElement)
        {
            Actions action = new Actions(_webDriver);
            var     el2    = Driver.FindElement(By.XPath(".//*[@title='" + clickElement + "']"));

            action.MoveToElement(hoverElement).Perform();
            action.Click(el2).Perform();
        }
Esempio n. 20
0
        // Checks element is visible and moves to it, taking into account a predefined timeout
        // This can generate a variety of exception that are all handled in this method
        /// <param name="driver"></param>
        /// <param name="by"></param>
        /// <param name="offsetX"></param>
        /// <param name="offsetY"></param>

        public static void MoveToElement(this IWebDriver driver, By by, int offsetX = 0, int offsetY = 0)
        {
            driver.Interact(by, ElementIsVisible(by), element =>
            {
                var actions = new OpenQA.Selenium.Interactions.Actions(driver);
                actions.MoveToElement(element, offsetX: offsetX, offsetY: offsetY).Perform();
            });
        }
Esempio n. 21
0
        /// <summary>
        /// Method performing a drag and drop of a given element onto another element (preferably a container).
        /// </summary>
        /// <param name="driver"></param>
        /// <param name="dragElement">Element to drag onto the drop element.</param>
        /// <param name="dropElement">The drop element (a container).</param>
        public static void DragAndDrop(this IWebDriver driver, IWebElement dragElement, IWebElement dropElement)
        {
            try
            {
                var action = new OpenQA.Selenium.Interactions.Actions(driver);

                action.MoveToElement(dragElement).Build().Perform();
                action.MoveToElement(dragElement).ClickAndHold();
                action.MoveToElement(dropElement).Release(dropElement);
                action.Build().Perform();
            }
            catch (Exception e)
            {
                throw new InternalActionException(string.Format("Unable to drag object \"{0}\" onto drop area with object \"{1}\".\r\nSee:\r\n\t- {2}{3}", dragElement, dropElement,
                                                                e.Message, (e.InnerException == null ? "" : string.Format("\r\n\t- {0}", e.InnerException.Message))), e);
            }
        }
Esempio n. 22
0
        /// <summary>
        /// Method performing a mouse right-click on a given IWebElement element.
        /// </summary>
        /// <param name="element">IWebElement element that receives the right-click action.</param>
        public static void ContextClick(this IWebElement element)
        {
            try
            {
                var wrappedElement = element as IWrapsDriver;
                var driver         = wrappedElement.WrappedDriver;
                var action         = new OpenQA.Selenium.Interactions.Actions(driver);

                action.MoveToElement(element);
                action.MoveToElement(element).ContextClick();
                action.Build().Perform();
            }
            catch (Exception e)
            {
                throw new InternalActionException(string.Format("Unable to right-click on object \"{0}\".\r\nSee:\r\n\t- {1}{2}", element,
                                                                e.Message, (e.InnerException == null ? "" : string.Format("\r\n\t- {0}", e.InnerException.Message))), e);
            }
        }
Esempio n. 23
0
        protected static void MoveToElement(PageElement pageElement, TimeSpan?maxWaitTime = null)
        {
            pageElement.GoToFrame();
            var action =
                new OpenQA.Selenium.Interactions.Actions(SeleniumDriver.Driver);

            action.MoveToElement(SeleniumUtility.WebDriverWait(ExpectedConditions.ElementIsVisible(pageElement.Locator),
                                                               maxWaitTime ?? Default5Seconds)).Build().Perform();
        }
Esempio n. 24
0
        public void Test_3_1()
        {
            var homePage     = new HomePage();
            var dealerButton = new DealerButton();

            PageFactory.InitElements(driver, homePage);
            PageFactory.InitElements(driver, dealerButton);
            var action = new OpenQA.Selenium.Interactions.Actions(driver);

            //Go on Location Search - Dealer
            action.MoveToElement(homePage.locationSearch).Perform();
            System.Threading.Thread.Sleep(500);
            homePage.dealer.Click();
            System.Threading.Thread.Sleep(1000);

            //Clear all filters before searching
            dealerButton.clearAll.Click();

            //Grab a initial amount of items in search grid results
            List <IWebElement> searchGrid = new List <IWebElement>();

            for (int i = 0; i < 86; i++)
            {
                searchGrid.Add(driver.FindElement(By.ClassName("w__dealer_item")));
            }
            Console.WriteLine("Clear all filters");
            Console.WriteLine("Results: " + searchGrid.Count + " results near Indiana");
            Console.WriteLine();

            dealerButton.parts.Click();
            dealerButton.sales.Click();
            dealerButton.company.SendKeys("Wabash");
            System.Threading.Thread.Sleep(7000);

            //Verify the result
            List <IWebElement> searchGrid_1 = new List <IWebElement>();

            for (int i = 0; i < 4; i++)
            {
                searchGrid_1.Add(driver.FindElement(By.ClassName("w__dealer_item")));
            }

            if (searchGrid_1.Count == 4)
            {
                Console.WriteLine("Search: Wabash; Location Type: Sales + Parts;");
                Console.WriteLine("Results: " + searchGrid_1.Count + " results near Indiana");
            }

            Console.WriteLine();

            System.Threading.Thread.Sleep(1000);

            bool res = CheckSearch.result(searchGrid_1);

            Assert.IsTrue(res, "Amount of results in search grid are not match with expected. Expected: 4");
        }
Esempio n. 25
0
        public void Logout()
        {
            var action = new OpenQA.Selenium.Interactions.Actions(_driver);

            var accountMenu = _driver.WdFindElement(NavigationHeaderLOC.PlayerAccount);

            action.MoveToElement(accountMenu).Build().Perform();

            _driver.WdFindElement(PlayerMenuLOC.ButtonLogout).Click();
        }
        /// <summary>
        /// Method performing a multi-click selection given two IWebElement objects. Use on a list of objects, it should also select all elements found within the given objects.
        /// </summary>
        /// <param name="driver">IWebDriver object to execute method.</param>
        /// <param name="firstElement">First IWebElement object onto which first click is performed.</param>
        /// <param name="secondElement">Second IWebElement object onto which second click is performed.</param>
        public static void ShiftClick(this IWebDriver driver, IWebElement firstElement, IWebElement secondElement)
        {
            try
            {
                var action = new OpenQA.Selenium.Interactions.Actions(driver);

                action.MoveToElement(firstElement);
                action.MoveToElement(firstElement).Click();

                action.KeyDown(Keys.Shift);

                action.MoveToElement(secondElement);
                action.MoveToElement(secondElement).Click();

                action.KeyUp(Keys.Shift);
                action.Build().Perform();
            }
            catch { }
        }
Esempio n. 27
0
        /// <summary>
        /// Method performing a mouse click action on an IWebElement element and wait page with specific title.
        /// </summary>
        /// <param name="driver">IWebDriver provided.</param>
        /// <param name="element">IWebElement element that receives the click action.</param>
        /// <param name="title">The new page title expected after click action.</param>
        /// <param name="timespan">The maximum time to wait for the page title.</param>
        public static void ClickAndWait(this IWebDriver driver, IWebElement element, string title, int timespan = 5)
        {
            try
            {
                var action = new OpenQA.Selenium.Interactions.Actions(driver);
                var wait   = new WebDriverWait(driver, TimeSpan.FromSeconds(timespan));

                action.MoveToElement(element);
                action.MoveToElement(element).Click();
                action.Build().Perform();

                wait.Until(d => d.Title.Equals(title, StringComparison.CurrentCultureIgnoreCase));
            }
            catch (Exception e)
            {
                throw new InternalActionException(string.Format("Unable to click on object \"{0}\" or wait for new title \"{1}\".\r\nSee:\r\n\t- {2}{3}", element, title,
                                                                e.Message, (e.InnerException == null ? "" : string.Format("\r\n\t- {0}", e.InnerException.Message))), e);
            }
        }
        public void SubmitUserDetails()
        {
            Wait.Until(ElementExtensions.ElementToBeClickable(Objects.Pages.CreateBuyerUser.CreateUser));
            var element = Driver.FindElement(Objects.Pages.CreateBuyerUser.CreateUser);
            var actions = new OpenQA.Selenium.Interactions.Actions(Driver);

            actions.MoveToElement(element);
            actions.Perform();
            element.Click();
        }
Esempio n. 29
0
        public bool MouseOver(string locator, IWebDriver driver)
        {
            Helper.HighlightElement(driver, driver.FindElement(By.XPath(locator)));
            var action = new OpenQA.Selenium.Interactions.Actions(driver);

            _elementselected = driver.FindElement(By.XPath(locator));
            ((IJavaScriptExecutor)driver).ExecuteScript("arguments[0].scrollIntoView(true);", _elementselected);
            action.MoveToElement(_elementselected).Perform();
            return(true);
        }
Esempio n. 30
0
        private void Statsdropdownscroll()
        {
            var DropDown = driver.FindElement(By.XPath("/html/body/div[1]/section/myapp/section/div/div/div/div/section/component/div[2]/div/div/div/div/div[2]/div[1]/div[1]/div/div/div[2]/ul/li[13]"));
            var action1  = new OpenQA.Selenium.Interactions.Actions(driver);

            ((IJavaScriptExecutor)driver).ExecuteScript("window.scrollTo(document.body.scrollHeight, 0)");
            action1.MoveToElement(DropDown);
            action1.Perform();
            DropDown = new WebDriverWait(driver, new TimeSpan(0, 1, 0))
                       .Until(driver => driver.FindElement(By.XPath("/html/body/div[1]/section/myapp/section/div/div/div/div/section/component/div[2]/div/div/div/div/div[2]/div[1]/div[1]/div/div/div[2]/ul/li[13]")));
        }
Esempio n. 31
0
        private void TeamsLogo()
        {
            var Logo    = driver.FindElement(By.CssSelector(".teams-logo"));
            var action1 = new OpenQA.Selenium.Interactions.Actions(driver);

            ((IJavaScriptExecutor)driver).ExecuteScript("window.scrollTo(document.body.scrollHeight, 0)");
            action1.MoveToElement(Logo);
            action1.Perform();
            Logo = new WebDriverWait(driver, new TimeSpan(0, 1, 0))
                   .Until(driver => driver.FindElement(By.CssSelector(".teams-logo")));
        }
Esempio n. 32
0
        private void Teamtracker()
        {
            var tracker = driver.FindElement(By.XPath("/html/body/div[1]/section/myapp/section[7]/div/div/div/div/section/component/div[1]/h2"));
            var action1 = new OpenQA.Selenium.Interactions.Actions(driver);

            ((IJavaScriptExecutor)driver).ExecuteScript("window.scrollTo(document.body.scrollHeight, 0)");
            action1.MoveToElement(tracker);
            action1.Perform();
            tracker = new WebDriverWait(driver, new TimeSpan(0, 1, 0))
                      .Until(driver => driver.FindElement(By.XPath("/html/body/div[1]/section/myapp/section[7]/div/div/div/div/section/component/div[1]/h2")));
        }
Esempio n. 33
0
        public void upLoad()
        {
            //Thread.Sleep(3000);
            //driver.FindElement(By.CssSelector("a.menuBtn_upload")).Click();
            //driver.FindElement(By.CssSelector("#a-pw_add > span.icontxt")).Click();
            //Thread.Sleep(1000);
            //Thread x = new Thread(new ThreadStart(Upload_File));
            //x.Start();
            //Thread.Sleep(1000);
            //driver.FindElement(By.CssSelector("table.table-pw_next a.btn_upload")).Click();
            //Thread.Sleep(2000);

            ////如果进度元素不是显示100,那么继续上传
            //if (driver.FindElement(By.XPath("//[@id='efaf3e61-c983-4dc3-9622-436d51d5a88c']/sapn[3]")).Text.Contains()!=100)
            //{

            //}

            //下载
            Thread.Sleep(1000);
            //driver.FindElement(By.XPath("//ul[@id='commandList']/li/table/tbody/tr/td/div/span")).Click();
            ////driver.FindElement(By.CssSelector("div.fileCommand span.MixiTai_Checkbox")).Click();
            ////driver.FindElement(By.XPath("//ul[@id='commandList']/li[1]/table/tbody/tr/td[2]/div/table/tbody/tr[2]/td/span")).Click();
            //driver.FindElement(By.XPath("(//input[@value='Open'])")).Click();
            ////driver.FindElement(By.CssSelector("a.option_Open")).Click();
            //Thread.Sleep(100);
            ////driver.FindElement(By.CssSelector("div.fileCommand span.MixiTai_Checkbox")).Click();
            //driver.FindElement(By.XPath("//ul[@id='commandList']/li/table/tbody/tr/td/div/span")).Click();
            //Thread.Sleep(100);
            //driver.FindElement(By.XPath("(//input[@value='Open'])")).Click();
            ////driver.FindElement(By.CssSelector("a.menuBtn_return > span.icontxt")).Click();
            //driver.FindElement(By.XPath("//ul[@id='commandList']/li[2]/table/tbody/tr/td[2]/div/table/tbody/tr[2]/td/span")).Click();
            //driver.FindElement(By.XPath("(//input[@value='Open'])[2]")).Click();
            //driver.FindElement(By.CssSelector("a.menuBtn_downLoad > span.icontxt")).Click();
            //driver.FindElement(By.CssSelector("a.menuBtn_downLoad > span.icontxt")).Click();
            //driver.FindElement(By.XPath("//div[@id='FilesView']/div[3]/a/span")).Click();

            var openFolderTableElement =
                driver.FindElement(
                    By.CssSelector("table[data-name='Angkor']"));

            var mouseOverAction = new OpenQA.Selenium.Interactions.Actions(driver);
            mouseOverAction.MoveToElement(openFolderTableElement);
            //notice: Actions必须要执行perform
            mouseOverAction.Perform();
            openFolderTableElement.FindElement(By.CssSelector("div.menuBtn a.option_Open")).Click();

            Thread.Sleep(1000);
            var openFileTableElement =
                driver.FindElement(
                    By.CssSelector("table[data-name='AppCertKitArmSetup.exe']"));

            var mouseOverAction1 = new OpenQA.Selenium.Interactions.Actions(driver);
            mouseOverAction1.MoveToElement(openFileTableElement);
            //notice: Actions必须要执行perform
            mouseOverAction1.Perform();
            openFileTableElement.FindElement(By.CssSelector("div.menuBtn a.option_Open")).Click();
            //driver.FindElement(By.LinkText("Download File")).Click();
            driver.FindElement(By.CssSelector("a.menuBtn_downLoad")).Click();
            Thread.Sleep(1000);
            var auto = new AutoItX3();
            //auto.Send("{BROWSE}");
            //Thread.Sleep(1000);

            //auto.Send("{TAB}");
            //auto.Send("{TAB}");
            //auto.Send("{ENTER}");
            Thread.Sleep(1000);
            const string widowTitle = "[Class:#32770]";
            auto.ControlFocus(widowTitle, "Choose Download Folder:", "[CLASS:Edit; INSTANCE:1]");
            auto.Send(@"C:");
            auto.ControlClick(widowTitle, "Choose Download Folder", "[CLASS:Button; INSTANCE:1]");
            auto.Send("{ENTER}");
            Thread.Sleep(5000);

            //driver.FindElement(By.LinkText("退出")).Click();
        }
Esempio n. 34
0
        /// <summary>
        /// Метод реализует действие наведения указателя мыши
        /// </summary>
        public void MouseOverNoHover()
        {
            OpenQA.Selenium.Interactions.Actions builder = new OpenQA.Selenium.Interactions.Actions(BitrixFramework.WebDriver);
            builder.MoveToElement(BitrixFramework.FindWebElement(this)).Build().Perform();

            Log.MesNormal(String.Format("'{0}' -> Наведение указателя мыши", description));

            //проверяем страницу на наличие ошибок
            BitrixFramework.CheckJSErrors();
        }
Esempio n. 35
0
        /// <summary>
        /// Клик по WebItem. Аналог WebDriver.Click()
        /// После клика ждет заданное количество времени. Опционально, по умолчанию 1 секунда.
        /// </summary>
        /// <param name="secondsToWait">Время ожидания, секунд</param>
        /// <param name="ScrollToObject">Меняет скроллирование до объекта(по умолчанию: отключено для админской части и включено для публичной)
        /// Соответственно true включает скролл в адимнке и выключает в публичке</param>
        /// <param name="checkErrors">Проверить наличие ошибок. По умолчанию true - проверить</param>
        /// <param name="x">координата x для клика относительно верхнего левого угла объекта</param>
        /// <param name="y">координата y для клика относительно верхнего левого угла объекта</param>
        /// <param name="NoRefresh"> Если задан - рефреш страницы при зависании не производится</param>
        public void ClickAndWait(double secondsToWait = 0.5, bool ScrollToObject = true, bool checkErrors = true, int x = 0, int y = 0, bool NoRefresh = false)
        {
            if (ScrollToObject)
                BitrixFramework.ScrollOnCoords(this);

            if (x != 0 && y != 0)
            {
                OpenQA.Selenium.Interactions.Actions builder = new OpenQA.Selenium.Interactions.Actions(BitrixFramework.WebDriver);
                builder.MoveToElement(BitrixFramework.FindWebElement(this), x, y).Click().Build().Perform();
            }
            else
            {
                try
                {
                    BitrixFramework.FindWebElement(this).Click();
                }
                catch (NullReferenceException)
                {
                    Log.MesError("Не найден объект \"" + this.description + "\" по пути \"" + this.by.ToString() + "\"");
                    throw;
                }
                catch (StaleElementReferenceException)
                {
                    Log.MesQuestion("Изменился DOM страницы, и элемента " + this.description + " больше нет в кеше. Подождем 5 сек и попробуем найти его ещё разок");
                    BitrixFramework.Wait(5);
                    try
                    {
                        BitrixFramework.FindWebElement(this).Click();
                    }
                    catch
                    {
                        Log.MesError("Не найден объект \"" + this.description + "\" по пути \"" + this.by.ToString() + "\"");
                        throw;
                    }
                }
                catch (OpenQA.Selenium.WebDriverException e)
                {
                    Log.MesQuestion("Висит страница \r\nMessage: " + e.Message + "\r\nStackTrace: " + e.StackTrace + "\r\n<a href=\"" + ScreenCapture.Printscreen() + "\">скриншот</a>");
                    if(!NoRefresh)
                        BitrixFramework.Refresh();
                    BitrixFramework.Wait(5);
                }
            }
            Log.MesNormal(String.Format("'{0}' -> Клик", description));

            System.Threading.Thread.Sleep(Convert.ToInt32(secondsToWait * 1000));
            if (checkErrors)
            {
                BitrixFramework.CheckJSErrors();
                GM.CheckContentOnErrors();
            }
        }