コード例 #1
0
 public void VerifyRegistrationWidgetAndProfileWidgetOnPreviewBootstrapTemplate()
 {
     RuntimeSettingsModificator.ExecuteWithClientTimeout(800000, () => BAT.Macros().NavigateTo().CustomPage("~/sitefinity/pages", false));
     RuntimeSettingsModificator.ExecuteWithClientTimeout(800000, () => BAT.Macros().User().EnsureAdminLoggedIn());
     BAT.Macros().NavigateTo().Design().PageTemplates(this.Culture);
     BAT.Wrappers().Backend().PageTemplates().PageTemplateMainScreen().OpenTemplateEditor(TemplateTitle);
     BATFeather.Wrappers().Backend().Pages().PageZoneEditorWrapper().AddWidgetToPlaceHolderPureMvcMode(ProfileWidget, PlaceHolderId);
     BATFeather.Wrappers().Backend().Pages().PageZoneEditorWrapper().AddWidgetToPlaceHolderPureMvcMode(RegistrationWidget, PlaceHolderId);
     BAT.Wrappers().Backend().PageTemplates().PageTemplateModifyScreen().PreviewTemplateFromEdit();
     ActiveBrowser.WaitUntilReady();
     ////Verify save changes message for Profile widget in Preview mode
     BATFeather.Wrappers().Frontend().Identity().ProfileWrapper().SaveChangesButton();
     Assert.IsTrue(ActiveBrowser.ContainsText(MessageSaveChangesProfileWidget), "Message was not found on the page");
     ////Verify all required fields message for Registration widget in Preview mode
     BATFeather.Wrappers().Frontend().Identity().RegistrationWrapper().RegisterButton();
     BATFeather.Wrappers().Frontend().Identity().RegistrationWrapper().AssertEmptyEmailFieldMessage();
     BATFeather.Wrappers().Frontend().Identity().RegistrationWrapper().AssertEmptyUsernameFieldMessage();
     BATFeather.Wrappers().Frontend().Identity().RegistrationWrapper().AssertEmptyPasswordFieldMessage();
     ////Verify successful message for Registration widget in Preview mode
     BATFeather.Wrappers().Frontend().Identity().RegistrationWrapper().FillEmail(Email);
     BATFeather.Wrappers().Frontend().Identity().RegistrationWrapper().FillUserName(UserName);
     BATFeather.Wrappers().Frontend().Identity().RegistrationWrapper().FillPassword(Password);
     BATFeather.Wrappers().Frontend().Identity().RegistrationWrapper().FillRetypePassword(Password);
     BATFeather.Wrappers().Frontend().Identity().RegistrationWrapper().RegisterButton();
     ActiveBrowser.WaitForElement("TextContent=~Thank you!");
     BATFeather.Wrappers().Frontend().Identity().RegistrationWrapper().VerifySuccessfullyMessage();
     BAT.Wrappers().Backend().Preview().RealPreviewWrapper().CloseBrowserWithPreview();
     BAT.Wrappers().Backend().Pages().PageZoneEditorWrapper().SelectExtraOptionForWidget(OperationNameDelete);
     BAT.Wrappers().Backend().Pages().PageZoneEditorWrapper().SelectExtraOptionForWidget(OperationNameDelete);
     BAT.Wrappers().Backend().PageTemplates().PageTemplateModifyScreen().PublishTemplate();
 }
コード例 #2
0
        public void WaitingForMultiplePageChanges()
        {
            // Using the same example above but instead of only waiting for the new div by checking the h3
            // element and then we want to also wait for the backcolor of the div to change to red.

            // Wait for the h3 to be added.
            HtmlFindExpression h3 = new HtmlFindExpression("TagIndex=h3:0"); // Basically the first occurrence of an h3 element.

            // Wait for the div with index=1 to appear in addition to the style having partial value:
            // background-color: red
            HtmlFindExpression newDiv = new HtmlFindExpression("TagIndex=div:1", "style=~background-color: red");

            // Invoke the action
            Actions.Click(this.Elements.GetHtml("activationDiv"));

            // Wait for all changes using a chained Find Expression
            HtmlFindExpression expr = new HtmlFindExpression();

            expr.AppendClauses(false, newDiv.Clauses);
            expr.AppendChain(h3);
            ActiveBrowser.WaitForElement(expr, 4000, false);

            // All elements should be found at this point. To verify.
            ActiveBrowser.RefreshDomTree();

            Element h3Element = Find.ByExpression(h3); // find the element

            Assert.IsTrue(h3Element.InnerText.Equals("We are back!"));

            Element newDivElement = Find.ByExpression(newDiv);

            Assert.IsTrue(newDivElement.GetAttribute("style").Value.ToLower().
                          Contains("background-color: red"));
        }
コード例 #3
0
        /// <summary>
        /// Set To date by date picker to custom date selector
        /// </summary>
        /// <param name="dayForward">Day forward</param>
        public void SetToDateByDatePicker(int dayForward)
        {
            DateTime publicationDateEnd       = DateTime.UtcNow.AddDays(dayForward);
            string   publicationDateEndFormat = publicationDateEnd.ToString("dd", CultureInfo.CreateSpecificCulture("en-US"));

            List <HtmlSpan> buttonDate = ActiveBrowser.Find.AllByExpression <HtmlSpan>("tagname=span", "class=input-group-btn").ToList <HtmlSpan>();

            Manager.Current.Desktop.Mouse.Click(MouseClickType.LeftClick, buttonDate[1].GetRectangle());

            HtmlFindExpression expression = new HtmlFindExpression("tagname=table", "role=grid");

            ActiveBrowser.WaitForElement(expression, 60000, false);

            List <HtmlTable>     dateTable = ActiveBrowser.Find.AllByExpression <HtmlTable>("tagname=table", "role=grid").ToList <HtmlTable>();
            List <HtmlTableCell> toDay     = dateTable[0].Find.AllByExpression <HtmlTableCell>("tagname=td", "InnerText=" + publicationDateEndFormat).ToList <HtmlTableCell>();
            HtmlButton           buttonToDay;

            if (toDay.Count == 2)
            {
                buttonToDay = toDay[1].Find.ByExpression <HtmlButton>("tagname=button");

                if (buttonToDay == null)
                {
                    buttonToDay = toDay[0].Find.ByExpression <HtmlButton>("tagname=button");
                }
            }
            else
            {
                buttonToDay = toDay[0].Find.ByExpression <HtmlButton>("tagname=button");
            }

            Manager.Current.Desktop.Mouse.Click(MouseClickType.LeftClick, buttonToDay.GetRectangle());
            Manager.Current.ActiveBrowser.WaitUntilReady();
        }
コード例 #4
0
        public void WaitingForSinglePageChange()
        {
            // The test page performs two operations async; each with 1 second delay
            // after the box is clicked:
            // 1.Creates a new Div with a child H3 element and adds it to the page.
            // 2.Changes the back color of the new div to red

            // Let's invoke the actions and wait for the H3 element to appear.

            // To do so, we will simply use the FindExpression object as described in FindingElements.cs
            // to define how an element should be identified.
            HtmlFindExpression h3 = new HtmlFindExpression("TagIndex=h3:0"); // Basically the first occurrence of an h3 element.

            // Initiate the action.
            Actions.Click(this.Elements.GetHtml("activationDiv"));

            // Wait for the element to appear on the page. Timeout: 2 seconds.
            ActiveBrowser.WaitForElement(h3, 3000, false);

            // Element should be found at this point. To verify.
            ActiveBrowser.RefreshDomTree();            // refresh the current DOM to reflect the javascript changes
            Element h3Element = Find.ByExpression(h3); // find the element

            Assert.IsTrue(h3Element.InnerText.Equals("We are back!"));
        }
コード例 #5
0
        /// <summary>
        /// Edit widget by name
        /// </summary>
        /// <param name="widgetName">The widget name</param>
        /// <param name="dropZoneIndex">The drop zone index</param>
        public void EditWidget(string widgetName, int dropZoneIndex = 0, bool isMediaWidgetEdited = false)
        {
            ActiveBrowser.WaitUntilReady();
            ActiveBrowser.RefreshDomTree();
            ActiveBrowser.WaitUntilReady();
            var widgetHeader = ActiveBrowser
                               .Find
                               .AllByCustom <HtmlDiv>(d => d.CssClass.StartsWith("rdTitleBar") && d.ChildNodes.First().InnerText.Equals(widgetName))[dropZoneIndex]
                               .AssertIsPresent(widgetName);

            widgetHeader.ScrollToVisible();
            HtmlAnchor editLink = widgetHeader.Find
                                  .ByCustom <HtmlAnchor>(a => a.TagName == "a" && a.Title.Equals("Edit"))
                                  .AssertIsPresent("edit link");

            editLink.Focus();
            editLink.Click();
            ActiveBrowser.WaitUntilReady();
            ActiveBrowser.WaitForAsyncOperations();
            ActiveBrowser.WaitForAjax(TimeOut);
            ActiveBrowser.RefreshDomTree();

            if (!isMediaWidgetEdited)
            {
                HtmlFindExpression expression = new HtmlFindExpression("class=modal-title", "InnerText=" + widgetName);
                ActiveBrowser.WaitForElement(expression, TimeOut, false);
                Manager.Current.Wait.For(this.WaitForSaveButton, TimeOut);
            }
        }
コード例 #6
0
        /// <summary>
        /// Verifies the tips.
        /// </summary>
        /// <param name="text">The text.</param>
        public void VerifyTips(string text)
        {
            HtmlFindExpression expression = new HtmlFindExpression("tagname=a", "sf-popover-title=Tips");

            ActiveBrowser.WaitForElement(expression, 60000, false);
            ActiveBrowser.Find.ByExpression <HtmlAnchor>("tagname=a", "sf-popover-title=Tips", "sf-popover-content=~" + text).AssertIsPresent("Tips");
        }
コード例 #7
0
 /// <summary>
 /// Waits the until image is loaded.
 /// </summary>
 public void WaitUntilImageIsLoaded()
 {
     ActiveBrowser.WaitForElement("tagName=button", "InnerText=~Change");
     Manager.Current.Wait.For(() => {
         this.ActiveBrowser.RefreshDomTree();
         return(this.EM.Media.ImagePropertiesScreen.ChangeButton.IsVisible());
     });
 }
コード例 #8
0
        /// <summary>
        /// Selects the radio button option.
        /// </summary>
        /// <param name="optionId">The option id.</param>
        public void SelectRadioButtonOption(TagsRadioButtonIds optionId)
        {
            ActiveBrowser.WaitForElement(new HtmlFindExpression("tagname=input", "id=" + optionId));
            HtmlInputRadioButton radioButton = ActiveBrowser.Find.ByExpression <HtmlInputRadioButton>("tagname=input", "id=" + optionId)
                                               .AssertIsPresent("radio button");

            radioButton.Click();
        }
コード例 #9
0
        /// <summary>
        /// Verifies the checked radio button option.
        /// </summary>
        /// <param name="optionId">The option id.</param>
        public void VerifyCheckedRadioButtonOption(TagsRadioButtonIds optionId)
        {
            ActiveBrowser.WaitForElement("tagname=input", "id=" + optionId);
            HtmlInputRadioButton radioButton = ActiveBrowser.Find.ByExpression <HtmlInputRadioButton>("tagname=input", "id=" + optionId)
                                               .AssertIsPresent("radio button");

            Assert.IsTrue(radioButton.Checked);
        }
コード例 #10
0
        /// <summary>
        /// Verifies the checked radio button option.
        /// </summary>
        /// <param name="optionId">The option id.</param>
        public void VerifyCheckedRadioButtonOption(WidgetDesignerRadioButtonIds optionId)
        {
            HtmlFindExpression expression = new HtmlFindExpression("tagname=input", "id=" + optionId);

            ActiveBrowser.WaitForElement(expression, 60000, false);
            HtmlInputRadioButton radioButton = ActiveBrowser.Find.ByExpression <HtmlInputRadioButton>("tagname=input", "id=" + optionId)
                                               .AssertIsPresent("radio button");

            Assert.IsTrue(radioButton.Checked);
        }
コード例 #11
0
        /// <summary>
        /// Checks if document or image title is populated correctly.
        /// </summary>
        /// <param name="imageTitle">The document or image title.</param>
        /// <returns>true or false depending on the document or image  title in the textbox.</returns>
        public bool IsTitlePopulated(string imageTitle)
        {
            HtmlFindExpression expression = new HtmlFindExpression("tagName=input", "name=title");

            ActiveBrowser.WaitForElement(expression, 30000, false);

            HtmlInputText titleField = this.EM.Media.MediaPropertiesBaseScreen.TitleField
                                       .AssertIsPresent("title field");

            return(imageTitle.Equals(titleField.Text));
        }
コード例 #12
0
        /// <summary>
        /// Verifies the selected option in aspect ratio selector
        /// </summary>
        /// <param name="option">The aspect ratio option.</param>
        public void VerifySelectedOptionAspectRatioSelector(string option)
        {
            HtmlFindExpression expression = new HtmlFindExpression("tagName=select", "ng-model=model.aspectRatio");

            ActiveBrowser.WaitForElement(expression, 60000, false);

            HtmlSelect selector = this.EM.Media.VideoPropertiesScreen.AspectRatioSelector
                                  .AssertIsPresent("aspect ration selector");

            Assert.AreEqual(option, selector.SelectedOption.Text);
        }
コード例 #13
0
        /// <summary>
        /// Verifies the image thumbnail.
        /// </summary>
        /// <param name="altText">The alt text.</param>
        /// <param name="src">The SRC.</param>
        public void VerifyImageThumbnail(string altText, string src)
        {
            ActiveBrowser.WaitForAjax(10000);
            ActiveBrowser.WaitUntilReady();
            ActiveBrowser.RefreshDomTree();
            ActiveBrowser.WaitForElement("tagname=img", "alt=~" + altText);

            HtmlImage image = ActiveBrowser.Find.ByExpression <HtmlImage>("alt=~" + altText)
                              .AssertIsPresent(altText);

            Assert.IsTrue(image.Src.Contains(src), "src is not correct");
        }
コード例 #14
0
        /// <summary>
        /// Verifies the image resizing properties.
        /// </summary>
        /// <param name="altText">The alt text.</param>
        /// <param name="src">The SRC.</param>
        public void VerifyImageResizingProperties(string altText, string srcWidth, string srcHeight, string srcQuality, string srcResizingOption)
        {
            ActiveBrowser.WaitForAjax(10000);
            ActiveBrowser.WaitUntilReady();
            ActiveBrowser.RefreshDomTree();
            ActiveBrowser.WaitForElement("tagname=img", "alt=~" + altText);

            HtmlImage image = ActiveBrowser.Find.ByExpression <HtmlImage>("alt=~" + altText)
                              .AssertIsPresent(altText);

            Assert.IsTrue(image.Src.Contains(srcWidth) && image.Src.Contains(srcHeight) && image.Src.Contains(srcQuality) && image.Src.Contains(srcResizingOption), "src is not correct");
        }
コード例 #15
0
        /// <summary>
        /// Selects option from thumbnail selector.
        /// </summary>
        /// <param name="optionValue">Option value.</param>
        public void SelectResizeImageOption(string optionValue)
        {
            HtmlFindExpression expression = new HtmlFindExpression("class=modal-title", "InnerText=Custom thumbnail size");

            ActiveBrowser.WaitForElement(expression, 30000, false);

            HtmlSelect selector = this.EM.Media.ImagePropertiesScreen.ResizeImageSelector
                                  .AssertIsPresent("resize image selector");

            selector.SelectByText(optionValue);
            selector.AsjQueryControl().InvokejQueryEvent(jQueryControl.jQueryControlEvents.click);
            selector.AsjQueryControl().InvokejQueryEvent(jQueryControl.jQueryControlEvents.change);
        }
コード例 #16
0
        /// <summary>
        /// Verifies the video info.
        /// </summary>
        /// <param name="title">The title.</param>
        /// <param name="type">The type.</param>
        /// <param name="size">The size.</param>
        public void VerifyVideoInfo(string title, string type, string size)
        {
            DateTime           dateTime   = DateTime.Now;
            var                date       = dateTime.Date;
            CultureInfo        ci         = CultureInfo.InvariantCulture;
            var                dateString = date.ToString("M/d/yyyy", ci);
            HtmlFindExpression expression = new HtmlFindExpression("ng-bind=sfMedia.Title.Value", "innertext=" + title);

            ActiveBrowser.WaitForElement(expression, 60000, false);
            ActiveBrowser.Find.ByExpression <HtmlSpan>("ng-bind=sfMedia.Title.Value", "innertext=" + title).AssertIsPresent("title");
            ActiveBrowser.Find.ByExpression <HtmlSpan>("ng-bind=sfMedia.Extension", "innertext=" + type).AssertIsPresent("type");
            ActiveBrowser.Find.ByExpression <HtmlSpan>("ng-bind=mediaSize", "innertext=" + size).AssertIsPresent("size");
            ActiveBrowser.Find.ByExpression <HtmlSpan>("ng-bind=uploaded | date : 'M/d/yyyy h:mm'", "innertext=~" + dateString).AssertIsPresent("date");
        }
コード例 #17
0
        private HtmlDiv GetSocialShareOptionDivByName(string optionName)
        {
            HtmlFindExpression socialShareDivFindExpression = new HtmlFindExpression("class=checkbox ng-scope", "ng-repeat=group in socialGroups.Groups", "InnerText=" + optionName);
            HtmlDiv            socialShareOptionDiv         = ActiveBrowser.WaitForElement(socialShareDivFindExpression, TimeOut, false).As <HtmlDiv>();

            if (socialShareOptionDiv != null && socialShareOptionDiv.IsVisible())
            {
                return(socialShareOptionDiv);
            }
            else
            {
                throw new ArgumentException("Social share option div was not found");
            }
        }
コード例 #18
0
        /// <summary>
        /// Verifies the video.
        /// </summary>
        /// <param name="src">The SRC.</param>
        /// <param name="width">The width.</param>
        /// <param name="height">The height.</param>
        public void VerifyVideo(string src, int width = 0, int height = 0)
        {
            HtmlFindExpression expression = new HtmlFindExpression("src=~" + src);

            ActiveBrowser.WaitForElement(expression, 60000, false);

            HtmlVideo video = ActiveBrowser.Find.ByExpression <HtmlVideo>("src=~" + src)
                              .AssertIsPresent("video");

            if (width != 0 && height != 0)
            {
                Assert.IsTrue(video.Width.Equals(width), "width is not correct");
                Assert.IsTrue(video.Height.Equals(height), "height is not correct");
            }
        }
コード例 #19
0
        /// <summary>
        /// Verifies the selected value in anchor dropdown.
        /// </summary>
        /// <param name="anchorName">Name of the anchor.</param>
        public void VerifySelectedValueInAnchorDropdown(string anchorName)
        {
            var anchorSelector = EM.GenericContent
                                 .ContentBlockLinkSelector
                                 .AnchorSelector
                                 .AssertIsNotNull("select anchor dropdown");

            if (!anchorSelector.IsVisible())
            {
                HtmlFindExpression expression = new HtmlFindExpression("tagname=select", "ng-model=sfSelectedItem.selectedAnchor");
                ActiveBrowser.WaitForElement(expression, 60000, false);
            }

            Assert.AreEqual(anchorName, anchorSelector.SelectedOption.Text);
        }
コード例 #20
0
        /// <summary>
        /// Provide access to "Create content" link
        /// </summary>
        public void CreateContentLink()
        {
            HtmlAnchor createContent = EM.GenericContent
                                       .ContentBlockWidget
                                       .CreateContent
                                       .AssertIsPresent("Create content");

            createContent.Click();
            ActiveBrowser.WaitUntilReady();
            ActiveBrowser.WaitForAsyncRequests();
            ActiveBrowser.RefreshDomTree();

            HtmlFindExpression expression = new HtmlFindExpression("class=modal-title", "InnerText=ContentBlock");

            ActiveBrowser.WaitForElement(expression, TimeOut, false);
            Manager.Current.Wait.For(this.WaitForSaveButton, Manager.Current.Settings.ClientReadyTimeout);
        }
コード例 #21
0
        /// <summary>
        /// Enters the email.
        /// </summary>
        /// <param name="content">The content.</param>
        public void EnterEmail(string content)
        {
            ActiveBrowser.RefreshDomTree();

            HtmlInputEmail email = EM.GenericContent
                                   .ContentBlockLinkSelector
                                   .Email
                                   .AssertIsNotNull("email address");

            if (!email.IsVisible())
            {
                HtmlFindExpression expression = new HtmlFindExpression("tagname=input", "ng-model=sfSelectedItem.emailAddress");
                ActiveBrowser.WaitForElement(expression, 60000, false);
            }

            email.MouseClick();

            email.Text = string.Empty;
            Manager.Current.Desktop.KeyBoard.TypeText(content);
        }
コード例 #22
0
        /// <summary>
        /// Selects the item.
        /// </summary>
        /// <param name="itemName">Name of the item.</param>
        public void SelectUnselectAllSocialShareOptions(bool isSelectMode = true)
        {
            HtmlFindExpression expression = new HtmlFindExpression("ng-model=group.IsChecked");

            ActiveBrowser.WaitForElement(expression, TimeOut, false);
            var inputs = ActiveBrowser.Find.AllByExpression <HtmlInputCheckBox>("ng-model=group.IsChecked");

            foreach (var input in inputs)
            {
                if (isSelectMode && !input.Checked)
                {
                    input.Click();
                }
                else if (!isSelectMode && input.Checked)
                {
                    input.Click();
                }

                ActiveBrowser.RefreshDomTree();
            }
        }
コード例 #23
0
 public void VerifyRegistrationWidgetAndProfileWidgetOnPreviewHybridPage()
 {
     RuntimeSettingsModificator.ExecuteWithClientTimeout(800000, () => BAT.Macros().User().EnsureAdminLoggedIn());
     RuntimeSettingsModificator.ExecuteWithClientTimeout(800000, () => BAT.Macros().NavigateTo().CustomPage("~/sitefinity/pages", false));
     BAT.Macros().NavigateTo().Pages(this.Culture);
     BAT.Wrappers().Backend().Pages().PagesWrapper().OpenPageZoneEditor(PageTitle);
     BAT.Wrappers().Backend().Pages().PagesWrapper().PreviewPage(PageTitle, isEditMode: true);
     ////Verify save changes message for Profile widget in Preview mode
     BAT.Wrappers().Frontend().Pages().PagesWrapperFrontend().ClickButtonByValue("Save changes");
     Assert.IsTrue(ActiveBrowser.ContainsText(MessageSaveChangesProfileWidget), "Message was not found on the page");
     ////Verify all required fields message for Registration widget in Preview mode
     BAT.Wrappers().Frontend().Pages().PagesWrapperFrontend().ClickButtonByValue("Register");
     BATFeather.Wrappers().Frontend().Identity().RegistrationWrapper().AssertEmptyEmailFieldMessage();
     BATFeather.Wrappers().Frontend().Identity().RegistrationWrapper().AssertEmptyPasswordFieldMessage();
     ////Verify successful message for Registration widget in Preview mode
     BATFeather.Wrappers().Frontend().Identity().RegistrationWrapper().FillEmail(Email);
     BATFeather.Wrappers().Frontend().Identity().RegistrationWrapper().FillPassword(Password);
     BATFeather.Wrappers().Frontend().Identity().RegistrationWrapper().FillRetypePassword(Password);
     BAT.Wrappers().Frontend().Pages().PagesWrapperFrontend().ClickButtonByValue("Register");
     ActiveBrowser.WaitForElement("TextContent=~Thank you!");
     BATFeather.Wrappers().Frontend().Identity().RegistrationWrapper().VerifySuccessfullyMessage();
 }
コード例 #24
0
        public void InvalidLogin()
        {
            // Start browser and navigate to Telerik Academy home page
            Manager.LaunchNewBrowser();
            ActiveBrowser.NavigateTo("http://telerikacademy.com/");

            // Find login button and clik it
            Find.ById <HtmlAnchor>("LoginButton").Click();

            // Wait for User and Password elements
            ActiveBrowser.WaitForElement(new HtmlFindExpression("textcontent=Вход в системата"), 30000, false);

            // Populate user and password
            Find.ById <HtmlInputText>("UsernameOrEmail").Text = "fakeUser";
            Find.ById <HtmlInputPassword>("Password").Text    = "fakePAssword";

            // Click "Вход"
            var exp = new HtmlFindExpression("tagname=input", "value=Вход");

            Find.ByExpression <HtmlInputSubmit>(exp).Click();

            // Verity error message
            Assert.IsTrue(ActiveBrowser.ContainsText("Невалидни данни за достъп!"));
        }
コード例 #25
0
        /// <summary>
        /// Verifies the selectedtag.
        /// </summary>
        /// <param name="tagName">Name of the tag.</param>
        public void VerifySelectedTag(string tagName)
        {
            HtmlFindExpression expression = new HtmlFindExpression("tagname=span", "InnerText=" + tagName);

            ActiveBrowser.WaitForElement(expression, 20000, false);
        }
コード例 #26
0
        public void TestKendo()
        {
            ActiveBrowser.NavigateTo(@"http://www.telerik.com/support/demos");
            int defaultWaitTime      = 2500;
            int expectedColumnsCount = 5;
            int expectedRowsCount    = 21;

            var demosLink = Find.ByExpression <HtmlAnchor>("TextContent=Launch Kendo UI demos", "class=Link--next");

            Assert.IsNotNull(demosLink);
            demosLink.Click();
            ActiveBrowser.WaitForElement(new HtmlFindExpression("XPath=//*[@id=\"widgets-all\"]/ul[1]/li[1]/ul/li[1]/a", "TextContent=Grid"), defaultWaitTime, false);
            Assert.AreEqual("http://demos.telerik.com/kendo-ui/", ActiveBrowser.Url);

            var gridLink = Find.ById <HtmlDiv>("widgets-all").Find.ByContent <HtmlAnchor>("Grid");

            Assert.IsNotNull(gridLink);
            gridLink.Click();

            var initFromTableLink = Find.ById <HtmlDiv>("example-nav").Find.ByContent <HtmlAnchor>("Initialization from table");

            Assert.IsNotNull(initFromTableLink);
            initFromTableLink.Click();

            var expression   = new HtmlFindExpression("id=exampleTitle", "InnerText=~Initialization from table");
            var exampleTitle = ActiveBrowser.WaitForElement(expression, defaultWaitTime, false);

            Assert.IsNotNull(exampleTitle);

            var grid = Find.ById <HtmlDiv>("example");

            Assert.IsNotNull(grid);
            var columnsHeader = grid.Find.ByAttributes <HtmlDiv>("class=k-grid-header-wrap");
            var columnsCount  = columnsHeader.Find.AllByExpression <HtmlControl>("class=k-header", "TagName=th").Count;

            Assert.AreEqual(expectedColumnsCount, columnsCount);

            var rowsCount = grid.Find.ById <HtmlTable>("grid").Find.AllByTagName <HtmlTableRow>("tr").Count;

            Assert.AreEqual(expectedRowsCount, rowsCount);

            var yearHeader = columnsHeader.Find.ByAttributes <HtmlTableCell>("data-field=year");

            yearHeader.Click();
            var sortArrow = ActiveBrowser.WaitForElement(
                defaultWaitTime,
                "xpath=//*[@id='example']/div/div[1]/div/table/thead/tr/th[3]/a/span",
                "class=k-icon k-i-arrow-n");

            Assert.IsNotNull(sortArrow);

            int rowCount     = 1;
            int previousYear = new int();

            do
            {
                var yearCell    = Find.ByXPath <HtmlTableCell>(string.Format("//*[@id='grid']/tbody/tr[{0}]/td[3]", rowCount));
                var currentYear = int.Parse(yearCell.TextContent);
                Assert.IsTrue(previousYear <= currentYear);
                previousYear = currentYear;
                currentYear  = 0;
                rowCount++;
            }while (rowCount < rowsCount);
        }