本文整理汇总了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;
}
示例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
}
示例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");
});
}
示例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);
});
}
示例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);
}
示例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));
}
示例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));
}
示例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);
//.........这里部分代码省略.........