https://github.com/yandex-qatools/htmlelements-dotnet
A DotNet Implementation of HtmlElements framework
https://github.com/yandex-qatools/htmlelements-dotnet
Last synced: 3 months ago
JSON representation
A DotNet Implementation of HtmlElements framework
- Host: GitHub
- URL: https://github.com/yandex-qatools/htmlelements-dotnet
- Owner: yandex-qatools
- License: other
- Created: 2013-09-22T23:02:31.000Z (about 12 years ago)
- Default Branch: master
- Last Pushed: 2014-01-23T11:31:46.000Z (over 11 years ago)
- Last Synced: 2025-05-05T02:36:03.715Z (5 months ago)
- Language: C#
- Size: 5.61 MB
- Stars: 17
- Watchers: 13
- Forks: 12
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
Html Elements framework for .NET
==================
This framework is designed to provide easy-to-use way of interaction with web-page elements in your tests. It may be considered as an extension of WebDriver Page Object.
With the help of Html Elements framework you can group web-page elements into blocks, encapsulate logic of interaction with them and then easily use created blocks in page objects. It also provides a set of helpful matchers to use with web-page elements and blocks.Create blocks of elements
-------------------------
For example, let's create a block for the search form on the page http://www.yandex.com:```c#
[Name("Search form")]
[Block(How = How.XPath, Using = "//form")]
public class SearchArrow : HtmlElement {
[Name("Search request input")]
[FindsBy(How = How.Id, Using = "searchInput")]
private TextInput requestInput;[Name("Search button")]
[FindsBy(How = How.ClassName, Using = "b-form-button__input")]
private Button searchButton;public void Search(string request) {
requestInput.SendKeys(request);
searchButton.Click();
}
}
```Construct page object using created blocks
------------------------------------------
You can easily use created blocks in page objects:```c#
public class SearchPage {
private SearchArrow searchArrow;
// Other blocks and elements herepublic SearchPage(IWebDriver driver) {
PageFactory.InitElements(new HtmlElementDecorator(driver), this);
}public void Search(string request) {
searchArrow.Search(request);
}// Other methods here
}
```Use page objects in your tests
------------------------------
Created page objects can be used in your tests. That makes tests more comprehensive and easy to write.```c#
[TestFixture]
public class SampleTest {
private IWebDriver driver = new FirefoxDriver();
private SearchPage searchPage = new SearchPage(driver);[TestFixtureSetUp]
public void LoadPage() {
driver.Navigate().GoToUrl("http://www.yandex.com");
}[Test]
public void SampleTest() {
searchPage.Search("yandex");
// Some assertion here
}[TestFixtureTearDown]
public void CloseDriver() {
driver.Quit();
}
}
```