Commit 51f3d23d authored by s5_driksm_a's avatar s5_driksm_a
Browse files

Innitial commit

parents
Pipeline #291 failed with stages
File added
.idea/
allure-results/
build/
target/
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4" />
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.bakalaurs</groupId>
<artifactId>Bakalaurs</artifactId>
<version>1.0-SNAPSHOT</version>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M3</version>
<configuration>
<testFailureIgnore>true</testFailureIgnore>
<argLine>
-javaagent:"${settings.localRepository}/org/aspectj/aspectjweaver/${aspectj.version}/aspectjweaver-${aspectj.version}.jar"
</argLine>
<forkCount>3</forkCount>
<reuseForks>true</reuseForks>
<includes>
<include>**/Test*.class</include>
</includes>
<reportsDirectory>target/surefire-reports-${surefire.forkNumber}</reportsDirectory>
</configuration>
<dependencies>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjweaver</artifactId>
<version>${aspectj.version}</version>
</dependency>
<dependency>
<groupId>org.apache.maven.surefire</groupId>
<artifactId>surefire-junit47</artifactId>
<version>3.0.0-M3</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
<properties>
<aspectj.version>1.9.1</aspectj.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<maven.failsafe.plugin.version>3.0.0-M3</maven.failsafe.plugin.version>
<maven.build.helper.plugin.version>3.0.0</maven.build.helper.plugin.version>
<cucumber.version>4.2.2</cucumber.version>
<maven.compiler.plugin.version>3.7.0</maven.compiler.plugin.version>
<generated.runner.directory>${project.build.directory}/parallel/runners</generated.runner.directory>
<generated.feature.directory>${project.build.directory}/parallel/features</generated.feature.directory>
</properties>
<dependencies>
<dependency>
<groupId>com.codeborne</groupId>
<artifactId>selenide</artifactId>
<version>5.2.3</version>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-plugin-api</artifactId>
<version>3.5.4</version>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-java</artifactId>
<version>4.0.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-junit</artifactId>
<version>4.0.0</version>
</dependency>
<dependency>
<groupId>io.qameta.allure</groupId>
<artifactId>allure-cucumber4-jvm</artifactId>
<version>2.9.0</version>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-all</artifactId>
<version>1.3</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.2</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-jdk14</artifactId>
<version>1.7.21</version>
</dependency>
</dependencies>
</project>
\ No newline at end of file
package pages;
import com.codeborne.selenide.SelenideElement;
import lombok.Data;
import lombok.EqualsAndHashCode;
import static com.codeborne.selenide.Condition.visible;
import static com.codeborne.selenide.Selenide.$$x;
import static com.codeborne.selenide.Selenide.$x;
@Data
@EqualsAndHashCode(callSuper = false)
public class LandingPage extends LoginPage {
private SelenideElement contactUsButton = $$x("//div[@ng-click='vm.openContactUsModal()']").filter(visible).get(0);
//Contact us form
private SelenideElement contactName = $x("//input[@ng-model='vm.fields.name']");
private SelenideElement contactSubject = $x("//input[@ng-model='vm.fields.subject']");
private SelenideElement contactMessage = $x("//textarea[@ng-model='vm.fields.message']");
private SelenideElement contactSend = $x("//div[@class='send-btn auth-user']");
}
package pages;
import com.codeborne.selenide.SelenideElement;
import lombok.Data;
import lombok.EqualsAndHashCode;
import static com.codeborne.selenide.Selectors.byName;
import static com.codeborne.selenide.Selenide.$;
import static com.codeborne.selenide.Selenide.$x;
@Data
@EqualsAndHashCode(callSuper = false)
public class LoginPage {
// Login and Register page elements
private SelenideElement cookieAcceptButton = $x("//*[@id='cookies-footer']/button");
private SelenideElement signUpButton = $x("//*[@class='signup-btn ng-binding']");
private SelenideElement signUpForm = $(byName("signupForm"));
private SelenideElement signUpFormEmail = $x(("//*/input[@name='username']"));
private SelenideElement signUpFormPassword = $x("/html/body/div[1]/div/div/div/div[1]/div/div[2]/form/custom-input[2]/input");
private SelenideElement signUpFormPasswordRepeat = $x("/html/body/div[1]/div/div/div/div[1]/div/div[2]/form/custom-input[3]/input");
private SelenideElement signUpFormButton = $x("/html/body/div[1]/div/div/div/div[1]/div/div[2]/form/button");
private SelenideElement signInButton = $x("//*[@class='login-btn ng-binding']");
private SelenideElement signInEmail = $x("//*/input[@name='email']");
private SelenideElement signInPassword = $x("//*/input[@name='password']");
private SelenideElement singInButtonConfirm = $x("//*[@class='auth-btn']");
}
package pages;
import com.codeborne.selenide.SelenideElement;
import lombok.Data;
import lombok.EqualsAndHashCode;
import static com.codeborne.selenide.Condition.visible;
import static com.codeborne.selenide.Selenide.$$x;
import static com.codeborne.selenide.Selenide.$x;
@Data
@EqualsAndHashCode(callSuper = false)
public class ProjectPage extends LandingPage{
private SelenideElement newProjectButton = $x("//a[@ui-sref='client.new_project']");
private SelenideElement noVoucherButton = $x("//a[@ng-click='vm.closeModal()']");
private SelenideElement projectNameField = $x("//input[@ng-model='vm.project_info.name']");
private SelenideElement projectDescriptionField = $x("//textarea[@ng-model='vm.project_info.description']");
private SelenideElement deviceOsButton = $$x("//div[@ng-repeat='brand in vm.device_list | filter:vm.osFilter']").filter(visible).get(1);
private SelenideElement modelCheckbox = $$x("//button[@type='button']").filter(visible).get(2);
private SelenideElement modelSave = $x("//button[@ng-click='vm.save()']");
}
package pages;
import com.codeborne.selenide.SelenideElement;
import lombok.Data;
import lombok.EqualsAndHashCode;
import static com.codeborne.selenide.Selenide.$x;
@Data
@EqualsAndHashCode(callSuper = false)
public class SettingsPage extends LandingPage {
private SelenideElement menuDropdown = $x("//div[@id='user-dropdown']");
private SelenideElement settingsButton = $x("//*[@id='user-dropdown']/div[3]/ul/li[1]/a");
private SelenideElement deleteProfileButton = $x("//button[@ng-click='vm.openDeleteProfileModal()']");
private SelenideElement passwordInput = $x("//input[@ng-model='vm.fields.password']");
private SelenideElement repeatPassword = $x("//input[@ng-model='vm.fields.repeat_password']");
private SelenideElement deleteProfile = $x("//div[@ng-click='vm.deleteAccount()']");
}
package utils;
public class BrowserFactory {
public static String browser;
public static String getBrowser() {
return browser;
}
public static void setBrowser(String browser) {
BrowserFactory.browser = browser;
}
}
package utils;
import org.apache.commons.lang3.StringUtils;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;
import static java.lang.System.getProperty;
import static java.lang.System.getenv;
import static org.hamcrest.CoreMatchers.not;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.text.IsEmptyString.isEmptyOrNullString;
import static utils.BrowserFactory.getBrowser;
public class Environment {
public String getTest48Url(){ return getEnv("TEST48_URL");}
public String getEmail() {return setEmail();}
private String getCredentials(String credential) {
String varEnv = getenv(credential);
String varProp = getProperty(credential);
if (StringUtils.isEmpty(varEnv) && StringUtils.isEmpty(varProp)) {
Properties newEnv = loadPropertiesFile("credentials.properties");
assertThat("The credential " + credential + " from credentials.properties is null or empty!", newEnv.getProperty(credential), not(isEmptyOrNullString()));
return newEnv.getProperty(credential);
} else if (!StringUtils.isEmpty(varEnv)) {
return varEnv;
}
assertThat("All property, environment variable and value in credentials.properties are empty for variable: " + credential, varProp, not(isEmptyOrNullString()));
return varProp;
}
private String getEnv(String property) {
String varEnv = getenv(property);
String varProp = getProperty(property);
if (StringUtils.isEmpty(varEnv) && StringUtils.isEmpty(varProp)) {
Properties newEnv = loadPropertiesFile("config.properties");
assertThat("The property " + property + " from config.properties is null!", newEnv.getProperty(property), not(isEmptyOrNullString()));
return newEnv.getProperty(property);
} else if (!StringUtils.isEmpty(varEnv)) {
return varEnv;
}
assertThat("All property, environment variable and value in config.properties are empty for variable: " + property, varProp, not(isEmptyOrNullString()));
return varProp;
}
private Properties prop = new Properties();
private Properties loadPropertiesFile(String filePath) {
try (InputStream resourceAsStream = getClass().getClassLoader().getResourceAsStream(filePath)) {
prop.load(resourceAsStream);
} catch (IOException e) {
System.err.println("Unable to load properties file : " + filePath);
}
return prop;
}
private String setEmail(){
if(getBrowser() == "chrome"){
return getCredentials("CHROME_EMAIL");
}
else if (getBrowser() == "firefox"){
return getCredentials("FIREFOX_EMAIL");
}
else if(getBrowser() == "safari"){
return getCredentials("SAFARI_EMAIL");
}
return "email set";
}
}
TEST48_URL=https://www.test48.com/
CHROME_EMAIL=test48chrome@yopmail.com
FIREFOX_EMAIL=test48firefox@yopmail.com
SAFARI_EMAIL=test48safari@yopmail.com
\ No newline at end of file
package stepdefinitions;
import com.codeborne.selenide.WebDriverRunner;
import cucumber.api.java.After;
import static com.codeborne.selenide.Selenide.*;
public class Hooks {
@After
public void closeBrowser(){
close();
sleep(1000);
WebDriverRunner.closeWebDriver();
}
}
package stepdefinitions;
import cucumber.api.java.en.And;
import cucumber.api.java.en.Then;
import pages.LandingPage;
public class LandingPageSteps {
private LandingPage landingPageElements = new LandingPage();
@And("user clicks message button")
public void userClicksMessageButton() {
landingPageElements.getContactUsButton().click();
}
@Then("fills in form")
public void fillsInForm() {
landingPageElements.getContactName().sendKeys("Test");
landingPageElements.getContactSubject().sendKeys("Test Subject");
landingPageElements.getContactMessage().sendKeys("Test message");
landingPageElements.getContactSend().isDisplayed();
}
}
package stepdefinitions;
import cucumber.api.java.en.And;
import cucumber.api.java.en.Given;
import cucumber.api.java.en.Then;
import cucumber.api.java.en.When;
import pages.SettingsPage;
import utils.Environment;
import static com.codeborne.selenide.Condition.visible;
import static com.codeborne.selenide.Selenide.*;
public class LoginAndRegisterSteps {
private SettingsPage landingPage = new SettingsPage();
Environment env = new Environment();
@Given("user is in test homepage")
public void userIsInTestHomepage() {
open(env.getTest48Url());
}
@Then("user clicks the sign up button")
public void userClicksTheSignUpButton() {
landingPage.getSignUpButton().click();
landingPage.getSignUpForm().waitUntil(visible, 5000);
}
@And("user enters his information")
public void userEntersHisInformation() {
landingPage.getCookieAcceptButton().click();
landingPage.getSignUpFormEmail().click();
landingPage.getSignUpFormEmail().sendKeys(env.getEmail());
landingPage.getSignUpFormPassword().click();
landingPage.getSignUpFormPassword().sendKeys("parole123");
landingPage.getSignUpFormPasswordRepeat().click();
landingPage.getSignUpFormPasswordRepeat().sendKeys("parole123");
}
@Then("user clicks sign up")
public void userClicksSignUp() {
landingPage.getSignUpFormButton().click();
landingPage.getMenuDropdown().waitUntil(visible, 10000);
}
@When("user logs into test48")
public void userLogsIntoTest() {
open(env.getTest48Url());
landingPage.getSignInButton().click();
landingPage.getCookieAcceptButton().click();
landingPage.getSignInEmail().sendKeys(env.getEmail());
landingPage.getSignInPassword().sendKeys("parole123");
landingPage.getSingInButtonConfirm().click();
}
}
package stepdefinitions;
import cucumber.api.java.en.And;
import cucumber.api.java.en.Then;
import pages.ProjectPage;
public class ProjectSteps {
private ProjectPage projectPage = new ProjectPage();
@And("user creates new project")
public void userCreatesNewProject() {
projectPage.getNewProjectButton().click();
projectPage.getNoVoucherButton().click();
}
@Then("fills in project information")
public void fillsInProjectInformation() {
projectPage.getProjectNameField().sendKeys("Test Project");
projectPage.getProjectDescriptionField().sendKeys("Project description");
}
@And("selects test devices")
public void selectsTestDevices() {
projectPage.getDeviceOsButton().click();
projectPage.getModelCheckbox().click();
projectPage.getModelSave().click();
}
}
package stepdefinitions;
import cucumber.api.java.en.And;
import cucumber.api.java.en.Then;
import cucumber.api.java.eo.Se;
import pages.SettingsPage;
import static com.codeborne.selenide.Condition.visible;
public class SettingsPageSteps {
private SettingsPage settingsPage = new SettingsPage();
@And("navigates to settings page")
public void navigatesToSettingsPage() {
settingsPage.getMenuDropdown().hover();
settingsPage.getSettingsButton().click();
}
@Then("clicks delete profile")
public void clicksDeleteProfile() {
settingsPage.getDeleteProfileButton().click();
}
@And("enters password")
public void entersPassword() {
settingsPage.getPasswordInput().click();
settingsPage.getPasswordInput().sendKeys("parole123");
settingsPage.getRepeatPassword().click();
settingsPage.getRepeatPassword().sendKeys("parole123");
}
@And("deletes profile")
public void deletesProfile() {
settingsPage.getDeleteProfile().click();
settingsPage.getSignUpButton().waitUntil(visible, 5000);
}
}
package testrunners;
import com.codeborne.selenide.Configuration;
import cucumber.api.CucumberOptions;
import cucumber.api.junit.Cucumber;
import org.junit.BeforeClass;
import org.junit.runner.RunWith;
import static utils.BrowserFactory.setBrowser;
@RunWith(Cucumber.class)
@CucumberOptions(
glue = "stepdefinitions",
features = {"src/test/resources/features/"},
plugin = {"pretty","io.qameta.allure.cucumber4jvm.AllureCucumber4Jvm", "json:target/cucumber-reports/file.json"}
)
public class TestRunnerChrome {
@BeforeClass
public static void startChrome(){
Configuration.browser="chrome";
setBrowser("chrome");
}
}
package testrunners;
import com.codeborne.selenide.Configuration;
import cucumber.api.CucumberOptions;
import cucumber.api.junit.Cucumber;
import org.junit.BeforeClass;
import org.junit.runner.RunWith;
import static utils.BrowserFactory.setBrowser;
@RunWith(Cucumber.class)
@CucumberOptions(
glue = "stepdefinitions",
features = {"src/test/resources/features/"},
plugin = {"pretty","io.qameta.allure.cucumber4jvm.AllureCucumber4Jvm", "json:target/cucumber-reports/file.json"}
)
public class TestRunnerFirefox {
@BeforeClass
public static void startFirefox(){
Configuration.browser="firefox";
setBrowser("firefox");
}
}
package testrunners;
import com.codeborne.selenide.Configuration;
import cucumber.api.CucumberOptions;
import cucumber.api.junit.Cucumber;
import org.junit.BeforeClass;
import org.junit.runner.RunWith;
import static utils.BrowserFactory.setBrowser;
@RunWith(Cucumber.class)
@CucumberOptions(
glue = "stepdefinitions",
features = {"src/test/resources/features/"},
plugin = {"pretty","io.qameta.allure.cucumber4jvm.AllureCucumber4Jvm", "json:target/cucumber-reports/file.json"}
)
public class TestRunnerSafari {
@BeforeClass
public static void startSafari(){
Configuration.browser="safari";
setBrowser("safari");
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment