本文整理汇总了C#中SeleniumPage类的典型用法代码示例。如果您正苦于以下问题:C# SeleniumPage类的具体用法?C# SeleniumPage怎么用?C# SeleniumPage使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SeleniumPage类属于命名空间,在下文中一共展示了SeleniumPage类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestGetNativePage
public void TestGetNativePage()
{
var nativePage = new NativePage();
var page = new SeleniumPage(nativePage);
var result = page.GetNativePage<NativePage>();
Assert.AreSame(nativePage, result);
}
示例2: TestGetPageType
public void TestGetPageType()
{
var nativePage = new NativePage();
var page = new SeleniumPage(nativePage);
var result = page.PageType;
Assert.AreEqual(typeof(NativePage), result);
}
示例3: TestGetPageFromElement
public void TestGetPageFromElement()
{
var element = new Mock<IWebElement>(MockBehavior.Strict);
var nativePage = new NativePage();
var page = new SeleniumPage(nativePage);
var result = page.GetPageFromElement(element.Object);
Assert.IsNotNull(result);
element.VerifyAll();
}
示例4: TestTryGetCorrectElement
public void TestTryGetCorrectElement()
{
var element = new Mock<IWebElement>(MockBehavior.Strict);
var nativePage = new NativePage { MyControl = element.Object };
var page = new SeleniumPage(nativePage);
IPropertyData propertyData;
var result = page.TryGetElement("MyControl", out propertyData);
Assert.IsNotNull(nativePage.MyControl);
Assert.AreEqual(true, result);
Assert.IsNotNull(propertyData);
}
示例5: TestGetFillMethodForMultipleSelectControl
public void TestGetFillMethodForMultipleSelectControl()
{
var option = new Mock<IWebElement>(MockBehavior.Strict);
option.SetupGet(o => o.Selected).Returns(false);
this.SetupClick(option);
var element = new Mock<IWebElement>(MockBehavior.Strict);
element.SetupGet(e => e.TagName).Returns("select");
element.Setup(e => e.GetAttribute("multiple")).Returns("true");
element.Setup(e => e.FindElements(By.TagName("option")))
.Returns(new ReadOnlyCollection<IWebElement>(new[] { option.Object }));
element.Setup(e => e.FindElements(By.XPath(".//option[normalize-space(.) = \"Selected Item\"]")))
.Returns(new ReadOnlyCollection<IWebElement>(new[] { option.Object }));
var nativePage = new NativePage();
var page = new SeleniumPage(nativePage);
var fillMethod = page.GetPageFillMethod(null);
fillMethod(element.Object, "Selected Item");
element.VerifyAll();
}
示例6: TestGetFillMethodForRadioButtonControl
public void TestGetFillMethodForRadioButtonControl()
{
var element = new Mock<IWebElement>(MockBehavior.Strict);
element.SetupGet(e => e.TagName).Returns("input");
element.Setup(e => e.GetAttribute("type")).Returns("radio");
this.SetupClick(element);
var nativePage = new NativePage();
var page = new SeleniumPage(nativePage);
var fillMethod = page.GetPageFillMethod(null);
fillMethod(element.Object, "true");
element.Verify(e => e.Click(), Times.Exactly(2));
element.VerifyAll();
}
示例7: TestGetFillMethodForCheckboxControl
public void TestGetFillMethodForCheckboxControl()
{
var element = new Mock<IWebElement>(MockBehavior.Strict);
element.SetupGet(e => e.TagName).Returns("input");
element.Setup(e => e.GetAttribute("type")).Returns("checkbox");
element.SetupGet(e => e.Selected).Returns(false);
this.SetupClick(element);
var nativePage = new NativePage();
var page = new SeleniumPage(nativePage);
var fillMethod = page.GetPageFillMethod(null);
fillMethod(element.Object, "true");
element.VerifyAll();
}
示例8: TestElementEnabledCheckWhenElementNotVisibleExceptionReturnsFalse
public void TestElementEnabledCheckWhenElementNotVisibleExceptionReturnsFalse()
{
var element = new Mock<IWebElement>(MockBehavior.Strict);
element.SetupGet(e => e.Displayed).Throws<ElementNotVisibleException>();
var nativePage = new NativePage();
var page = new SeleniumPage(nativePage);
var result = page.ElementEnabledCheck(element.Object);
Assert.AreEqual(false, result);
element.VerifyAll();
}
示例9: TestGetElementAttributeValueWithValidAttribute
public void TestGetElementAttributeValueWithValidAttribute()
{
var element = new Mock<IWebElement>(MockBehavior.Strict);
element.Setup(e => e.GetAttribute("href")).Returns("http://myurl.com/page");
var nativePage = new NativePage();
var page = new SeleniumPage(nativePage);
var result = page.GetElementAttributeValue(element.Object, "href");
Assert.AreEqual("http://myurl.com/page", result);
element.VerifyAll();
}
示例10: TestGetClickElement
public void TestGetClickElement()
{
var element = new Mock<IWebElement>(MockBehavior.Strict);
this.SetupClick(element);
var nativePage = new NativePage();
var page = new SeleniumPage(nativePage);
var result = page.ClickElement(element.Object);
Assert.AreEqual(true, result);
element.VerifyAll();
}
示例11: TestGetElementTextWhenControlIsCheckBoxInputControl
public void TestGetElementTextWhenControlIsCheckBoxInputControl()
{
var element = new Mock<IWebElement>(MockBehavior.Strict);
element.SetupGet(e => e.TagName).Returns("input ");
element.Setup(e => e.GetAttribute("type")).Returns("checkBox");
element.SetupGet(e => e.Selected).Returns(true);
var nativePage = new NativePage();
var page = new SeleniumPage(nativePage);
var result = page.GetElementText(element.Object);
Assert.AreEqual("True", result);
element.VerifyAll();
}
示例12: TestGetElementTextWhenControlIsTextAreaControl
public void TestGetElementTextWhenControlIsTextAreaControl()
{
var element = new Mock<IWebElement>(MockBehavior.Strict);
element.SetupGet(e => e.TagName).Returns("textarea");
element.Setup(e => e.GetAttribute("type")).Returns("textarea");
element.Setup(e => e.GetAttribute("value")).Returns("Input Text Area");
var nativePage = new NativePage();
var page = new SeleniumPage(nativePage);
var result = page.GetElementText(element.Object);
Assert.AreEqual("Input Text Area", result);
element.VerifyAll();
}
示例13: TestGetElementTextWhenControlASelectControlReturnsTheSelectedItemText
public void TestGetElementTextWhenControlASelectControlReturnsTheSelectedItemText()
{
var option = new Mock<IWebElement>(MockBehavior.Strict);
option.SetupGet(o => o.Selected).Returns(true);
option.SetupGet(o => o.Text).Returns("Selected Item");
var element = new Mock<IWebElement>(MockBehavior.Strict);
element.SetupGet(e => e.TagName).Returns("select");
element.Setup(e => e.GetAttribute("multiple")).Returns("false");
element.Setup(e => e.FindElements(By.TagName("option")))
.Returns(new ReadOnlyCollection<IWebElement>(new[] { option.Object }));
var nativePage = new NativePage();
var page = new SeleniumPage(nativePage);
var result = page.GetElementText(element.Object);
Assert.AreEqual("Selected Item", result);
element.VerifyAll();
}
示例14: TestGetElementTextWhenControlIsNotSpecialReturnsTheElementText
public void TestGetElementTextWhenControlIsNotSpecialReturnsTheElementText()
{
var element = new Mock<IWebElement>(MockBehavior.Strict);
element.SetupGet(e => e.TagName).Returns("DIV");
element.SetupGet(e => e.Text).Returns("Normal Text");
var nativePage = new NativePage();
var page = new SeleniumPage(nativePage);
var result = page.GetElementText(element.Object);
Assert.AreEqual("Normal Text", result);
element.VerifyAll();
}
示例15: TestElementEnabledCheckWhenStaleElementReferenceReturnsFalse
public void TestElementEnabledCheckWhenStaleElementReferenceReturnsFalse()
{
var element = new Mock<IWebElement>(MockBehavior.Strict);
element.SetupGet(e => e.Displayed).Throws<StaleElementReferenceException>();
var nativePage = new NativePage();
var page = new SeleniumPage(nativePage);
var result = page.ElementEnabledCheck(element.Object);
Assert.IsFalse(result);
element.VerifyAll();
}