This repository was archived by the owner on Oct 18, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 28
Add tests for mobile #81
Open
totallynotkate
wants to merge
3
commits into
autoschool:master
Choose a base branch
from
totallynotkate:appium
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
52 changes: 52 additions & 0 deletions
52
commons-module/src/test/java/ru/qatools/school/mobiletests/MobileTests.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| package ru.qatools.school.mobiletests; | ||
|
|
||
| import org.junit.Before; | ||
| import org.junit.Rule; | ||
| import org.junit.Test; | ||
| import ru.qatools.school.rules.MobileDriverRule; | ||
| import ru.qatools.school.screens.MainScreen; | ||
| import ru.qatools.school.screens.SelectStationScreen; | ||
| import ru.qatools.school.steps.mobilesteps.MobileSteps; | ||
| import ru.yandex.qatools.allure.annotations.Title; | ||
| import ru.yandex.qatools.htmlelements.annotations.Name; | ||
|
|
||
| import static org.hamcrest.MatcherAssert.assertThat; | ||
| import static org.hamcrest.Matchers.greaterThan; | ||
| import static org.hamcrest.Matchers.is; | ||
|
|
||
| /** | ||
| * @author totallynotkate (Kate Kocijevska) | ||
| */ | ||
| public class MobileTests { | ||
|
|
||
| public static final String FIRST_STATION = "Arbatskaya"; | ||
| public static final String SECOND_STATION = "Borisovo"; | ||
| public static final int TIME = 10; | ||
| private MobileSteps mobileSteps; | ||
|
|
||
| @Rule | ||
| public MobileDriverRule mobileDriverRule = new MobileDriverRule(); | ||
|
|
||
| @Before | ||
| public void initSteps(){ | ||
| mobileSteps = new MobileSteps(mobileDriverRule.getDriver()); | ||
| } | ||
|
|
||
| @Test | ||
| @Title("Время поездки от Арбатской до Борисово должно быть больше 10 минут") | ||
| public void shouldSeeGreaterTime(){ | ||
| SelectStationScreen selectStationScreen = mobileSteps.goToSelectStationScreen(onMainScreen().fromField()); | ||
| mobileSteps.input(selectStationScreen.stationNameInput(), FIRST_STATION); | ||
| mobileSteps.tap(selectStationScreen.stationsList().get(0)); | ||
|
|
||
| selectStationScreen = mobileSteps.goToSelectStationScreen(onMainScreen().toField()); | ||
| mobileSteps.input(selectStationScreen.stationNameInput(), SECOND_STATION); | ||
| mobileSteps.tap(selectStationScreen.stationsList().get(0)); | ||
|
|
||
| mobileSteps.shouldSeeTimeGreaterThan(TIME); | ||
| } | ||
|
|
||
| private MainScreen onMainScreen(){ | ||
| return new MainScreen(mobileDriverRule.getDriver()); | ||
| } | ||
| } |
32 changes: 32 additions & 0 deletions
32
steps-module/src/main/java/ru/qatools/school/rules/MobileDriverRule.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| package ru.qatools.school.rules; | ||
|
|
||
| import org.junit.rules.ExternalResource; | ||
| import org.openqa.selenium.remote.DesiredCapabilities; | ||
| import org.openqa.selenium.remote.RemoteWebDriver; | ||
|
|
||
| import java.net.MalformedURLException; | ||
| import java.net.URL; | ||
|
|
||
| /** | ||
| * @author totallynotkate (Kate Kocijevska) | ||
| */ | ||
| public class MobileDriverRule extends ExternalResource { | ||
| protected RemoteWebDriver driver; | ||
|
|
||
| protected void before() throws MalformedURLException { | ||
| DesiredCapabilities desiredCapabilities = new DesiredCapabilities(); | ||
| desiredCapabilities.setCapability("platformName", "Android"); | ||
| desiredCapabilities.setCapability("deviceName", "Android"); | ||
| desiredCapabilities.setCapability("app", "http://autoschool.github.io/files/ya-metro.apk"); | ||
| desiredCapabilities.setCapability("appWaitActivity", "ru.yandex.metro.MainActivity"); | ||
| driver = new RemoteWebDriver(new URL("http://127.0.0.1:4723/wd/hub"), desiredCapabilities); | ||
| } | ||
|
|
||
| protected void after() { | ||
| driver.quit(); | ||
| } | ||
|
|
||
| public RemoteWebDriver getDriver() { | ||
| return driver; | ||
| } | ||
| } |
42 changes: 42 additions & 0 deletions
42
steps-module/src/main/java/ru/qatools/school/screens/MainScreen.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| package ru.qatools.school.screens; | ||
|
|
||
| import org.openqa.selenium.remote.RemoteWebDriver; | ||
| import org.openqa.selenium.support.FindBy; | ||
| import org.openqa.selenium.support.PageFactory; | ||
| import ru.yandex.qatools.htmlelements.annotations.Name; | ||
| import ru.yandex.qatools.htmlelements.element.HtmlElement; | ||
| import ru.yandex.qatools.htmlelements.loader.decorator.HtmlElementDecorator; | ||
| import ru.yandex.qatools.htmlelements.loader.decorator.HtmlElementLocatorFactory; | ||
|
|
||
| /** | ||
| * @author totallynotkate (Kate Kocijevska) | ||
| */ | ||
| public class MainScreen { | ||
| public MainScreen(RemoteWebDriver driver){ | ||
| PageFactory.initElements(new HtmlElementDecorator(new HtmlElementLocatorFactory(driver)), this); | ||
| } | ||
|
|
||
| @Name("Поле From") | ||
| @FindBy(id = "ru.yandex.metro:id/tv_from_name") | ||
| private HtmlElement fromField; | ||
|
|
||
| @Name("Поле To") | ||
| @FindBy(id = "ru.yandex.metro:id/tv_to_name") | ||
| private HtmlElement toField; | ||
|
|
||
| @Name("Выезжающая панель") | ||
| @FindBy(id="ru.yandex.metro:id/topPanel") | ||
| private TopPanel topPanel; | ||
|
|
||
| public HtmlElement fromField(){ | ||
| return fromField; | ||
| } | ||
|
|
||
| public HtmlElement toField() { | ||
| return toField; | ||
| } | ||
|
|
||
| public TopPanel topPanel() { | ||
| return topPanel; | ||
| } | ||
| } |
36 changes: 36 additions & 0 deletions
36
steps-module/src/main/java/ru/qatools/school/screens/SelectStationScreen.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| package ru.qatools.school.screens; | ||
|
|
||
| import org.openqa.selenium.remote.RemoteWebDriver; | ||
| import org.openqa.selenium.support.FindBy; | ||
| import org.openqa.selenium.support.PageFactory; | ||
| import ru.yandex.qatools.htmlelements.annotations.Name; | ||
| import ru.yandex.qatools.htmlelements.element.HtmlElement; | ||
| import ru.yandex.qatools.htmlelements.loader.decorator.HtmlElementDecorator; | ||
| import ru.yandex.qatools.htmlelements.loader.decorator.HtmlElementLocatorFactory; | ||
|
|
||
| import java.util.List; | ||
|
|
||
| /** | ||
| * @author totallynotkate (Kate Kocijevska) | ||
| */ | ||
| public class SelectStationScreen { | ||
| public SelectStationScreen(RemoteWebDriver driver){ | ||
| PageFactory.initElements(new HtmlElementDecorator(new HtmlElementLocatorFactory(driver)), this); | ||
| } | ||
|
|
||
| @Name("Поле ввода названия станции") | ||
| @FindBy(id = "ru.yandex.metro:id/filterTextId") | ||
| private HtmlElement stationNameInput; | ||
|
|
||
| @Name("Список станций") | ||
| @FindBy(id="ru.yandex.metro:id/txtStationName") | ||
| private List<HtmlElement> stationsList; | ||
|
|
||
| public HtmlElement stationNameInput() { | ||
| return stationNameInput; | ||
| } | ||
|
|
||
| public List<HtmlElement> stationsList() { | ||
| return stationsList; | ||
| } | ||
| } |
25 changes: 25 additions & 0 deletions
25
steps-module/src/main/java/ru/qatools/school/screens/TopPanel.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| package ru.qatools.school.screens; | ||
|
|
||
| import org.openqa.selenium.Rectangle; | ||
| import org.openqa.selenium.support.FindBy; | ||
| import ru.yandex.qatools.htmlelements.annotations.Name; | ||
| import ru.yandex.qatools.htmlelements.element.HtmlElement; | ||
|
|
||
| /** | ||
| * @author totallynotkate (Kate Kocijevska) | ||
| */ | ||
| public class TopPanel extends HtmlElement{ | ||
|
|
||
| @Name("Время поездки") | ||
| @FindBy(id="ru.yandex.metro:id/tv_time") | ||
| private HtmlElement rideTimeString; | ||
|
|
||
| public HtmlElement rideTimeString() { | ||
| return rideTimeString; | ||
| } | ||
|
|
||
| @Override | ||
| public Rectangle getRect() { | ||
| return null; | ||
| } | ||
| } |
48 changes: 48 additions & 0 deletions
48
steps-module/src/main/java/ru/qatools/school/steps/mobilesteps/MobileSteps.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| package ru.qatools.school.steps.mobilesteps; | ||
|
|
||
| import org.openqa.selenium.remote.RemoteWebDriver; | ||
| import ru.qatools.school.screens.MainScreen; | ||
| import ru.qatools.school.screens.SelectStationScreen; | ||
| import ru.yandex.qatools.allure.annotations.Step; | ||
| import ru.yandex.qatools.htmlelements.element.HtmlElement; | ||
|
|
||
| import static org.hamcrest.MatcherAssert.assertThat; | ||
| import static org.hamcrest.Matchers.greaterThan; | ||
|
|
||
| /** | ||
| * @author totallynotkate (Kate Kocijevska) | ||
| */ | ||
| public class MobileSteps { | ||
| private RemoteWebDriver driver; | ||
|
|
||
| public MobileSteps(RemoteWebDriver driver) { | ||
| this.driver = driver; | ||
| } | ||
|
|
||
| @Step("Тапаем по элементу {0}") | ||
| public void tap(HtmlElement element) { | ||
| element.click(); | ||
| } | ||
|
|
||
| @Step("Переходим на страницу выбора станции с элемента {0}") | ||
| public SelectStationScreen goToSelectStationScreen(HtmlElement element) { | ||
| element.click(); | ||
| return new SelectStationScreen(driver); | ||
| } | ||
|
|
||
| @Step("Вводим текст {1} в поле {0}") | ||
| public void input(HtmlElement element, String text) { | ||
| element.sendKeys(text); | ||
| } | ||
|
|
||
| @Step() | ||
| public void shouldSeeTimeGreaterThan(int time) { | ||
| assertThat("Неправильное время поездки", | ||
| Integer.parseInt(onMainScreen().topPanel().rideTimeString().getText().trim().split(" ")[0]), | ||
| greaterThan(time)); | ||
| } | ||
|
|
||
| private MainScreen onMainScreen() { | ||
| return new MainScreen(driver); | ||
| } | ||
| } | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Начиная с 61ой минуты что-то пойдёт не так.