コード例 #1
0
        public void Mouse_click_will_fail_because_hidden_link_is_matched_instead_of_visible_link()
        {
            // Playback.PlaybackSettings.SmartMatchOptions = SmartMatchOptions.None; // tried Sudhish Mathuria's suggestion

            var example2Path = Path.Combine(TestContext.TestDeploymentDir, "example2.htm");

            var window = BrowserWindow.Launch(example2Path);

            var document = new HtmlDocument(window);
            document.FilterProperties[HtmlDocument.PropertyNames.Title] = "2ad6de55-75f1-403f-8fcb-1d5defac9786";

            var visibleLink = new HtmlHyperlink(document);
            visibleLink.SearchProperties[HtmlHyperlink.PropertyNames.InnerText] = "Hello";

            // ONLY FIND VISIBLE CONTROLS !
            visibleLink.SearchConfigurations.Add(SearchConfiguration.VisibleOnly);

            var allMatches = visibleLink.FindMatchingControls();
            Assert.AreEqual(2, allMatches.Count, "Should be two matching.");

            visibleLink.Find(); // THIS SHOULD BE THE VISIBLE ONE

            Debug.WriteLine("BoundingRectangle: " + visibleLink.BoundingRectangle);
            Assert.IsTrue(visibleLink.BoundingRectangle.Width > 0, "Width should positive.");
            Assert.IsTrue(visibleLink.BoundingRectangle.Height > 0, "Height should positive.");

            Mouse.Click(visibleLink);
        }
コード例 #2
0
        public void Mouse_click_will_fail_because_hidden_link_is_matched_instead_of_visible_link()
        {
            // Playback.PlaybackSettings.SmartMatchOptions = SmartMatchOptions.None; // tried Sudhish Mathuria's suggestion

            var example2Path = Path.Combine(TestContext.TestDeploymentDir, "example2.htm");

            var window = BrowserWindow.Launch(example2Path);

            var document = new HtmlDocument(window);

            document.FilterProperties[HtmlDocument.PropertyNames.Title] = "2ad6de55-75f1-403f-8fcb-1d5defac9786";

            var visibleLink = new HtmlHyperlink(document);

            visibleLink.SearchProperties[HtmlHyperlink.PropertyNames.InnerText] = "Hello";

            // ONLY FIND VISIBLE CONTROLS !
            visibleLink.SearchConfigurations.Add(SearchConfiguration.VisibleOnly);

            var allMatches = visibleLink.FindMatchingControls();

            Assert.AreEqual(2, allMatches.Count, "Should be two matching.");

            visibleLink.Find(); // THIS SHOULD BE THE VISIBLE ONE

            Debug.WriteLine("BoundingRectangle: " + visibleLink.BoundingRectangle);
            Assert.IsTrue(visibleLink.BoundingRectangle.Width > 0, "Width should positive.");
            Assert.IsTrue(visibleLink.BoundingRectangle.Height > 0, "Height should positive.");

            Mouse.Click(visibleLink);
        }
コード例 #3
0
        public static UITestControlCollection GetAllHtmlLinkControls()
        {
            var link = new HtmlHyperlink(browserWindow);

            link.SearchProperties.Add(CSVReader.ControlType + ".PropertyNames." + CSVReader.LocatorType, CSVReader.LocatorValue);

            var controlCollection = link.FindMatchingControls();

            return(controlCollection);
        }
コード例 #4
0
        public HtmlHyperlink ClickLinkByClassForColumnName(string parentfname, string sclass, int pause = 0)
        {
            HtmlHyperlink button = new HtmlHyperlink(BrowserWindow);

            button.SearchProperties[HtmlEdit.PropertyNames.Class]   = sclass;
            button.SearchProperties[HtmlEdit.PropertyNames.TagName] = "A";
            button = button.FindMatchingControls().Where(x => x.Enabled == true)
                     .First(x => x.GetParent().FriendlyName == parentfname) as HtmlHyperlink;
            Mouse.Click(button);
            Thread.Sleep(pause);
            return(button);
        }
コード例 #5
0
        private HtmlHyperlink FindHyperlinkForFirstProduct(HtmlControl productList)
        {
            HtmlHyperlink hyperlink         = new HtmlHyperlink(productList);
            var           productHyperlinks = hyperlink.FindMatchingControls();

            if (productHyperlinks.Count > 0)
            {
                return(productHyperlinks[0] as HtmlHyperlink);
            }
            else
            {
                return(null);
            }
        }
コード例 #6
0
        public void CodedUITestMethod1()
        {
            int           value  = 1;
            BrowserWindow window = BrowserWindow.Launch("http://automationpractice.com/index.php");

            Thread.Sleep(3000);
            HtmlDiv dresslinkParent = new HtmlDiv(window);

            dresslinkParent.SearchProperties.Add(HtmlDiv.PropertyNames.Id, "block_top_menu");
            //dresslinkParent.DrawHighlight();
            HtmlHyperlink DressesLink = new HtmlHyperlink(dresslinkParent);

            //DressesLink.SearchProperties.Add(HtmlHyperlink.PropertyNames.TagName, "A");
            DressesLink.SearchProperties[HtmlHyperlink.PropertyNames.InnerText] = "Dresses";
            //this.mUIDressesHyperlink.FilterProperties[HtmlHyperlink.PropertyNames.AbsolutePath] = "/index.php";
            //this.mUIDressesHyperlink.FilterProperties[HtmlHyperlink.PropertyNames.Title] = "Dresses";
            DressesLink.SearchProperties.Add(HtmlHyperlink.PropertyNames.Title, "Dresses");
            var col = DressesLink.FindMatchingControls();

            //col[1].DrawHighlight();
            Mouse.Hover(col[1]);
            Thread.Sleep(1000);
            HtmlHyperlink summerDresses = new HtmlHyperlink(dresslinkParent);

            summerDresses.SearchProperties.Add(HtmlHyperlink.PropertyNames.TagName, "A");
            summerDresses.SearchProperties.Add(HtmlHyperlink.PropertyNames.InnerText, "Summer Dresses".ToUpper());
            col = summerDresses.FindMatchingControls();
            //col[0].DrawHighlight();
            //col[1].DrawHighlight();
            Mouse.Click(col[1]);

            HtmlCheckBox checkbog = new HtmlCheckBox(window);

            checkbog.SearchProperties.Add(HtmlCheckBox.PropertyNames.Id, "layered_id_attribute_group_1");
            if (checkbog.Checked == false)
            {
                checkbog.Checked = true;
            }


            HtmlComboBox combobo = new HtmlComboBox();

            combobo.SelectedItem = "value";
            HtmlRadioButton butt = new HtmlRadioButton();

            butt.Selected = false;
            butt.WaitForControlEnabled();
        }
コード例 #7
0
        // To click on specific hyperlink based on the property from a list of hidden hyperlink controls
        public void clickHTMLHyperlinkFromHiddenControlsOneProp(string strControl)
        {
            Keywords      KeyFound       = reader.FindControlinList(strControl);
            BrowserWindow _browser       = new BrowserWindow();
            HtmlHyperlink _htmlHyperlink = new HtmlHyperlink(_browser);

            _htmlHyperlink.SearchProperties[KeyFound.PropertyName1] = KeyFound.PropertyValue1;
            _htmlHyperlink.WaitForControlExist();
            UITestControlCollection _uitestControlCollection = _htmlHyperlink.FindMatchingControls();

            foreach (UITestControl _uitestControl in _uitestControlCollection)
            {
                if (_uitestControl.BoundingRectangle.Width > 0)
                {
                    Mouse.Click(_uitestControl);
                    break;
                }
            }
        }
コード例 #8
0
ファイル: Actions.cs プロジェクト: k3foru/CUIT_Framework
        public static UITestControlCollection GetAllHtmlLinkControls()
        {
            var link = new HtmlHyperlink(browserWindow);
            link.SearchProperties.Add(CSVReader.ControlType + ".PropertyNames." + CSVReader.LocatorType, CSVReader.LocatorValue);

            var controlCollection = link.FindMatchingControls();
            return controlCollection;
        }