Skip to content

Commit ab4cd04

Browse files
author
Kamil Nowocin
committed
feat: Major build update
1 parent 0a5bd16 commit ab4cd04

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+1399
-596
lines changed

build.gradle

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,13 @@ dependencies {
4949
compile group: 'org.apache.poi', name: 'poi-ooxml', version: '4.1.2'
5050
// https://mvnrepository.com/artifact/org.hamcrest/hamcrest
5151
testCompile group: 'org.hamcrest', name: 'hamcrest', version: '2.2'
52+
// https://mvnrepository.com/artifact/joda-time/joda-time
53+
compile group: 'joda-time', name: 'joda-time', version: '2.10.5'
54+
// https://mvnrepository.com/artifact/io.cucumber/cucumber-guice
55+
compile group: 'io.cucumber', name: 'cucumber-guice', version: '4.8.0'
56+
// https://mvnrepository.com/artifact/com.google.inject/guice
57+
compile group: 'com.google.inject', name: 'guice', version: '4.2.2'
58+
5259

5360
implementation("com.google.guava:guava:28.1-jre")
5461
testImplementation 'io.cucumber:cucumber-java:4.3.1'
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
package com;
2+
3+
import cucumber.runtime.java.guice.ScenarioScoped;
4+
5+
/**
6+
* Test_Automation-automationpractice
7+
*
8+
* @author kamil.nowocin
9+
**/
10+
11+
@ScenarioScoped
12+
public class ContextInjection {
13+
14+
/**
15+
* DATA SETS
16+
**/
17+
public String generatedEmail;
18+
public String paymentType;
19+
20+
public String productName;
21+
public String productSize;
22+
public String productColor;
23+
public double productQuantity;
24+
public double productUnitPrice;
25+
public double finalOrderTotalPrice;
26+
public double finalProductTotalPrice;
27+
28+
/**
29+
* DEFAULT
30+
**/
31+
//CUSTOMER DATA//
32+
public final String defaultCustomerUserName = "Thor Odinson";
33+
public final String defaultCustomerFirstLastName = "Thor Odinson";
34+
public final String defaultCustomerCompanyName = "Avengers";
35+
public final String defaultCustomerAddress = "Asgard";
36+
public final String defaultCustomerCountry = "United States";
37+
public final String defaultCustomerMobilePhone = "600500400";
38+
39+
//NAVIGATION MENU LABELS//
40+
public final String yourShoppingCart = "Your shopping cart";
41+
public final String addresses = "Addresses";
42+
public final String shipping = "Shipping";
43+
public final String yourPaymentMethod = "Your payment method";
44+
public final String orderConfirmation = "Order confirmation";
45+
46+
//ORDER DATA//
47+
public final double SHIPPING_PRICE = 2.00;
48+
public final double TAX_VALUE = 0;
49+
}

src/test/java/com/DriverFactory.java

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,37 +61,45 @@ protected RemoteWebDriver remoteWebDriver(DesiredCapabilities desiredCapabilitie
6161
}
6262

6363
protected void startBrowser() {
64+
printWebDriverManagerVersions(false);
6465
DesiredCapabilities desiredCapabilities = null;
6566
if (driver == null) {
6667
switch (getHost().toLowerCase()) {
6768
case "chrome":
68-
WebDriverManager.chromedriver().setup();
69+
WebDriverManager.chromedriver().version("79.0.3945.36").setup();
6970
ChromeOptions chromeOptions = new ChromeOptions();
7071
chromeOptions.addArguments();
7172
driver = new ChromeDriver(chromeOptions);
7273
break;
74+
7375
case "firefox":
7476
WebDriverManager.firefoxdriver().setup();
7577
FirefoxOptions firefoxOptions = new FirefoxOptions();
7678
firefoxOptions.addArguments("");
7779
driver = new FirefoxDriver(firefoxOptions);
7880
break;
81+
7982
case "opera":
8083
WebDriverManager.operadriver().arch64().version("2.45").setup();
8184
OperaOptions operaOptions = new OperaOptions();
8285
operaOptions.addArguments("");
8386
driver = new OperaDriver(operaOptions);
8487
break;
85-
case "safari":
86-
driver = new SafariDriver();
87-
break;
88+
8889
case "edge":
8990
WebDriverManager.edgedriver().setup();
9091
driver = new EdgeDriver();
92+
break;
93+
9194
case "ie":
9295
WebDriverManager.iedriver().setup();
9396
driver = new InternetExplorerDriver();
9497
break;
98+
99+
case "safari":
100+
driver = new SafariDriver();
101+
break;
102+
95103
case "browserstack":
96104
desiredCapabilities = new DesiredCapabilities();
97105
desiredCapabilities.setCapability("os", "Windows");
@@ -116,6 +124,7 @@ protected void startBrowser() {
116124
//https://USER_NAME:[email protected]/wd/hub <- HOST_URL (.travis.yml for more information)
117125
driver = remoteWebDriver(desiredCapabilities, HOST_URL);
118126
break;
127+
119128
default:
120129
throw new IllegalStateException("This browser isn't supported yet! Sorry...");
121130
}

src/test/java/com/ExcelEnvironment.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,17 @@
1717

1818
public class ExcelEnvironment extends FrameworkEnvironment {
1919

20-
private static final String testDataExcelFileName = "testdata.xlsx";
2120
private static String testDataExcelPath = null;
22-
private static XSSFWorkbook excelWorkBook;
23-
private static XSSFSheet excelSheet;
21+
2422
private static XSSFRow excelRow;
23+
private static XSSFSheet excelSheet;
24+
private static XSSFWorkbook excelWorkBook;
2525

2626
public static int excelRowNumber;
2727

28+
public static final String testDataExcelFileName = "testdata.xlsx";
29+
public static final String testDataExcelSheetName = "automationData";
30+
2831
public static void setExcelRowNumber(int _rowNumber) {
2932
excelRowNumber = _rowNumber;
3033
}

src/test/java/com/FrameworkEnvironment.java

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import com.listeners.TestNGListener_WEB;
55
import com.steps.Hooks;
66
import cucumber.api.Scenario;
7+
import io.github.bonigarcia.wdm.WebDriverManager;
78
import io.qameta.allure.Attachment;
89
import net.andreinc.mockneat.MockNeat;
910
import org.apache.commons.io.FileUtils;
@@ -22,6 +23,7 @@
2223
import java.nio.file.Files;
2324
import java.nio.file.Path;
2425
import java.nio.file.Paths;
26+
import java.text.DecimalFormat;
2527
import java.text.SimpleDateFormat;
2628
import java.util.Date;
2729
import java.util.Locale;
@@ -40,14 +42,12 @@ public class FrameworkEnvironment {
4042
protected static Logger logger = LoggerFactory.getLogger(Hooks.class);
4143
protected static Faker faker = new Faker(new Locale("en-US"));
4244
protected static MockNeat mockNeat = MockNeat.threadLocal();
45+
protected static DecimalFormat decimalFormat = new DecimalFormat("#0.00");
4346

4447
//BUNDLES//
4548
protected static final ResourceBundle resourceBundleInvalidEmails = ResourceBundle.getBundle("invalidEmails");
4649
protected static final ResourceBundle resourceBundleErrorMessages = ResourceBundle.getBundle("errorValidators");
4750

48-
//DYNAMIC DATA//
49-
protected final String tempEmail = mockNeat.emails().val();
50-
5151
//STATIC DATA//
5252
protected static final int TIMEOUT = 15;
5353
protected static final int EXCEL_TC_NAME_COLUMN = 0;
@@ -57,7 +57,7 @@ public class FrameworkEnvironment {
5757
protected static final String ANSI_BLUE = "\u001b[34m";
5858
protected static final String ANSI_GREEN = "\u001B[32m";
5959
protected static final String EXECUTOR = "GRADLE";
60-
protected static final String HOME_URL = "http://automationpractice.com/index.php";
60+
protected static final String HOME_URL = "http://automationpractice.com";
6161
protected static final String TODAY_DATE = new SimpleDateFormat("yyyy-MM-dd HH:ss").format(new Date());
6262

6363
//MESSAGES//
@@ -190,7 +190,17 @@ protected void deleteOldLogs() {
190190
.map(Path::toFile)
191191
.forEach(File::delete);
192192
} catch (IOException e) {
193-
logger.error("Failed to delete logs files!", e);
193+
logger.error("Failed to delete log files!", e);
194+
}
195+
}
196+
197+
public void printWebDriverManagerVersions(Boolean boolStatus) {
198+
if (boolStatus) {
199+
logger.info("ChromeDriver available versions: " + WebDriverManager.chromedriver().getVersions() + "\n");
200+
logger.info("GeckoDriver available versions: " + WebDriverManager.firefoxdriver().getVersions() + "\n");
201+
logger.info("OperaDriver available versions: " + WebDriverManager.operadriver().getVersions() + "\n");
202+
logger.info("EdgeDriver available versions: " + WebDriverManager.edgedriver().getVersions() + "\n");
203+
logger.info("IE available versions: " + WebDriverManager.iedriver().getVersions());
194204
}
195205
}
196206
}

src/test/java/com/listeners/TestNGRetry.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,11 @@ public boolean retry(ITestResult iTestResult) {
2121
if (retryStatus < retryLimit) {
2222
retryStatus++;
2323
iTestResult.setStatus(ITestResult.FAILURE);
24-
logger.info(String.format(ANSI_RED + "TEST WILL BE REPEATED (%d/2): %S" + ANSI_RESET,
25-
retryStatus, iTestResult.getMethod().getDescription()));
24+
logger.info(String.format(ANSI_RED + "TEST WILL BE REPEATED (%d/2): %S" + ANSI_RESET, retryStatus,
25+
iTestResult.getMethod().getDescription()));
2626
return true;
2727
}
28+
2829
} else {
2930
iTestResult.setStatus(ITestResult.SUCCESS);
3031
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package com.pages;
2+
3+
import com.pages.base.BasePage;
4+
import org.openqa.selenium.WebElement;
5+
import org.openqa.selenium.support.FindBy;
6+
import org.openqa.selenium.support.How;
7+
8+
/**
9+
* Test_Automation-automationpractice
10+
*
11+
* @author kamil.nowocin
12+
**/
13+
14+
public class AccountDetailsPage extends BasePage {
15+
16+
//VIEW//
17+
@FindBy(how = How.CSS, using = "#center_column > p")
18+
public WebElement myAccountDetailsDashboard;
19+
}

src/test/java/com/pages/AuthenticationPage.java

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,29 +13,42 @@
1313

1414
public class AuthenticationPage extends BasePage {
1515

16-
//CREATE AN ACCOUNT
16+
/**
17+
* CREATE AN ACCOUNT
18+
**/
19+
//VIEW//
20+
@FindBy(how = How.ID, using = "create-account_form")
21+
public WebElement createAccountPane;
22+
23+
//BUTTONS & INPUTS & DROPDOWN//
1724
@FindBy(how = How.ID, using = "email_create")
18-
public WebElement registerNewEmailInput;
25+
public WebElement createAnAccountEmailInput;
1926

2027
@FindBy(how = How.ID, using = "SubmitCreate")
2128
public WebElement createAnAccountButton;
2229

30+
//MESSAGES//
2331
@FindBy(how = How.ID, using = "create_account_error")
2432
public WebElement createAnAccountError;
2533

26-
//ALREADY REGISTERED
34+
/**
35+
* ALREADY REGISTERED
36+
**/
37+
//VIEW//
2738
@FindBy(how = How.ID, using = "login_form")
28-
public WebElement loginForm;
39+
public WebElement registeredPane;
2940

41+
//BUTTONS & INPUTS & DROPDOWN//
3042
@FindBy(how = How.ID, using = "email")
31-
public WebElement emailInput;
43+
public WebElement registeredEmailInput;
3244

3345
@FindBy(how = How.ID, using = "passwd")
34-
public WebElement passwordInput;
46+
public WebElement registeredPasswordInput;
3547

3648
@FindBy(how = How.ID, using = "SubmitLogin")
37-
public WebElement signInButton;
49+
public WebElement registeredSignInButton;
3850

51+
//MESSAGES//
3952
@FindBy(how = How.CSS, using = "#center_column > div.alert.alert-danger")
40-
public WebElement loginError;
53+
public WebElement registeredLoginError;
4154
}

src/test/java/com/pages/CustomerServicePage.java

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,23 +13,19 @@
1313

1414
public class CustomerServicePage extends BasePage {
1515

16+
//VIEW//
1617
@FindBy(how = How.XPATH, using = "//h1[@class='page-heading bottom-indent']")
1718
public WebElement contactUsHeader;
1819

1920
@FindBy(how = How.XPATH, using = "//form[@class='contact-form-box']")
20-
public WebElement contactUsForm;
21-
22-
@FindBy(how = How.XPATH, using = "//div[@class='alert alert-danger']//li")
23-
public WebElement contactUsErrorMessage;
24-
25-
@FindBy(how = How.XPATH, using = "//p[@class='alert alert-success']")
26-
public WebElement contactUsSuccessMessage;
21+
public WebElement contactUsPane;
2722

23+
//BUTTONS & INPUTS & DROPDOWN//
2824
@FindBy(how = How.XPATH, using = "//div[@class='col-xs-12 col-md-3']//select[@id='id_contact']")
2925
public WebElement subjectHeadingDropdown;
3026

3127
@FindBy(how = How.XPATH, using = "//div[@class='col-xs-12 col-md-3']//div[@class='form-group selector1']//span")
32-
public WebElement chosenSubjectHeadingFromDropdown;
28+
public WebElement readSubjectHeading;
3329

3430
@FindBy(how = How.XPATH, using = "//div[@class='col-xs-12 col-md-3']//input[@id='email']")
3531
public WebElement emailAddressInput;
@@ -44,11 +40,18 @@ public class CustomerServicePage extends BasePage {
4440
public WebElement chooseFileButton;
4541

4642
@FindBy(how = How.XPATH, using = "//div[@class='col-xs-12 col-md-3']//span[@class='filename']")
47-
public WebElement chosenFileName;
43+
public WebElement readFileName;
4844

4945
@FindBy(how = How.XPATH, using = "//div[@class='col-xs-12 col-md-9']//textarea[@class='form-control']")
5046
public WebElement messageTextArea;
5147

5248
@FindBy(how = How.XPATH, using = "//div[@class='submit']//button")
5349
public WebElement sendButton;
50+
51+
//MESSAGES//
52+
@FindBy(how = How.XPATH, using = "//div[@class='alert alert-danger']//li")
53+
public WebElement contactUsErrorMessage;
54+
55+
@FindBy(how = How.XPATH, using = "//p[@class='alert alert-success']")
56+
public WebElement contactUsSuccessMessage;
5457
}

0 commit comments

Comments
 (0)