first commit
diff --git a/cloudAutomation/.gitignore b/cloudAutomation/.gitignore
new file mode 100644
index 0000000..1d86b47
--- /dev/null
+++ b/cloudAutomation/.gitignore
@@ -0,0 +1,3 @@
+.idea/
+*.iml
+target/
\ No newline at end of file
diff --git a/cloudAutomation/pom.xml b/cloudAutomation/pom.xml
new file mode 100644
index 0000000..c3d850c
--- /dev/null
+++ b/cloudAutomation/pom.xml
@@ -0,0 +1,74 @@
+<?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.epam.ta</groupId>
+ <artifactId>cloudAutomation</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <source>8</source>
+ <target>8</target>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <version>2.22.1</version>
+ </plugin>
+ </plugins>
+ </build>
+
+ <dependencies>
+ <!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-java -->
+ <dependency>
+ <groupId>org.seleniumhq.selenium</groupId>
+ <artifactId>selenium-java</artifactId>
+ <version>3.141.59</version>
+ </dependency>
+ <!-- https://mvnrepository.com/artifact/org.testng/testng -->
+ <dependency>
+ <groupId>org.testng</groupId>
+ <artifactId>testng</artifactId>
+ <version>6.14.3</version>
+ <scope>test</scope>
+ </dependency>
+ <!-- https://mvnrepository.com/artifact/org.hamcrest/hamcrest -->
+ <dependency>
+ <groupId>org.hamcrest</groupId>
+ <artifactId>hamcrest</artifactId>
+ <version>2.1</version>
+ <scope>test</scope>
+ </dependency>
+ <!-- https://mvnrepository.com/artifact/commons-io/commons-io -->
+ <dependency>
+ <groupId>commons-io</groupId>
+ <artifactId>commons-io</artifactId>
+ <version>2.6</version>
+ </dependency>
+ <dependency>
+ <groupId>io.github.bonigarcia</groupId>
+ <artifactId>webdrivermanager</artifactId>
+ <version>3.6.2</version>
+ <scope>test</scope>
+ </dependency>
+ <!-- https://mvnrepository.com/artifact/org.apache.logging.log4j/log4j-core -->
+ <dependency>
+ <groupId>org.apache.logging.log4j</groupId>
+ <artifactId>log4j-core</artifactId>
+ <version>2.11.1</version>
+ </dependency>
+ <!-- https://mvnrepository.com/artifact/org.apache.logging.log4j/log4j-api -->
+ <dependency>
+ <groupId>org.apache.logging.log4j</groupId>
+ <artifactId>log4j-api</artifactId>
+ <version>2.11.1</version>
+ </dependency>
+ </dependencies>
+</project>
\ No newline at end of file
diff --git a/cloudAutomation/src/main/java/TestDriverManager.java b/cloudAutomation/src/main/java/TestDriverManager.java
new file mode 100644
index 0000000..9e810a1
--- /dev/null
+++ b/cloudAutomation/src/main/java/TestDriverManager.java
@@ -0,0 +1,12 @@
+//import io.github.bonigarcia.wdm.WebDriverManager;
+import org.openqa.selenium.WebDriver;
+import org.openqa.selenium.firefox.FirefoxDriver;
+
+public class TestDriverManager {
+ private static WebDriver driver;
+
+ public static void main(String[] args) {
+ // WebDriverManager.firefoxdriver().setup();
+ driver = new FirefoxDriver();
+ }
+}
diff --git a/cloudAutomation/src/test/java/Utils/TestListener.java b/cloudAutomation/src/test/java/Utils/TestListener.java
new file mode 100644
index 0000000..472360a
--- /dev/null
+++ b/cloudAutomation/src/test/java/Utils/TestListener.java
@@ -0,0 +1,76 @@
+package Utils;
+
+import driver.DriverSingletone;
+import org.apache.commons.io.FileUtils;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+import org.openqa.selenium.OutputType;
+import org.openqa.selenium.TakesScreenshot;
+import org.testng.ITestContext;
+import org.testng.ITestListener;
+import org.testng.ITestResult;
+
+import java.io.File;
+import java.io.IOException;
+import java.time.ZonedDateTime;
+import java.time.format.DateTimeFormatter;
+
+public class TestListener implements ITestListener {
+ private Logger logger = LogManager.getRootLogger();
+
+
+ @Override
+ public void onTestStart(ITestResult iTestResult) {
+
+ }
+
+ @Override
+ public void onTestSuccess(ITestResult iTestResult) {
+
+ }
+
+ @Override
+ public void onTestFailure(ITestResult iTestResult) {
+ saveScrenshot();
+ }
+
+ private void saveScrenshot() {
+ File screenCapture = ((TakesScreenshot) DriverSingletone
+ .getDriver())
+ .getScreenshotAs(OutputType.FILE);
+ try {
+ FileUtils.copyFile(screenCapture, new File(
+ ".//target/screenshots/"
+ + getCurrentTimeAsString() +
+ ".png"));
+ }catch (IOException e) {
+ logger.error("Failed to save screenshot: " + e.getLocalizedMessage());
+ }
+ }
+ private String getCurrentTimeAsString() {
+ DateTimeFormatter formatter = DateTimeFormatter.ofPattern("uuuu-MM-dd_HH-mm-ss");
+ return ZonedDateTime.now().format(formatter);
+ }
+
+ @Override
+ public void onTestSkipped(ITestResult iTestResult) {
+
+ }
+
+ @Override
+ public void onTestFailedButWithinSuccessPercentage(ITestResult iTestResult) {
+
+ }
+
+ @Override
+ public void onStart(ITestContext iTestContext) {
+
+ }
+
+ @Override
+ public void onFinish(ITestContext iTestContext) {
+
+ }
+}
+
+
diff --git a/cloudAutomation/src/test/java/driver/DriverSingletone.java b/cloudAutomation/src/test/java/driver/DriverSingletone.java
new file mode 100644
index 0000000..3c217f7
--- /dev/null
+++ b/cloudAutomation/src/test/java/driver/DriverSingletone.java
@@ -0,0 +1,36 @@
+package driver;
+
+import io.github.bonigarcia.wdm.WebDriverManager;
+import org.openqa.selenium.chrome.ChromeDriver;
+import org.openqa.selenium.firefox.FirefoxDriver;
+import org.openqa.selenium.WebDriver;
+
+public class DriverSingletone {
+ private static WebDriver driver;
+
+ private DriverSingletone(){}
+
+ public static WebDriver getDriver(){
+ if(null==driver){
+ switch (System.getProperty("browser")){
+ case "firefox":{
+ WebDriverManager.firefoxdriver().setup();
+ driver = new FirefoxDriver();
+ }
+ default:{
+ WebDriverManager.chromedriver().setup();
+ driver = new ChromeDriver();
+ }
+ driver.manage().window().maximize();
+ }
+
+ }
+ return driver;
+ }
+
+ public static void closeDriver(){
+ driver.quit();
+ driver = null;
+ }
+
+}
diff --git a/cloudAutomation/src/test/java/model/ComputerEngine.java b/cloudAutomation/src/test/java/model/ComputerEngine.java
new file mode 100644
index 0000000..e749683
--- /dev/null
+++ b/cloudAutomation/src/test/java/model/ComputerEngine.java
@@ -0,0 +1,110 @@
+package model;
+
+public class ComputerEngine {
+
+ private String numberOfInstances;
+ private String operatingSystem;
+ private String machineClass;
+ private String machineType;
+ private String numberOfGpu;
+ private String gpuType;
+ private String localSsd;
+ private String datacenterLocation;
+ private String commitedUsach;
+ private String cost;
+
+ public ComputerEngine(String numberOfInstances, String operatingSystem, String machineClass, String machineType,
+ String numberOfGpu, String gpuType, String localSsd, String datacenterLocation,
+ String commitedUsach) {
+ this.numberOfInstances = numberOfInstances;
+ this.operatingSystem = operatingSystem;
+ this.machineClass = machineClass;
+ this.machineType = machineType;
+ this.numberOfGpu = numberOfGpu;
+ this.gpuType = gpuType;
+ this.localSsd = localSsd;
+ this.datacenterLocation = datacenterLocation;
+ this.commitedUsach = commitedUsach;
+
+ }
+
+ public String getNumberOfInstances() {
+ return numberOfInstances;
+ }
+
+ public void setNumberOfInstances(String numberOfInstances) {
+ this.numberOfInstances = numberOfInstances;
+ }
+
+ public String getOperatingSystem() {
+ return operatingSystem;
+ }
+
+ public void setOperatingSystem(String operatingSystem) {
+ this.operatingSystem = operatingSystem;
+ }
+
+ public String getMachineClass() {
+ return machineClass;
+ }
+
+ public void setMachineClass(String machineClass) {
+ this.machineClass = machineClass;
+ }
+
+ public String getMachineType() {
+ return machineType;
+ }
+
+ public void setMachineType(String machineType) {
+ this.machineType = machineType;
+ }
+
+ public String getNumberOfGpu() {
+ return numberOfGpu;
+ }
+
+ public void setNumberOfGpu(String numberOfGpu) {
+ this.numberOfGpu = numberOfGpu;
+ }
+
+ public String getGpuType() {
+ return gpuType;
+ }
+
+ public void setGpuType(String gpuType) {
+ this.gpuType = gpuType;
+ }
+
+ public String getLocalSsd() {
+ return localSsd;
+ }
+
+ public void setLocalSsd(String localSsd) {
+ this.localSsd = localSsd;
+ }
+
+ public String getDatacenterLocation() {
+ return datacenterLocation;
+ }
+
+ public void setDatacenterLocation(String datacenterLocation) {
+ this.datacenterLocation = datacenterLocation;
+ }
+
+ public String getCommitedUsach() {
+ return commitedUsach;
+ }
+
+ public void setCommitedUsach(String commitedUsach) {
+ this.commitedUsach = commitedUsach;
+ }
+
+ public String getCost() {
+ return cost;
+ }
+
+ public void setCost(String cost) {
+ this.cost = cost;
+ }
+}
diff --git a/cloudAutomation/src/test/java/page/CloudCalkulationResultPage.java b/cloudAutomation/src/test/java/page/CloudCalkulationResultPage.java
new file mode 100644
index 0000000..3721195
--- /dev/null
+++ b/cloudAutomation/src/test/java/page/CloudCalkulationResultPage.java
@@ -0,0 +1,35 @@
+package page;
+
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+import org.openqa.selenium.By;
+import org.openqa.selenium.WebDriver;
+import org.openqa.selenium.WebElement;
+import org.openqa.selenium.support.FindBy;
+import org.openqa.selenium.support.PageFactory;
+import page.initialPages.CloudAbstractPage;
+
+public class CloudCalkulationResultPage extends CloudAbstractPage {
+ private static final Logger logger = LogManager.getRootLogger();
+
+ @FindBy(xpath = "//b[contains(text(), 'Total Estimated Cost:')]")
+ private WebElement totalEstimatedCostRow;
+
+ @FindBy(xpath = "//button[contains(text(),'Email Estimate')]")
+ private WebElement emailEstimateBtn;
+
+ public CloudCalkulationResultPage(WebDriver driver) {
+ super(driver);
+ PageFactory.initElements(driver, this);
+ logger.info("CloudCalkulationResultPage is open");
+ }
+
+ public String getTotalEstimatedCost() {
+ return totalEstimatedCostRow.getText();
+ }
+
+ public EmailYourEstimatePage chooseEmailEstimate(){
+ emailEstimateBtn.click();
+ return new EmailYourEstimatePage(driver);
+ }
+}
diff --git a/cloudAutomation/src/test/java/page/CloudFillingCalculationFormPage.java b/cloudAutomation/src/test/java/page/CloudFillingCalculationFormPage.java
new file mode 100644
index 0000000..965e657
--- /dev/null
+++ b/cloudAutomation/src/test/java/page/CloudFillingCalculationFormPage.java
@@ -0,0 +1,150 @@
+package page;
+
+import model.ComputerEngine;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+import org.openqa.selenium.By;
+import org.openqa.selenium.JavascriptExecutor;
+import org.openqa.selenium.WebDriver;
+import org.openqa.selenium.WebElement;
+import org.openqa.selenium.support.FindBy;
+import org.openqa.selenium.support.PageFactory;
+import page.initialPages.CloudAbstractPage;
+
+public class CloudFillingCalculationFormPage extends CloudAbstractPage {
+ private static final String ID_Iframe = "idIframe";
+ private static final String TEMPLATE_XPATH_ITEM_DROP_DOWN_MENU = "//div[@class='md-select-menu-container md-active md-clickable']" +
+ "//md-option/div[contains(text(),'%s')]";
+ private static final String XPATH_GPUS_CHECK_BOX = "//div[contains(text(),'Add GPUs.')]/preceding-sibling::div";
+ private static final String ID_LOCAL_SSD_FIELD = "select_value_label_49";
+ private static final String XPATH_WAIT_CLOSE_MENU = "//md-select[@aria-expanded='true']";
+ private static final String XPATH_ESTIMATE_BTN = "//form[@name='ComputeEngineForm']" +
+ "//button[@class ='md-raised md-primary cpc-button md-button md-ink-ripple' ]";
+ private static final Logger logger = LogManager.getRootLogger();
+
+ @FindBy(id = "idIframe")
+ private WebElement iframe;
+
+ @FindBy(xpath = "//md-tab-item//div[text()='Compute Engine' ]")
+ private WebElement computeEngineBtn;
+
+ @FindBy(id = "input_52")//"input[@id='input_1493']"
+ private WebElement numberOfInstancesInput;
+
+ @FindBy(id = "select_value_label_45")
+ private WebElement operatingSystemSoftwareField;
+
+ @FindBy(id = "select_value_label_46")
+ private WebElement machineClassField;
+
+ @FindBy(id = "select_value_label_48")
+ private WebElement machineTypeField;
+
+ @FindBy(id = "select_value_label_334")
+ private WebElement numberOfGPUsField;
+
+ @FindBy(id = "select_value_label_335")
+ private WebElement GPuTypeField;
+
+ @FindBy(id = "select_value_label_50")
+ private WebElement datacenterLocationField;
+
+ @FindBy(xpath = "//form[@name='ComputeEngineForm']//md-select[@placeholder='Committed usage']")
+ private WebElement commitedUsageField;
+
+ public CloudFillingCalculationFormPage(WebDriver driver) {
+ super(driver);
+ PageFactory.initElements(driver, this);
+ logger.info("CloudProductsAndServicesPage is open");
+ }
+
+ public CloudFillingCalculationFormPage activateComputeEngine() {
+ waitForElementLocatedBy(driver, By.id(ID_Iframe));
+ driver.switchTo().frame(iframe);
+ computeEngineBtn.click();
+ return this;
+ }
+
+ public CloudFillingCalculationFormPage fillNumberOfInstances(ComputerEngine computerEngine) {
+ numberOfInstancesInput.sendKeys(computerEngine.getNumberOfInstances());
+ return this;
+ }
+
+ public CloudFillingCalculationFormPage chooseOperatingSystem(ComputerEngine computerEngine) {
+ String xpathOperatingSystem = String.format(TEMPLATE_XPATH_ITEM_DROP_DOWN_MENU, computerEngine.getOperatingSystem());
+ operatingSystemSoftwareField.click();
+ WebElement operatingSystemOption = waitForElementLocatedBy(driver, By.xpath(xpathOperatingSystem));
+ operatingSystemOption.click();
+ return this;
+ }
+
+ public CloudFillingCalculationFormPage chooseMachineClass(ComputerEngine computerEngine) {
+ String xpathMachineClass = String.format(TEMPLATE_XPATH_ITEM_DROP_DOWN_MENU, computerEngine.getMachineClass());
+ machineClassField.click();
+ waitForElementLocatedBy(driver, By.xpath(xpathMachineClass)).click();
+ return this;
+ }
+
+ public CloudFillingCalculationFormPage chooseMachineType(ComputerEngine computerEngine){
+ String xpathMachineType = String.format(TEMPLATE_XPATH_ITEM_DROP_DOWN_MENU, computerEngine.getMachineType());
+ machineTypeField.click();
+ waitForElementToBeClickableBy(driver, By.xpath(xpathMachineType)).click();
+ return this;
+ }
+
+ public CloudFillingCalculationFormPage pickGPUs() {
+ WebElement gpusCheckBox = waitForElementToBeClickableBy(driver, By.xpath(XPATH_GPUS_CHECK_BOX));
+ if (!gpusCheckBox.isSelected()) {
+ gpusCheckBox.click();
+ }
+ return this;
+ }
+
+ public CloudFillingCalculationFormPage chooseNumberOfGPUs(ComputerEngine computerEngine){
+ String xpathNumberOfGPUs = String.format(TEMPLATE_XPATH_ITEM_DROP_DOWN_MENU, computerEngine.getNumberOfGpu());
+ numberOfGPUsField.click();
+ WebElement element = waitForElementToBeClickableBy(driver, By.xpath(xpathNumberOfGPUs));
+ element.click();
+ return this;
+ }
+
+ public CloudFillingCalculationFormPage chooseGPuType(ComputerEngine computerEngine) {
+ String xpathGPuTyp = String.format(TEMPLATE_XPATH_ITEM_DROP_DOWN_MENU, computerEngine.getGpuType());
+ GPuTypeField.click();
+ waitForElementLocatedBy(driver, By.xpath(xpathGPuTyp)).click();
+ return this;
+ }
+
+ public CloudFillingCalculationFormPage chooseLocalSsd(ComputerEngine computerEngine) {
+ ((JavascriptExecutor)driver).executeScript("arguments[0].scrollIntoView();", driver.findElement(By.xpath(XPATH_ESTIMATE_BTN)));
+ String xpathLocalSsd = String.format(TEMPLATE_XPATH_ITEM_DROP_DOWN_MENU, computerEngine.getLocalSsd());
+ WebElement localSsdField = waitForElementToBeClickableBy(driver, By.id(ID_LOCAL_SSD_FIELD));
+
+ waitInvisibilityOfElementLocated(driver, By.xpath(XPATH_WAIT_CLOSE_MENU));
+
+ localSsdField.click();
+ waitForElementToBeClickableBy(driver, By.xpath(xpathLocalSsd)).click();
+ return this;
+ }
+
+ public CloudFillingCalculationFormPage chooseDatacenterLocation(ComputerEngine computerEngine) {
+ String xpathDatacenterLocation = String.format(TEMPLATE_XPATH_ITEM_DROP_DOWN_MENU, computerEngine.getDatacenterLocation());
+ datacenterLocationField.click();
+ waitForElementToBeClickableBy(driver, By.xpath(xpathDatacenterLocation)).click();
+ return this;
+ }
+
+ public CloudFillingCalculationFormPage chooseCommittedUsage(ComputerEngine computerEngine) {
+ String xpathCommittedUsage = String.format(TEMPLATE_XPATH_ITEM_DROP_DOWN_MENU, computerEngine.getCommitedUsach());
+ commitedUsageField.click();
+ waitForElementToBeClickableBy(driver, By.xpath(xpathCommittedUsage)).click();
+ return this;
+ }
+
+ public CloudCalkulationResultPage getEstimation() {
+ waitForElementLocatedBy(driver, By.xpath(XPATH_ESTIMATE_BTN)).click();
+ logger.info("Form is filled in and gone to calculate");
+ return new CloudCalkulationResultPage(driver);
+ }
+
+}
diff --git a/cloudAutomation/src/test/java/page/CrazyMailingPage.java b/cloudAutomation/src/test/java/page/CrazyMailingPage.java
new file mode 100644
index 0000000..8954966
--- /dev/null
+++ b/cloudAutomation/src/test/java/page/CrazyMailingPage.java
@@ -0,0 +1,31 @@
+package page;
+
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+import org.openqa.selenium.By;
+import org.openqa.selenium.WebDriver;
+import org.openqa.selenium.WebElement;
+import page.initialPages.CloudAbstractPage;
+
+public class CrazyMailingPage extends CloudAbstractPage {
+
+ private static final String ID_TEMPORARY_EMAIL_FIELD = "email_addr";
+ private static final String TEMPLATE_XPATH_SUBJECT_CLOUD_EMAIL = "//strong[contains(text(),'%s')]";
+ private static final Logger logger = LogManager.getRootLogger();
+
+ public CrazyMailingPage(WebDriver driver) {
+ super(driver);
+ logger.info("CrazyMailingPage is open");
+ }
+ public String getEmail(){
+ WebElement email = waitForElementLocatedBy(driver, By.id(ID_TEMPORARY_EMAIL_FIELD));
+ return email.getText();
+ }
+
+ public EmailContentPage openEmailBySubject(String emailSubject){
+ String xpathSubject = String.format(TEMPLATE_XPATH_SUBJECT_CLOUD_EMAIL, emailSubject);
+ waitForElementToBeClickableBy(driver, By.xpath(xpathSubject)).click();
+ logger.info("Arrived email by subject" + emailSubject + " is open");
+ return new EmailContentPage(driver);
+ }
+}
diff --git a/cloudAutomation/src/test/java/page/EmailContentPage.java b/cloudAutomation/src/test/java/page/EmailContentPage.java
new file mode 100644
index 0000000..629fb6d
--- /dev/null
+++ b/cloudAutomation/src/test/java/page/EmailContentPage.java
@@ -0,0 +1,26 @@
+package page;
+
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+import org.openqa.selenium.By;
+import org.openqa.selenium.WebDriver;
+import org.openqa.selenium.WebElement;
+import page.initialPages.CloudAbstractPage;
+
+public class EmailContentPage extends CloudAbstractPage {
+
+ private static final String XPATH_COST_IN_EMAIL_FIELD = "//h3[text() = 'Total Estimated Monthly Cost']/following::h3";
+ private static final String ID_Iframe = "mess_frame";
+ private static final Logger logger = LogManager.getRootLogger();
+
+ public EmailContentPage(WebDriver driver) {
+ super(driver);
+ logger.info("EmailContentPage is open");
+ }
+
+ public String getTotalEstimateCost(){
+ WebElement iFrame = waitForElementLocatedBy(driver, By.id(ID_Iframe));
+ driver.switchTo().frame(iFrame);
+ return waitForElementLocatedBy(driver, By.xpath(XPATH_COST_IN_EMAIL_FIELD)).getText();
+ }
+}
diff --git a/cloudAutomation/src/test/java/page/EmailYourEstimatePage.java b/cloudAutomation/src/test/java/page/EmailYourEstimatePage.java
new file mode 100644
index 0000000..e9fc6ed
--- /dev/null
+++ b/cloudAutomation/src/test/java/page/EmailYourEstimatePage.java
@@ -0,0 +1,34 @@
+package page;
+
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+import org.openqa.selenium.By;
+import org.openqa.selenium.WebDriver;
+import org.openqa.selenium.WebElement;
+import page.initialPages.CloudAbstractPage;
+
+public class EmailYourEstimatePage extends CloudAbstractPage {
+
+ private static final String ID_Iframe = "idIframe";
+ private static final String XPATH_EMAIL_FIELD = "//label[contains(text(),'Email')]/following-sibling::input";
+ private static final String XPATH_SEND_EMAIL_BTN = "//button[contains(text(),'Send Email') and not(@disabled)]";
+ private static final Logger logger = LogManager.getRootLogger();
+
+ public EmailYourEstimatePage(WebDriver driver) {
+ super(driver);
+ logger.info("EmailYourEstimatePage is open");
+ }
+
+ public EmailYourEstimatePage fillEmailField(String email) {
+ WebElement iFrame = waitForElementLocatedBy(driver, By.id(ID_Iframe));
+ driver.switchTo().frame(iFrame);
+ waitForElementLocatedBy(driver, By.xpath(XPATH_EMAIL_FIELD)).sendKeys(email);
+ return this;
+ }
+
+ public CloudCalkulationResultPage sendEmail() {
+ waitForElementToBeClickableBy(driver, By.xpath(XPATH_SEND_EMAIL_BTN)).click();
+ logger.info("Email is sent");
+ return new CloudCalkulationResultPage(driver);
+ }
+}
diff --git a/cloudAutomation/src/test/java/page/initialPages/CloudAbstractPage.java b/cloudAutomation/src/test/java/page/initialPages/CloudAbstractPage.java
new file mode 100644
index 0000000..f061d9c
--- /dev/null
+++ b/cloudAutomation/src/test/java/page/initialPages/CloudAbstractPage.java
@@ -0,0 +1,50 @@
+package page.initialPages;
+
+import org.openqa.selenium.By;
+import org.openqa.selenium.JavascriptExecutor;
+import org.openqa.selenium.WebDriver;
+import org.openqa.selenium.WebElement;
+import org.openqa.selenium.support.ui.ExpectedConditions;
+import org.openqa.selenium.support.ui.WebDriverWait;
+
+import java.util.ArrayList;
+
+public abstract class CloudAbstractPage {
+ protected WebDriver driver;
+ private static final int TIME_WAIT = 20;
+ private static final String SCRIPT_TEMPLATE = "window.open('%s')";
+
+ public CloudAbstractPage(WebDriver driver) {
+ this.driver = driver;
+ }
+
+ protected WebElement waitForElementLocatedBy(WebDriver driver, By by) {
+ return new WebDriverWait(driver, TIME_WAIT)
+ .until(ExpectedConditions.presenceOfElementLocated(by));
+ }
+
+ protected WebElement waitForElementToBeClickableBy(WebDriver driver, By by) {
+ return new WebDriverWait(driver, TIME_WAIT)
+ .until(ExpectedConditions.elementToBeClickable(by));
+ }
+
+
+ protected void waitInvisibilityOfElementLocated(WebDriver driver, By by) {
+ new WebDriverWait(driver,TIME_WAIT).until(ExpectedConditions.invisibilityOfElementLocated(by));
+ }
+
+ public void openNewTabWithUrl(String url) {
+ String script = String.format(SCRIPT_TEMPLATE, url);
+ ((JavascriptExecutor) driver).executeScript(script);
+ ArrayList<String> tabs = new ArrayList<String>(driver.getWindowHandles());
+ driver.switchTo().window(tabs.get(1));
+ }
+
+ public void goToTabByWindowHandle(String windowHandle) {
+ driver.switchTo().window(windowHandle);
+ }
+
+ public String getCurrentWindowHandle(){
+ return driver.getWindowHandle();
+ }
+}
diff --git a/cloudAutomation/src/test/java/page/initialPages/CloudHomePage.java b/cloudAutomation/src/test/java/page/initialPages/CloudHomePage.java
new file mode 100644
index 0000000..ae857dc
--- /dev/null
+++ b/cloudAutomation/src/test/java/page/initialPages/CloudHomePage.java
@@ -0,0 +1,36 @@
+package page.initialPages;
+
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+import org.openqa.selenium.By;
+import org.openqa.selenium.WebDriver;
+import org.openqa.selenium.WebElement;
+
+
+public class CloudHomePage extends CloudAbstractPage {
+
+ private static final String HOME_URL = "https://cloud.google.com/";
+ private static final String XPATH_SEE_ALL_PRODUCTS_BTN = "//a[contains(text(),'See products')]";
+ private static final Logger logger = LogManager.getRootLogger();
+
+ public CloudHomePage(WebDriver driver) {
+ super(driver);
+ }
+
+ public CloudHomePage openPage() {
+ driver.get(HOME_URL);
+ logger.info("CloudHomePage is open");
+ return this;
+ }
+
+ public CloudProductsAndServicesPage seeAllProducts(){
+ WebElement seeAllProductsBtn = waitForElementLocatedBy(driver, By.xpath(XPATH_SEE_ALL_PRODUCTS_BTN));
+ seeAllProductsBtn.click();
+ return new CloudProductsAndServicesPage(driver);
+ }
+
+ public String seeAllProductsBtnName(){
+ WebElement seeAllProductsBtn = waitForElementLocatedBy(driver, By.xpath(XPATH_SEE_ALL_PRODUCTS_BTN));
+ return seeAllProductsBtn.getText();
+ }
+}
\ No newline at end of file
diff --git a/cloudAutomation/src/test/java/page/initialPages/CloudPricingPage.java b/cloudAutomation/src/test/java/page/initialPages/CloudPricingPage.java
new file mode 100644
index 0000000..49ddac1
--- /dev/null
+++ b/cloudAutomation/src/test/java/page/initialPages/CloudPricingPage.java
@@ -0,0 +1,27 @@
+package page.initialPages;
+
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+import org.openqa.selenium.By;
+import org.openqa.selenium.WebDriver;
+import org.openqa.selenium.WebElement;
+import org.openqa.selenium.support.PageFactory;
+import page.CloudFillingCalculationFormPage;
+import page.initialPages.CloudAbstractPage;
+
+public class CloudPricingPage extends CloudAbstractPage {
+ private static final String XPATH_CALCULATORS_BTN = "//a[text()='Calculators']";
+ private static final Logger logger = LogManager.getRootLogger();
+
+ public CloudPricingPage(WebDriver driver) {
+ super(driver);
+ PageFactory.initElements(driver, this);
+ logger.info("CloudPricingPage is open");
+ }
+
+ public CloudFillingCalculationFormPage usePricingCalculator(){
+ WebElement calculatorsBtn = waitForElementLocatedBy(driver, By.xpath(XPATH_CALCULATORS_BTN));
+ calculatorsBtn.click();
+ return new CloudFillingCalculationFormPage(driver);
+ }
+}
diff --git a/cloudAutomation/src/test/java/page/initialPages/CloudProductsAndServicesPage.java b/cloudAutomation/src/test/java/page/initialPages/CloudProductsAndServicesPage.java
new file mode 100644
index 0000000..f543d2e
--- /dev/null
+++ b/cloudAutomation/src/test/java/page/initialPages/CloudProductsAndServicesPage.java
@@ -0,0 +1,25 @@
+package page.initialPages;
+
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+import org.openqa.selenium.By;
+import org.openqa.selenium.WebDriver;
+import org.openqa.selenium.WebElement;
+import page.initialPages.CloudAbstractPage;
+import page.initialPages.CloudPricingPage;
+
+public class CloudProductsAndServicesPage extends CloudAbstractPage {
+ private static final String XPATH_SEE_PRICING_BTN = "//a[contains(text(),'See pricing')]";
+ private static final Logger logger = LogManager.getRootLogger();
+
+ public CloudProductsAndServicesPage(WebDriver driver) {
+ super(driver);
+ logger.info("CloudProductsAndServicesPage is open");
+ }
+
+ public CloudPricingPage seePricing(){
+ WebElement seePricingBtn = waitForElementLocatedBy(driver, By.xpath(XPATH_SEE_PRICING_BTN));
+ seePricingBtn.click();
+ return new CloudPricingPage(driver);
+ }
+}
diff --git a/cloudAutomation/src/test/java/service/ProductCreator.java b/cloudAutomation/src/test/java/service/ProductCreator.java
new file mode 100644
index 0000000..9b7a8b4
--- /dev/null
+++ b/cloudAutomation/src/test/java/service/ProductCreator.java
@@ -0,0 +1,25 @@
+package service;
+
+import model.ComputerEngine;
+
+public class ProductCreator {
+ private static final String NUMBER_OF_INSTANCES = "number.of.instances";
+ private static final String OPERATING_SYSTEM = "operating.system";
+ private static final String MACHINE_CLASS = "machine.class";
+ private static final String MACHINE_TYPE = "machine.type";
+
+ private static final String NUMBER_OF_GPU = "number.of.gpu";
+ private static final String GPU_TYPE = "gpu.type";
+ private static final String LOCAL_SSD = "local.ssd";
+ private static final String DATACENTER_LOCATION = "datacenter.location";
+ private static final String COMMITED_USACH = "commited.usach";
+
+ public static ComputerEngine createProductComputerEngine(){
+return new ComputerEngine(TestDataReader.getTestData(NUMBER_OF_INSTANCES), TestDataReader.getTestData(OPERATING_SYSTEM),
+ TestDataReader.getTestData(MACHINE_CLASS), TestDataReader.getTestData(MACHINE_TYPE),
+ TestDataReader.getTestData(NUMBER_OF_GPU), TestDataReader.getTestData(GPU_TYPE),
+ TestDataReader.getTestData(LOCAL_SSD), TestDataReader.getTestData(DATACENTER_LOCATION),
+ TestDataReader.getTestData(COMMITED_USACH));
+ }
+}
+
diff --git a/cloudAutomation/src/test/java/service/TestDataReader.java b/cloudAutomation/src/test/java/service/TestDataReader.java
new file mode 100644
index 0000000..9f4e8e0
--- /dev/null
+++ b/cloudAutomation/src/test/java/service/TestDataReader.java
@@ -0,0 +1,8 @@
+package service;
+
+import java.util.ResourceBundle;
+
+public class TestDataReader {
+ public static ResourceBundle resourceBundle = ResourceBundle.getBundle(System.getProperty("environment"));
+ public static String getTestData(String key){return resourceBundle.getString(key);}
+}
diff --git a/cloudAutomation/src/test/java/test/CloudTestRun.java b/cloudAutomation/src/test/java/test/CloudTestRun.java
new file mode 100644
index 0000000..c095b2a
--- /dev/null
+++ b/cloudAutomation/src/test/java/test/CloudTestRun.java
@@ -0,0 +1,75 @@
+package test;
+
+import model.ComputerEngine;
+import org.testng.Assert;
+import org.testng.annotations.Test;
+import page.CloudCalkulationResultPage;
+import page.initialPages.CloudHomePage;
+import page.CrazyMailingPage;
+import page.EmailYourEstimatePage;
+import service.ProductCreator;
+
+import static org.hamcrest.CoreMatchers.equalTo;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.is;
+
+public class CloudTestRun extends CommonConditions {
+
+ @Test(description = "Filling form correct amount of the order by email")
+ public void checkTheCorrectAmountOfTheOrderByEmail() {
+// Assert.fail("[Natasha] Filling form correct amount of the order by email");
+ String emailSubject = "Google Cloud Platform Price Estimate";
+ String temporaryMail = "https://www.crazymailing.com";
+
+ ComputerEngine testComputerEngine = ProductCreator.createProductComputerEngine();
+
+ CloudHomePage cloudHomePage = new CloudHomePage(driver);
+
+ cloudHomePage.openPage()
+ .seeAllProducts()
+ .seePricing()
+ .usePricingCalculator()
+ .activateComputeEngine()
+ .fillNumberOfInstances(testComputerEngine)
+ .chooseOperatingSystem(testComputerEngine)
+ .chooseMachineClass(testComputerEngine)
+ .chooseMachineType(testComputerEngine)
+ .pickGPUs()
+ .chooseNumberOfGPUs(testComputerEngine)
+ .chooseGPuType(testComputerEngine)
+ .chooseLocalSsd(testComputerEngine)
+ .chooseDatacenterLocation(testComputerEngine)
+ .chooseCommittedUsage(testComputerEngine)
+ .getEstimation();
+
+ CloudCalkulationResultPage cloudCalkulationResultPage = new CloudCalkulationResultPage(driver);
+
+ String estimatedCostByPage = cloudCalkulationResultPage.getTotalEstimatedCost();
+
+ EmailYourEstimatePage emailYourEstimatePage = cloudCalkulationResultPage.chooseEmailEstimate();
+
+ String emailEstimateWindowHandle = emailYourEstimatePage.getCurrentWindowHandle();
+ emailYourEstimatePage.openNewTabWithUrl(temporaryMail);
+
+ CrazyMailingPage crazyMailingPage = new CrazyMailingPage(driver);
+ String emailAddress = crazyMailingPage.getEmail();
+ String crazyMailingWindowHandle = crazyMailingPage.getCurrentWindowHandle();
+ crazyMailingPage.goToTabByWindowHandle(emailEstimateWindowHandle);
+
+ new EmailYourEstimatePage(driver).fillEmailField(emailAddress)
+ .sendEmail()
+ .goToTabByWindowHandle(crazyMailingWindowHandle);
+
+ String totalEstimateCostFromEmail = crazyMailingPage.openEmailBySubject(emailSubject)
+ .getTotalEstimateCost().trim();
+
+ String[] estimatedCostArray = estimatedCostByPage.split(":");
+ String expectedEstimatedCostValue = estimatedCostArray[1].replaceAll("per 1 month", "").trim();
+
+// Assert.assertEquals(expectedEstimatedCostValue, totalEstimateCostFromEmail);
+ assertThat(expectedEstimatedCostValue, is(equalTo(totalEstimateCostFromEmail)));
+
+
+ }
+
+}
diff --git a/cloudAutomation/src/test/java/test/CommonConditions.java b/cloudAutomation/src/test/java/test/CommonConditions.java
new file mode 100644
index 0000000..87e5fcb
--- /dev/null
+++ b/cloudAutomation/src/test/java/test/CommonConditions.java
@@ -0,0 +1,21 @@
+package test;
+
+import Utils.TestListener;
+import driver.DriverSingletone;
+import org.openqa.selenium.WebDriver;
+import org.testng.annotations.AfterMethod;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Listeners;
+
+@Listeners({TestListener.class})
+public class CommonConditions {
+ protected WebDriver driver;
+ @BeforeMethod(alwaysRun = true)
+ public void browserSetup() {
+ driver = DriverSingletone.getDriver();
+ }
+ @AfterMethod(alwaysRun = true)
+ public void browserClose() {
+ DriverSingletone.closeDriver();
+ }
+}
diff --git a/cloudAutomation/src/test/java/test/FindInitialBtnTest.java b/cloudAutomation/src/test/java/test/FindInitialBtnTest.java
new file mode 100644
index 0000000..4395bfc
--- /dev/null
+++ b/cloudAutomation/src/test/java/test/FindInitialBtnTest.java
@@ -0,0 +1,24 @@
+package test;
+
+import org.testng.Assert;
+import org.testng.annotations.Test;
+import page.initialPages.CloudHomePage;
+
+import static org.hamcrest.CoreMatchers.equalTo;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.is;
+
+public class FindInitialBtnTest extends CommonConditions{
+ @Test(description = "Find initial button")
+ public void FindInitialBtn () {
+ System.out.println("*****");
+// Assert.fail();
+ String expectedlBtnName = "See products";
+ CloudHomePage cloudHomePage = new CloudHomePage(driver);
+
+ String currentBtnName = cloudHomePage.openPage()
+ .seeAllProductsBtnName();
+// Assert.assertEquals(currentBtnName, expectedlBtnName);
+ assertThat(currentBtnName, is(equalTo(expectedlBtnName)));
+ }
+}
diff --git a/cloudAutomation/src/test/resources/dev.properties b/cloudAutomation/src/test/resources/dev.properties
new file mode 100644
index 0000000..f23e8d1
--- /dev/null
+++ b/cloudAutomation/src/test/resources/dev.properties
@@ -0,0 +1,9 @@
+number.of.instances = 2;
+operating.system = "Free: Debian, CentOS, CoreOS, Ubuntu, or other User Provided OS";
+machine.class = "Regular";
+machine.type = "n1-standard-16 (vCPUs: 16, RAM: 60GB)";
+number.of.gpu = 2;
+gpu.type = "NVIDIA Tesla V100";
+local.ssd = "2x375 GB";
+datacenter.location = "Frankfurt (europe-west3)";
+commited.usach = "1 Year";
\ No newline at end of file
diff --git a/cloudAutomation/src/test/resources/log4j2.xml b/cloudAutomation/src/test/resources/log4j2.xml
new file mode 100644
index 0000000..781b267
--- /dev/null
+++ b/cloudAutomation/src/test/resources/log4j2.xml
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<Configuration>
+ <Appenders>
+ <Console name="Consol">
+ <PatternLayout>
+ <Pattern>%d %p %c{2} [%t] %l %m%n</Pattern>
+ </PatternLayout>
+ </Console>
+ <File name="File" filename="target/logs/cloudAutomation.log">
+ <PatternLayot>
+ <Pattern>%d %p %c{2} [%t] %l %m%n</Pattern>
+ </PatternLayot>
+ </File>
+ </Appenders>
+ <Loggers>
+ <Root level="trace">
+ <AppenderRef ref="Consol"/>
+ <AppenderRef ref="File"/>
+ </Root>
+ </Loggers>
+</Configuration>
\ No newline at end of file
diff --git a/cloudAutomation/src/test/resources/qa.properties b/cloudAutomation/src/test/resources/qa.properties
new file mode 100644
index 0000000..e337e8c
--- /dev/null
+++ b/cloudAutomation/src/test/resources/qa.properties
@@ -0,0 +1,11 @@
+number.of.instances = 4
+operating.system = Free: Debian, CentOS, CoreOS, Ubuntu, or other User Provided OS
+machine.class = Regular
+machine.type = n1-standard-8 (vCPUs: 8, RAM: 30GB)
+number.of.gpu = 1
+gpu.type = NVIDIA Tesla V100
+local.ssd = 2x375 GB
+datacenter.location = Frankfurt (europe-west3)
+commited.usach = 1 Year
+
+
diff --git a/cloudAutomation/src/test/resources/testng-all.xml b/cloudAutomation/src/test/resources/testng-all.xml
new file mode 100644
index 0000000..430ac45
--- /dev/null
+++ b/cloudAutomation/src/test/resources/testng-all.xml
@@ -0,0 +1,8 @@
+<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
+<suite name="All tests" verbose="1">
+ <test name="All tests">
+ <classes>
+ <class name="test.CloudTestRun"/>
+ </classes>
+ </test>
+</suite>
\ No newline at end of file
diff --git a/cloudAutomation/src/test/resources/testng-smoke.xml b/cloudAutomation/src/test/resources/testng-smoke.xml
new file mode 100644
index 0000000..186f96b
--- /dev/null
+++ b/cloudAutomation/src/test/resources/testng-smoke.xml
@@ -0,0 +1,8 @@
+<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
+<suite name="Smoke" verbose="1">
+ <test name="Find initial btn test">
+ <classes>
+ <class name="test.FindInitialBtnTest"/>
+ </classes>
+ </test>
+</suite>
\ No newline at end of file