diff --git a/htmlelements-junit-example/pom.xml b/htmlelements-junit-example/pom.xml
index 26bbc1e..0d7c929 100644
--- a/htmlelements-junit-example/pom.xml
+++ b/htmlelements-junit-example/pom.xml
@@ -10,6 +10,8 @@
4.0.0
htmlelements-junit-example
+ Yandex QATools HtmlElements Example using jUnit
+ jar
1.11-SNAPSHOT
@@ -28,7 +30,12 @@
ru.yandex.qatools.htmlelements
- htmlelements-all
+ htmlelements-java
+ ${htmlelements.version}
+
+
+ ru.yandex.qatools.htmlelements
+ htmlelements-matchers
${htmlelements.version}
diff --git a/htmlelements-junit-example/src/main/java/my/company/web/elements/SearchArrow.java b/htmlelements-junit-example/src/main/java/my/company/web/elements/SearchArrow.java
new file mode 100644
index 0000000..6a52984
--- /dev/null
+++ b/htmlelements-junit-example/src/main/java/my/company/web/elements/SearchArrow.java
@@ -0,0 +1,25 @@
+package my.company.web.elements;
+
+import org.openqa.selenium.support.FindBy;
+import ru.yandex.qatools.htmlelements.element.Button;
+import ru.yandex.qatools.htmlelements.element.HtmlElement;
+import ru.yandex.qatools.htmlelements.element.TextInput;
+
+/**
+ * @author Artem Eroshenko eroshenkoam
+ * 5/6/13, 5:13 PM
+ */
+public class SearchArrow extends HtmlElement {
+
+ @FindBy(xpath = ".//input[@class='b-form-input__input']")
+ public TextInput requestInput;
+
+ @FindBy(xpath = ".//input[@class='b-form-button__input']")
+ public Button searchButton;
+
+ public void searchFor(String request) {
+ requestInput.clear();
+ requestInput.sendKeys(request);
+ searchButton.click();
+ }
+}
diff --git a/htmlelements-junit-example/src/main/java/my/company/web/elements/SearchResults.java b/htmlelements-junit-example/src/main/java/my/company/web/elements/SearchResults.java
new file mode 100644
index 0000000..f252864
--- /dev/null
+++ b/htmlelements-junit-example/src/main/java/my/company/web/elements/SearchResults.java
@@ -0,0 +1,22 @@
+package my.company.web.elements;
+
+import org.openqa.selenium.WebElement;
+import org.openqa.selenium.support.FindBy;
+import ru.yandex.qatools.htmlelements.element.HtmlElement;
+
+import java.util.List;
+
+/**
+ * @author Artem Eroshenko eroshenkoam
+ * 5/6/13, 5:13 PM
+ */
+public class SearchResults extends HtmlElement {
+
+ @SuppressWarnings("unused")
+ @FindBy(xpath = ".//li[contains(@class, 'b-serp-item_js_inited')]")
+ private List searchItems;
+
+ public List getSearchItems() {
+ return searchItems;
+ }
+}
diff --git a/htmlelements-junit-example/src/main/java/my/company/web/pages/MainPage.java b/htmlelements-junit-example/src/main/java/my/company/web/pages/MainPage.java
new file mode 100644
index 0000000..907c943
--- /dev/null
+++ b/htmlelements-junit-example/src/main/java/my/company/web/pages/MainPage.java
@@ -0,0 +1,30 @@
+package my.company.web.pages;
+
+import my.company.web.elements.SearchArrow;
+import org.openqa.selenium.WebDriver;
+import org.openqa.selenium.support.FindBy;
+import org.openqa.selenium.support.PageFactory;
+import ru.yandex.qatools.htmlelements.loader.decorator.HtmlElementDecorator;
+
+/**
+ * @author Artem Eroshenko eroshenkoam
+ * 5/6/13, 5:14 PM
+ */
+public class MainPage {
+
+ private WebDriver driver;
+
+ @FindBy(className = "b-morda-search-form")
+ private SearchArrow searchArrow;
+
+ public MainPage(final WebDriver driver) {
+ PageFactory.initElements(new HtmlElementDecorator(driver), this);
+ this.driver = driver;
+ }
+
+ public SearchPage searchFor(String request) {
+ this.searchArrow.searchFor(request);
+ return new SearchPage(driver);
+ }
+
+}
diff --git a/htmlelements-junit-example/src/main/java/my/company/web/pages/SearchPage.java b/htmlelements-junit-example/src/main/java/my/company/web/pages/SearchPage.java
new file mode 100644
index 0000000..04f1720
--- /dev/null
+++ b/htmlelements-junit-example/src/main/java/my/company/web/pages/SearchPage.java
@@ -0,0 +1,39 @@
+package my.company.web.pages;
+
+import my.company.web.elements.SearchArrow;
+import my.company.web.elements.SearchResults;
+import org.openqa.selenium.WebDriver;
+import org.openqa.selenium.support.FindBy;
+import org.openqa.selenium.support.PageFactory;
+import ru.yandex.qatools.htmlelements.loader.decorator.HtmlElementDecorator;
+
+/**
+ * @author Artem Eroshenko eroshenkoam
+ * 5/6/13, 5:15 PM
+ */
+public class SearchPage {
+
+ @SuppressWarnings("unused")
+ private WebDriver driver;
+
+ @FindBy(className = "b-serp-list")
+ @SuppressWarnings("unused")
+ private SearchResults searchResults;
+
+ @FindBy(className = "b-morda-search-form")
+ @SuppressWarnings("unused")
+ private SearchArrow searchArrow;
+
+ public SearchPage(WebDriver driver) {
+ PageFactory.initElements(new HtmlElementDecorator(driver), this);
+ this.driver = driver;
+ }
+
+ public void searchFor(String request) {
+ this.searchArrow.searchFor(request);
+ }
+
+ public SearchResults getSearchResults() {
+ return this.searchResults;
+ }
+}
diff --git a/htmlelements-junit-example/src/test/java/my/company/web/SearchingByRequestTest.java b/htmlelements-junit-example/src/test/java/my/company/web/SearchingByRequestTest.java
new file mode 100644
index 0000000..d372b31
--- /dev/null
+++ b/htmlelements-junit-example/src/test/java/my/company/web/SearchingByRequestTest.java
@@ -0,0 +1,46 @@
+package my.company.web;
+
+import my.company.web.pages.MainPage;
+import my.company.web.pages.SearchPage;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.openqa.selenium.WebDriver;
+import org.openqa.selenium.firefox.FirefoxDriver;
+
+import static org.hamcrest.collection.IsCollectionWithSize.hasSize;
+import static org.junit.Assert.assertThat;
+import static ru.yandex.qatools.htmlelements.matchers.WebElementMatchers.exists;
+
+/**
+ * @author Artem Eroshenko eroshenkoam
+ * 5/6/13, 2:51 PM
+ */
+public class SearchingByRequestTest {
+
+ private final int DEFAULT_RESULTS_COUNT;
+
+ public WebDriver driver = new FirefoxDriver();
+
+ public SearchingByRequestTest() {
+ DEFAULT_RESULTS_COUNT = 10;
+ }
+
+ @Before
+ public void loadStartPage() {
+ driver.get("http://www.yandex.ru");
+ }
+
+ @Test
+ public void afterSearchingUserShouldSeSearchResults() {
+ MainPage mainPage = new MainPage(driver);
+ SearchPage page = mainPage.searchFor("Yandex");
+ assertThat(page.getSearchResults(), exists());
+ assertThat(page.getSearchResults().getSearchItems(), hasSize(DEFAULT_RESULTS_COUNT));
+ }
+
+ @After
+ public void killWebDriver() {
+ driver.quit();
+ }
+}