Skip to content
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
56 changes: 54 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>8</source>
<target>8</target>
Expand All @@ -22,9 +23,37 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.19.1</version>
<version>2.22.2</version>
<configuration>
<testFailureIgnore>true</testFailureIgnore>
<testFailureIgnore>false</testFailureIgnore>
<argLine>
-javaagent:"${settings.localRepository}/org/aspectj/aspectjweaver/${aspectj.version}/aspectjweaver-${aspectj.version}.jar"
</argLine>
<systemPropertyVariables>
<allure.results.directory>${project.build.directory}/allure-results</allure.results.directory>
</systemPropertyVariables>
<properties>
<property>
<name>listener</name>
<value>io.qameta.allure.junit4.AllureJunit4</value>
</property>
</properties>
</configuration>
<dependencies>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjweaver</artifactId>
<version>${aspectj.version}</version>
</dependency>
</dependencies>
</plugin>

<plugin>
<groupId>io.qameta.allure</groupId>
<artifactId>allure-maven</artifactId>
<version>2.10.0</version>
<configuration>
<reportVersion>2.6.0</reportVersion>
</configuration>
</plugin>
</plugins>
Expand All @@ -34,6 +63,8 @@
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<aspectj.version>1.9.5</aspectj.version>
<allure.version>2.13.6</allure.version>
</properties>
<dependencies>
<dependency>
Expand All @@ -48,6 +79,27 @@
<version>7.0.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.qameta.allure</groupId>
<artifactId>allure-junit4</artifactId>
<version>${allure.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjweaver</artifactId>
<version>${aspectj.version}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.30</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.7.30</version>
</dependency>
</dependencies>

</project>
39 changes: 31 additions & 8 deletions src/test/java/lib/CoreTestCase.java
Original file line number Diff line number Diff line change
@@ -1,30 +1,36 @@
package lib;

import io.appium.java_client.AppiumDriver;
import io.qameta.allure.Step;
import junit.framework.TestCase;
import lib.UI.MainPageObject;
import lib.UI.WelcomePageObject;
import org.junit.After;
import org.junit.Before;
import org.openqa.selenium.ScreenOrientation;
import org.openqa.selenium.remote.RemoteWebDriver;

public class CoreTestCase extends TestCase {
import java.io.FileOutputStream;
import java.util.Properties;

public class CoreTestCase {
protected RemoteWebDriver driver;
private static String AppiumURL = "http://127.0.0.1:4723/";

@Override
protected void setUp() throws Exception {
super.setUp();
@Before
@Step("Run driver and session")
public void setUp() throws Exception {
driver = Platform.getInstance().getDriver();
this.createAllurePropertyFile();
this.rotateScreenPortrait();
this.skipWelcomePageForApp();
this.openWikiWebPageForMobileWeb();
}

@Override
protected void tearDown() throws Exception {
@After
@Step("Remove driver and session")
public void tearDown() {
driver.quit();

super.tearDown();
}

protected void rotateScreenPortrait() {
Expand All @@ -36,6 +42,7 @@ protected void rotateScreenPortrait() {
}

}
@Step("Rotate screen to LANDSCAPE mode")
protected void rotateScreenLandscape() {
if (driver instanceof AppiumDriver) {
AppiumDriver driver = (AppiumDriver) this.driver;
Expand All @@ -45,6 +52,7 @@ protected void rotateScreenLandscape() {
}
}

@Step("Skip welcome screen for iOS/Android")
private void skipWelcomePageForApp()
{
if (Platform.getInstance().isiOS()) {
Expand All @@ -56,6 +64,7 @@ private void skipWelcomePageForApp()
}
}

@Step("Open wikipedia URL for Mobile Web (this method does nothing for Android and iOS)")
protected void openWikiWebPageForMobileWeb()
{
if (Platform.getInstance().isMW()) {
Expand All @@ -64,4 +73,18 @@ protected void openWikiWebPageForMobileWeb()
System.out.println("Method openWikiWebPageForMobileWeb() do nothing for platform " + Platform.getInstance().getPlatformVar());
}
}
private void createAllurePropertyFile()
{
String path = System.getProperty("allure.results.directory");
try {
Properties props = new Properties();
FileOutputStream fos = new FileOutputStream(path + "/environment.properties");
props.setProperty("Environment", Platform.getInstance().getPlatformVar());
props.store(fos,"See https://github.com/allure-framework/allure-app/wiki/Environment");
fos.close();
} catch (Exception e) {
System.err.println("IO problem when writing allure properties file");
e.printStackTrace();
}
}
}
19 changes: 19 additions & 0 deletions src/test/java/lib/UI/ArticlePageObject.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package lib.UI;

import io.qameta.allure.Step;
import lib.Platform;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.remote.RemoteWebDriver;
Expand All @@ -26,24 +27,32 @@ private static String getSubTitleElement(String substring)
}
/*TEMPLATES METHODS */

@Step("Waiting for title '{substring}' in the folder")
public WebElement waitForTitleElementInFolder(String substring)
{
String element_result_present_xpath = getTitleElement(substring);
return this.waitForElementPresent(element_result_present_xpath,"Cannot find " + substring + " article in folder",7);
}

@Step("Waiting for subtitle '{substring}' on the article page")
public WebElement waitForSubTitleElement(String substring)
{
String element_result_present_xpath = getSubTitleElement(substring);
return this.waitForElementPresent(element_result_present_xpath,"Cannot find " + substring + " article in folder",7);
}
@Step("Getting for title on the article in folder (for mobile web)")
public String getArticleTitleInFolderMW()
{
screenshot(this.takeScreenshot("article_title_in_folder"));
return this.waitForElementPresent(TITLE_IN_FOLDER_TPL,"Can",3).getText();
}
@Step("Getting for title '{substring}' on the article in folder (for iOS/Android)")
public String getArticleTitleInFolder(String substring)
{
WebElement title_element_in_folder = waitForTitleElementInFolder(substring);

screenshot(this.takeScreenshot("article_title_in_folder"));

String element=null;
if (Platform.getInstance().isiOS()) {
element = title_element_in_folder.getAttribute("value");
Expand All @@ -55,6 +64,7 @@ public String getArticleTitleInFolder(String substring)
return element;
}

@Step("Getting for subtitle '{substring}' on the article")
public String getArticleSubTitle(String substring)
{
WebElement subtitle_element_in_folder = waitForSubTitleElement(substring);
Expand All @@ -64,17 +74,21 @@ public String getArticleSubTitle(String substring)
} else if (Platform.getInstance().isiOS()) {
element = "value";
}
screenshot(this.takeScreenshot("article_subtitle"));
return subtitle_element_in_folder.getAttribute(element);
}

@Step("Waiting for title in the article")
public WebElement waitForTitleElementInArticle()
{
return this.waitForElementPresent(TITLE_IN_ARTICLE,"Cannot find title in article",10);
}
@Step("Waiting for title in the article without waiting for the title to appear")
public void waitForTitleElementInArticleWithoutTimeout()
{
this.assertElementPresent(TITLE_IN_ARTICLE,"Cannot find title in article");
}
@Step("Getting for title on the article (for iOS/Android)")
public String getTitleInArticle()
{
WebElement title_element = waitForTitleElementInArticle();
Expand All @@ -84,12 +98,16 @@ public String getTitleInArticle()
} else {
element = title_element.getAttribute("value");
}
screenshot(this.takeScreenshot("title_in_article"));
return element;
}
@Step("Getting for title on the article (for mobile web)")
public String getTitleInArticleMW ()
{
screenshot(this.takeScreenshot("title_in_article"));
return this.waitForElementPresent(TITLE_IN_ARTICLE,"Can2",3).getText();
}
@Step("Swiping article '{substring}' for delete")
public void swipeElementDelete(String substring)
{
this.waitForArticleToAppearByTitle(substring);
Expand All @@ -100,6 +118,7 @@ public void swipeElementDelete(String substring)
}
}

@Step("Waiting for article by '{substring}'")
public void waitForArticleToAppearByTitle(String substring)
{
String article_xpath = getTitleElement(substring);
Expand Down
12 changes: 10 additions & 2 deletions src/test/java/lib/UI/BottomToolbarArticleUI.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package lib.UI;

import io.qameta.allure.Step;
import lib.Platform;
import org.openqa.selenium.remote.RemoteWebDriver;

Expand All @@ -19,7 +20,6 @@ abstract public class BottomToolbarArticleUI extends MainPageObject {
INOUT_PASSWORD,
BUTTON_SUBMIT,
BUTTON_LOG_IN,
BURGER_MENU,
BUTTON_WATCHLIST,
UNSAVE_BUTTON,
UPDATE_SAVED;
Expand All @@ -35,6 +35,7 @@ private static String getNameOfList(String substring)
return NAME_OF_EXIST_LIST_TPL.replace("{SUBSTRING_NAME_OF_LIST}",substring);
}
/*TEMPLATES METHODS */
@Step("Adding to favourite list")
public void addToList ()
{
this.waitForElementAndClick(BUTTON_PAGE_SAVE, "Cannot find Save button", 3);
Expand All @@ -46,39 +47,46 @@ public void addToList ()
}
}

@Step("Login for mobile web")
public void logIn (String name, String password)
{
this.waitForElementAndClick(BUTTON_LOG_IN,"Cannot find 'log in' button",5);
this.waitForElementAndSendKeys(INPUT_NAME,name,"Cannot find input for name",5);
this.waitForElementAndSendKeys(INOUT_PASSWORD,password,"Cannot find input for password",5);
this.waitForElementAndClick(BUTTON_SUBMIT,"Cannot find submit button",5);
screenshot(this.takeScreenshot("log_in"));
}

@Step("Open watchList for mobile web")
public void watchList ()
{
this.waitForElementAndClick(BUTTON_WATCHLIST,"Cannot find watchlist button",5);
screenshot(this.takeScreenshot("watchList"));
}

@Step("Delete article from favorites for mobile web")
public void deleteArticle ()
{
this.waitForElementAndClick(UNSAVE_BUTTON,"Cannot find unsaved button",5);
}

@Step("Create favorite list with name '{name_of_folder}' for iOS/Android")
public void createMyList(String name_of_folder)
{
if (Platform.getInstance().isiOS()) {
this.waitForElementAndClick(BUTTON_CREATE_NEW_LIST, "Cannot find button 'Create new list'",15);
}
this.waitForElementAndSendKeys(INPUT_NAME_OF_FOLDER, name_of_folder, "Cannot find input for write name of this list", 5);
this.waitForElementAndClick(BUTTON_OK, "Cannot find button 'OK'", 5);

}
@Step("Add to exist favorite list with name '{substring}' for iOS/Android")
public void addToExistList(String substring)
{
String name_of_saves_list = getNameOfList(substring);
this.waitForElementAndClick(name_of_saves_list, "Cannot find folder " + substring, 5);
}

@Step("View exist favorite list for iOS/Android")
public void viewExistListAfterSave()
{
this.waitForElementAndClick(BUTTON_VIEW_LIST, "Cannot click on View list", 5);
Expand Down
Loading