Skip to content
This repository was archived by the owner on Oct 18, 2018. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package ru.qatools.school.tp;

import org.junit.Ignore;
import org.junit.Rule;
import org.junit.Test;
import ru.yandex.qatools.allure.annotations.TestCaseId;
Expand All @@ -18,27 +19,30 @@ public class ConnectedToTPTest {
public TPInformerRule tms = new TPInformerRule("ruletest");


@Ignore
@Test
@TestCaseId("1")
public void shouldMarkCaseStatusAsPassed() throws IOException, InterruptedException {
SECONDS.sleep(15);
}


@Ignore
@Test
@TestCaseId("2")
public void shouldFail() throws IOException, InterruptedException {
SECONDS.sleep(5);
fail();
}

@Ignore
@Test
@TestCaseId("3")
public void shouldBroke() throws IOException, InterruptedException {
SECONDS.sleep(5);
throw new RuntimeException();
}

@Ignore
@Test
@TestCaseId("4")
public void shouldBeSkipped() throws IOException, InterruptedException {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,36 +1,117 @@
package ru.qatools.school.webtests;

/* @author arrumm (Arkhipov Roman) */

import org.junit.Before;
import org.junit.Ignore;
import org.junit.Rule;
import org.junit.Test;
import org.openqa.selenium.Keys;
import ru.qatools.school.pages.MainPage;
import ru.qatools.school.rules.WebDriverRule;
import ru.qatools.school.steps.websteps.DefaultSteps;
import ru.qatools.school.tp.TPInformerRule;
import ru.yandex.qatools.allure.annotations.TestCaseId;
import ru.yandex.qatools.allure.annotations.Title;

public class WeatherWebTest {

public static final String MOSCOW = "Moscow";
private static final String CITY = "Tomsk";

private DefaultSteps defaultSteps;

@Rule
public WebDriverRule webDriverRule = new WebDriverRule();

@Rule
public TPInformerRule tms = new TPInformerRule("arrumm");

@Before
public void initSteps() {
defaultSteps = new DefaultSteps(webDriverRule.getDriver());
}


@Test
@Title("Should see add widget button on the main page (URL without params)")
@TestCaseId("6")
public void shouldSeeAddWidgetButtonOnMainPageWithoutParams() {
defaultSteps.openMainPageWithoutParams();
defaultSteps.shouldSee(onMainPage().newCardButton());
}

@Test
@Title("Должны видеть виджет на главной странице")
@Title("Should see widget on the main page")
@TestCaseId("7")
public void shouldSeeWidgetOnMainPage() {
defaultSteps.openMainPageWithCity(MOSCOW);
defaultSteps.shouldSee(onMainPage().getWeatherWidget().get(0));
defaultSteps.openMainPageWithCity(null);
defaultSteps.shouldSee(onMainPage().getFirstWidget());
}

@Test
@Title("Should see picture on widget shows weather")
@TestCaseId("11")
public void shouldSeeWeatherPicture() {
defaultSteps.openMainPageWithCity(CITY);
defaultSteps.shouldSee(onMainPage().getFirstWidget().getWidgetText().getWeatherImage());
}


@Test
@Title("City name at widget title should match URL")
@TestCaseId("1")
public void shouldSeeWidgetWithCityInURL() {
defaultSteps.openMainPageWithCity(CITY);
defaultSteps.shouldSeeTextInElement(
onMainPage().getFirstWidget().getWidgetTitle().getCityNameElement(),
CITY);
}

@Test
@Title("Should see one more widget on the main page after adding")
@TestCaseId("8")
public void shouldDetectOnceMoreWidget() {
defaultSteps.openMainPageWithCity(CITY);
int widgetsQ = onMainPage().widgets().size();
defaultSteps.clickOn(onMainPage().newCardButton());
defaultSteps.shouldBeWidgetsQuantityOnPage(onMainPage().widgets(), widgetsQ + 1);
defaultSteps.shouldSeeAllFrom(onMainPage().widgets());
}

//@Ignore
@Test
@Title("Should see widget title")
@TestCaseId("12")
public void shouldSeeWidgetTitle() {
defaultSteps.openMainPageWithCity(CITY);
defaultSteps.shouldSee(onMainPage().getFirstWidget());
}

@Test
@Title("Should see temperature on the widget")
@TestCaseId("10")
public void shouldSeeTemperatureOnWidget() {
defaultSteps.openMainPageWithCity(CITY);
defaultSteps.shouldSee(onMainPage().getFirstWidget().getWidgetText().getTemperature());
}

@Test
@Title("Should see same city in the title entered by keyboard")
@TestCaseId("9")
public void shouldSeeCityInputFromKeyboard() {
defaultSteps.openMainPageWithCity(null);
defaultSteps.clickOn(onMainPage().newCardButton());
defaultSteps.clickOn(onMainPage().getFirstWidget().getWidgetTitle().getCityNameElement());
defaultSteps.clearIt(onMainPage().getFirstWidget().getWidgetTitle().getCityNameElement());
defaultSteps.sendKeysTo(onMainPage().getFirstWidget().getWidgetTitle().getCityNameElement(), CITY);
defaultSteps.sendKeysTo(onMainPage().getFirstWidget().getWidgetTitle().getCityNameElement(), Keys.ENTER);
defaultSteps.shouldSeeTextInElement(
onMainPage().getFirstWidget().getWidgetTitle().getCityNameElement(),
CITY);
}

private MainPage onMainPage() {
return new MainPage(webDriverRule.getDriver());
}

}
}
3 changes: 3 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@
<selenium.version>2.53.0</selenium.version>
<htmlelements.version>1.15</htmlelements.version>
<aspectj.version>1.8.5</aspectj.version>

<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

</properties>

<dependencies>
Expand Down
19 changes: 16 additions & 3 deletions steps-module/src/main/java/ru/qatools/school/pages/MainPage.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package ru.qatools.school.pages;

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
import org.openqa.selenium.support.PageFactory;
import ru.qatools.school.pages.blocks.WeatherWidget;
Expand All @@ -12,6 +13,7 @@

/**
* Created by kurau.
* edited by arrumm.
*/
public class MainPage {

Expand All @@ -21,10 +23,21 @@ public MainPage(WebDriver driver) {

@Name("Список виджетов")
@FindBy(css = ".card.card_md")
private List<WeatherWidget> weatherWidget;
private List<WeatherWidget> widgets;

public List<WeatherWidget> getWeatherWidget() {
return weatherWidget;
@Name("Кнопка добавления виджета на страницу")
@FindBy(css = ".new-card")
private WebElement newCardButton;

public List<WeatherWidget> widgets() {
return widgets;
}

public WeatherWidget getFirstWidget() {
return widgets().get(0);
}

public WebElement newCardButton() {
return newCardButton;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import ru.qatools.school.pages.blocks.widgetblocks.WidgetText;
import ru.qatools.school.pages.blocks.widgetblocks.WidgetTitle;
import ru.yandex.qatools.htmlelements.annotations.Name;
import ru.yandex.qatools.htmlelements.element.Button;
import ru.yandex.qatools.htmlelements.element.HtmlElement;

/**
Expand Down Expand Up @@ -33,11 +34,8 @@ public WidgetTitle getWidgetTitle() {
return widgetTitle;
}

public WebElement getActions() {
return actions;
}

public Rectangle getRect() {
return null;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,14 @@ public class WidgetText extends HtmlElement {
@FindBy(css = ".weather-image")
private WebElement weatherImage;

@Name("Значение температуры")
@FindBy(css = ".weather-temperature__digit")
private WebElement temperature;

public WebElement getTemperature() {
return temperature;
}

public WebElement getWeatherImage() {
return weatherImage;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,25 @@

import org.openqa.selenium.Rectangle;
import ru.yandex.qatools.htmlelements.element.HtmlElement;
import org.openqa.selenium.support.FindBy;
import ru.yandex.qatools.htmlelements.annotations.Name;
import ru.yandex.qatools.htmlelements.element.HtmlElement;

/**
* Created by kurau.
* added by arrumm (Arkhipov Roman)
*/
public class WidgetTitle extends HtmlElement {

@Name("Название города в заголовке")
@FindBy(css = ".inplace")
private WidgetTitle cityNameElement;


public HtmlElement getCityNameElement() {
return cityNameElement;
}

public Rectangle getRect() {
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,24 @@

import org.junit.rules.ExternalResource;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.firefox.FirefoxBinary;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.firefox.FirefoxProfile;

import java.io.File;

/**
* Created by kurau.
* added by arrumm (Arkhipov Roman)
*/
public class WebDriverRule extends ExternalResource {

private WebDriver driver;

protected void before() throws Throwable {

System.setProperty("webdriver.firefox.bin", "D:\\my Programs\\firefox\\firefox.exe");
this.driver = new FirefoxDriver();
}

Expand Down
33 changes: 0 additions & 33 deletions steps-module/src/main/java/ru/qatools/school/steps/UserSteps.java

This file was deleted.

Loading