当前位置: 首页>>代码示例>>C#>>正文


C# Element.GetAttributeValue方法代码示例

本文整理汇总了C#中Element.GetAttributeValue方法的典型用法代码示例。如果您正苦于以下问题:C# Element.GetAttributeValue方法的具体用法?C# Element.GetAttributeValue怎么用?C# Element.GetAttributeValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Element的用法示例。


在下文中一共展示了Element.GetAttributeValue方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: PositionMousePointerInMiddleOfElement

        private static void PositionMousePointerInMiddleOfElement(Element button, Document ie)
        {
            var left = position(button, "Left");
            var width = int.Parse(button.GetAttributeValue("clientWidth"));
            var top = position(button, "Top");
            var height = int.Parse(button.GetAttributeValue("clientHeight"));

            var window = (IHTMLWindow3)((IEDocument)ie.NativeDocument).HtmlDocument.parentWindow;

            left = left + window.screenLeft;
            top = top + window.screenTop;

            var currentPt = new System.Drawing.Point(left + (width / 2), top + (height / 2));
            System.Windows.Forms.Cursor.Position = currentPt;
        }
开发者ID:fschwiet,项目名称:WatiN-2.0.20.1089-net-2.0,代码行数:15,代码来源:PositionMousePointerOnElementTest.cs

示例2: GetAttributeValueOfNullThrowsArgumentNullException

        public void GetAttributeValueOfNullThrowsArgumentNullException()
        {
            // GIVEN
            var nativeElementMock = new Mock<INativeElement>();
            nativeElementMock.Expect(x => x.IsElementReferenceStillValid()).Returns(true);
            var helloButton = new Element(new Mock<DomContainer>().Object, nativeElementMock.Object);

            // WHEN
            helloButton.GetAttributeValue(null);

            // THEN exception
        }
开发者ID:koshdim,项目名称:KoWatIn,代码行数:12,代码来源:ElementTests.cs

示例3: Element

        public void Element()
        {
            ExecuteTest(browser =>
                            {
                                element = browser.Element(Find.ById("table1"));

                                var container = element as IElementContainer;
                                Assert.That(container, Is.Not.Null, "Should implement IElementsContainer");
                                Assert.IsAssignableFrom(typeof(ElementContainer<Element>), element, "The returned object form ie.Element should be castable to ElementsContainer<Element>");

                                Assert.IsNotNull(element, "Element not found");

                                // check behavior for standard attribute
                                Assert.AreEqual("table1", element.GetAttributeValue("id"), "GetAttributeValue id failed");
                                // check behavior for non existing attribute
                                Assert.IsNull(element.GetAttributeValue("watin"), "GetAttributeValue watin should return null");
                                // check behavior for custom attribute
                                Assert.AreEqual("myvalue", element.GetAttributeValue("myattribute"), "GetAttributeValue myattribute should return myvalue");

                                Assert.AreEqual("table", element.TagName.ToLower(), "Invalid tagname");

                                // Textbefore and TextAfter tests
                                var checkBox = browser.CheckBox("Checkbox21");

                                var textBefore = checkBox.TextBefore;
                                Assert.AreEqual("Test label before: ", textBefore, "Unexpected checkBox.TextBefore");

                                var textAfter = checkBox.TextAfter;
                                Assert.AreEqual(" Test label after", textAfter, "Unexpected checkBox.TextAfter");

                                var label = checkBox.Parent;
                                Assert.That(label, Is.InstanceOfType(typeof(Label)), "Expected a label");

                                var after = label.TextAfter ?? string.Empty; // difference between IE and FF
                                Assert.That(after.Trim(), Is.Empty, "Unexpected label.TextAfter");
                            });
        }
开发者ID:koshdim,项目名称:KoWatIn,代码行数:37,代码来源:ElementTests.cs

示例4: WaitUntilTimesOut

        public void WaitUntilTimesOut()
        {
            ExecuteTestWithAnyBrowser(browser =>
              {
                  element = browser.Form("Form");
                  Assert.That(element.GetAttributeValue("disabled"), Is.EqualTo(false.ToString()),
                              "Expected enabled form");

                  element.WaitUntil(new AttributeConstraint("disabled", true.ToString()), 1);

              });
        }
开发者ID:koshdim,项目名称:KoWatIn,代码行数:12,代码来源:ElementTests.cs

示例5: StyleDotStyleAttributeNameShouldReturnStyleAttribute

        public void StyleDotStyleAttributeNameShouldReturnStyleAttribute()
        {
            // GIVEN
            const string styleAttributeValue = "white";

            var mockNativeElement = new Mock<INativeElement>();
            var mockDomContainer = new Mock<DomContainer>();
            mockNativeElement.Expect(x => x.IsElementReferenceStillValid()).Returns(true);
            mockNativeElement.Expect(x => x.GetStyleAttributeValue("color")).Returns(styleAttributeValue);

            var element = new Element(mockDomContainer.Object, mockNativeElement.Object);

            // WHEN
            var value = element.GetAttributeValue("style.color");

            // THEN
            Assert.AreEqual(styleAttributeValue, value);
        }
开发者ID:koshdim,项目名称:KoWatIn,代码行数:18,代码来源:ElementTests.cs

示例6: StyleAttributeShouldReturnAsString

        public void StyleAttributeShouldReturnAsString()
        {
            // GIVEN
            const string cssText = "COLOR: white; FONT-STYLE: italic";

            var mockNativeElement = new Mock<INativeElement>();
            var mockDomContainer = new Mock<DomContainer>();
            mockNativeElement.Expect(x => x.IsElementReferenceStillValid()).Returns(true);
            mockNativeElement.Expect(x => x.GetStyleAttributeValue("cssText")).Returns(cssText);

            var element = new Element(mockDomContainer.Object, mockNativeElement.Object);

            // WHEN
            var value = element.GetAttributeValue("style");

            // THEN
            Assert.That(value, Is.EqualTo(cssText));
        }
开发者ID:koshdim,项目名称:KoWatIn,代码行数:18,代码来源:ElementTests.cs

示例7: position

        private static int position(Element element, string attributename)
        {
            var ieElement = (IEElement)element.NativeElement;

            var pos = 0;
            var offsetParent = ieElement.AsHtmlElement.offsetParent;
            if (offsetParent != null)
            {
                var domContainer = element.DomContainer;
                pos = position(new Element(domContainer, new IEElement(offsetParent)), attributename);
            }

            if (Comparers.StringComparer.AreEqual(element.TagName, "table", true))
            {
                pos = pos + int.Parse(element.GetAttributeValue("client" + attributename));
            }
            return pos + int.Parse(element.GetAttributeValue("offset" + attributename));
        }
开发者ID:exaphaser,项目名称:WatiN,代码行数:18,代码来源:PositionMousePointerOnElementTest.cs

示例8: ParseElement

        public static DynValue ParseElement(Element ele)
        {
            Type type = null;

            switch (ele.TagName.ToLower())
            {
                case "area":
                    type = typeof(cArea);
                    break;

                case "button":
                    type = typeof(cButton);
                    break;

                case "input":
                    switch (ele.GetAttributeValue("type").ToLower())
                    {
                        case "reset":
                        case "submit":
                        case "button":
                            type = typeof(cButton);
                            break;

                        case "checkbox":
                            type = typeof(cCheckBox);
                            break;

                        case "file":
                            type = typeof(cFileUpload);
                            break;

                        case "image":
                            type = typeof(cImage);
                            break;

                        case "radio":
                            type = typeof(cRadioButton);
                            break;

                        case "textarea":
                        case "text":
                        case "password":
                        case "hidden":
                            type = typeof(cTextField);
                            break;
                    }
                    break;

                case "div":
                    type = typeof(cDiv);
                    break;

                case "form":
                    type = typeof(cForm);
                    break;

                case "frame":
                case "iframe":
                    type = typeof(cFrame);
                    break;

                case "img":
                    type = typeof(cImage);
                    break;

                case "label":
                    type = typeof(cLabel);
                    break;

                case "a":
                    type = typeof(cLink);
                    break;

                case "ul":
                case "ol":
                    type = typeof(cList);
                    break;

                case "li":
                    type = typeof(cListItem);
                    break;

                case "option":
                    type = typeof(cOption);
                    break;

                case "p":
                    type = typeof(cPara);
                    break;

                case "select":
                    type = typeof(cSelectList);
                    break;

                case "span":
                    type = typeof(cSpan);
                    break;

                case "table":
                    type = typeof(cTable);
//.........这里部分代码省略.........
开发者ID:DevanFerreira,项目名称:myBot,代码行数:101,代码来源:Helpers.cs


注:本文中的Element.GetAttributeValue方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。