├── .gitignore
├── configuration.properties
├── configurationTwo.properties
├── pom.xml
├── smoke_test_runner.xml
├── src
└── test
│ ├── java
│ └── com
│ │ └── cybertek
│ │ ├── pages
│ │ ├── BasePage.java
│ │ ├── CalendarEventsPage.java
│ │ ├── ContactInfoPage.java
│ │ ├── ContactsPage.java
│ │ ├── CreateCalendarEventsPage.java
│ │ ├── DashboardPage.java
│ │ ├── LoginPage.java
│ │ └── adidasPages
│ │ │ ├── BasePageForAdidas.java
│ │ │ ├── CartPage.java
│ │ │ └── ProductPage.java
│ │ ├── tests
│ │ ├── TestBase.java
│ │ ├── TestBaseTwo.java
│ │ ├── day10_actions_js
│ │ │ ├── ActionsTest.java
│ │ │ ├── HoverTest.java
│ │ │ └── JavaScriptExecutorDemo.java
│ │ ├── day10_file_upload
│ │ │ ├── FilePathExample.java
│ │ │ └── FileUploadTest.java
│ │ ├── day11_webtables
│ │ │ └── WebTablesExample.java
│ │ ├── day12_properties_driver_tests
│ │ │ ├── AnotherLoginTest.java
│ │ │ ├── LoginTest.java
│ │ │ ├── PropertiesTest.java
│ │ │ ├── Singleton.java
│ │ │ └── SingletonTest.java
│ │ ├── day13_pom
│ │ │ ├── NegativeLoginTest.java
│ │ │ ├── PageSubtitleTest.java
│ │ │ ├── PositiveLoginTest.java
│ │ │ └── RepeatOptionsTests.java
│ │ ├── day14_extent_reports
│ │ │ ├── ExtentDemoTest.java
│ │ │ └── NegativeLoginTestWithReport.java
│ │ ├── day15_review
│ │ │ └── verifyContactInfoTest.java
│ │ ├── day16_ddf
│ │ │ ├── DDFLoginTest.java
│ │ │ ├── DDFWithDataProvider.java
│ │ │ └── ExcelUtilsDemo.java
│ │ ├── day1_intro
│ │ │ └── OpenBrowser.java
│ │ ├── day2_webdriver_basics
│ │ │ ├── CallWebDriverFactory.java
│ │ │ ├── CloseAndQuit.java
│ │ │ ├── GetTitleAndUrl.java
│ │ │ └── NavigationDemo.java
│ │ ├── day3_webelement_intro
│ │ │ ├── verifyConfirmationMessage.java
│ │ │ ├── verifyURLchanged.java
│ │ │ └── verifyURLnotChanged.java
│ │ ├── day4_basic_locators
│ │ │ ├── IDLocatorTest.java
│ │ │ ├── classNameTest.java
│ │ │ ├── linkTextandPartialLinkText.java
│ │ │ ├── nameLocatorTest.java
│ │ │ └── tagNameLocator.java
│ │ ├── day5_xpath
│ │ │ ├── AmazonTest.java
│ │ │ └── xPathLocator.java
│ │ ├── day6_css
│ │ │ └── cssLocator.java
│ │ ├── day7_testng
│ │ │ ├── BeforeAfterMethod.java
│ │ │ ├── FirstTestNGTest.java
│ │ │ └── TestNGAssertionsDemo.java
│ │ ├── day7_types_of_elements
│ │ │ ├── AttributeTest.java
│ │ │ ├── CheckboxDemo.java
│ │ │ ├── DisabledElements.java
│ │ │ ├── DisplayedDemo.java
│ │ │ └── RadioButtonTest.java
│ │ ├── day8_types_of_elements_2
│ │ │ ├── ListOfElements.java
│ │ │ ├── NoSelectDropdown.java
│ │ │ └── SelectDropdownTest.java
│ │ ├── day9_popups_tabs_frames
│ │ │ ├── MultipleWindows.java
│ │ │ ├── PopupsAndAlerts.java
│ │ │ └── iframeTest.java
│ │ ├── day9_waits
│ │ │ ├── ExplicitWaitExample.java
│ │ │ ├── ImplicitWaitExample.java
│ │ │ └── ThreadSleepExample.java
│ │ └── reviews
│ │ │ ├── week01
│ │ │ ├── NotesOfTheWeek
│ │ │ ├── T01_YahooPractice.java
│ │ │ └── T02_CybertekUrlTask.java
│ │ │ ├── week02
│ │ │ ├── LocatorHWTest.java
│ │ │ ├── Notes.txt
│ │ │ └── Task2.java
│ │ │ ├── week03
│ │ │ ├── CheckBoxHW.java
│ │ │ └── Notes.txt
│ │ │ ├── week04
│ │ │ ├── ChercherTest.java
│ │ │ └── DropdownTest.java
│ │ │ ├── week5
│ │ │ ├── ActionsandIframeTest.java
│ │ │ ├── AdidasTask.java
│ │ │ └── ScrollingTest.java
│ │ │ ├── week6
│ │ │ └── AdidasTaskWithPOM.java
│ │ │ └── week7
│ │ │ ├── DataProviderExample.java
│ │ │ ├── ExcelDDFTest.java
│ │ │ ├── ExelTestExamples.java
│ │ │ ├── HWTests.java
│ │ │ ├── Notes.txt
│ │ │ └── TestBaseForHW.java
│ │ └── utilities
│ │ ├── BrowserUtils.java
│ │ ├── ConfigurationReader.java
│ │ ├── ConfigurationReaderTwo.java
│ │ ├── Driver.java
│ │ ├── ExcelUtil.java
│ │ └── WebDriverFactory.java
│ └── resources
│ ├── StatusCodes.xlsx
│ ├── Vytracktestdata.xlsx
│ └── textfile.txt
└── testng_runner.xml
/.gitignore:
--------------------------------------------------------------------------------
1 | /target/
2 | /.idea/
3 |
--------------------------------------------------------------------------------
/configuration.properties:
--------------------------------------------------------------------------------
1 | browser=chrome
2 | url=https://qa1.vytrack.com
3 | qa1_url=https://qa1.vytrack.com
4 | qa2_url=https://qa2.vytrack.com
5 | qa3_url=https://qa3.vytrack.com
6 | driver_username=user1
7 | driver_password=UserUser123
8 | salesmanager_username=salesmanager120
9 | salesmanager_password=UserUser123
10 | storemanager_username=storemanager85
11 | storemanager_password=UserUser123
12 |
13 |
--------------------------------------------------------------------------------
/configurationTwo.properties:
--------------------------------------------------------------------------------
1 | browser=chrome
2 | demoblaze.url=https://www.demoblaze.com/index.html
--------------------------------------------------------------------------------
/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 4.0.0
6 |
7 | org.example
8 | EU7TestNGSelenium
9 | 1.0-SNAPSHOT
10 |
11 |
12 | 1.8
13 | 1.8
14 |
15 |
16 |
17 |
18 | com.github.javafaker
19 | javafaker
20 | 1.0.2
21 |
22 |
23 |
24 |
25 | org.seleniumhq.selenium
26 | selenium-java
27 | 3.141.59
28 |
29 |
30 |
31 |
32 | io.github.bonigarcia
33 | webdrivermanager
34 | 5.0.3
35 |
36 |
37 | org.testng
38 | testng
39 | 7.1.0
40 | test
41 |
42 |
43 |
44 | com.aventstack
45 | extentreports
46 | 4.0.9
47 |
48 |
49 |
50 |
51 | org.apache.poi
52 | poi
53 | 4.1.2
54 |
55 |
56 |
57 |
58 | org.apache.poi
59 | poi-ooxml
60 | 4.1.2
61 |
62 |
63 | org.projectlombok
64 | lombok
65 | RELEASE
66 | test
67 |
68 |
69 |
70 |
--------------------------------------------------------------------------------
/smoke_test_runner.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/src/test/java/com/cybertek/pages/BasePage.java:
--------------------------------------------------------------------------------
1 | package com.cybertek.pages;
2 |
3 | import com.cybertek.utilities.BrowserUtils;
4 | import com.cybertek.utilities.Driver;
5 | import org.openqa.selenium.By;
6 | import org.openqa.selenium.WebElement;
7 | import org.openqa.selenium.interactions.Actions;
8 | import org.openqa.selenium.support.CacheLookup;
9 | import org.openqa.selenium.support.FindBy;
10 | import org.openqa.selenium.support.PageFactory;
11 | import org.openqa.selenium.support.ui.ExpectedConditions;
12 | import org.openqa.selenium.support.ui.WebDriverWait;
13 |
14 | public abstract class BasePage {
15 |
16 | @FindBy(css = "div[class='loader-mask shown']")
17 | @CacheLookup
18 | protected WebElement loaderMask;
19 |
20 | @FindBy(css = "h1[class='oro-subtitle']")
21 | public WebElement pageSubTitle;
22 |
23 | @FindBy(css = "#user-menu > a")
24 | public WebElement userName;
25 |
26 | @FindBy(linkText = "Logout")
27 | public WebElement logOutLink;
28 |
29 | @FindBy(linkText = "My User")
30 | public WebElement myUser;
31 |
32 | public BasePage() {
33 | PageFactory.initElements(Driver.get(), this);
34 | }
35 |
36 |
37 | /**
38 | * @return page name, for example: Dashboard
39 | */
40 | public String getPageSubTitle() {
41 | //ant time we are verifying page name, or page subtitle, loader mask appears
42 | waitUntilLoaderScreenDisappear();
43 | // BrowserUtils.waitForStaleElement(pageSubTitle);
44 | return pageSubTitle.getText();
45 | }
46 |
47 |
48 | /**
49 | * Waits until loader screen present. If loader screen will not pop up at all,
50 | * NoSuchElementException will be handled bu try/catch block
51 | * Thus, we can continue in any case.
52 | */
53 | public void waitUntilLoaderScreenDisappear() {
54 | try {
55 | WebDriverWait wait = new WebDriverWait(Driver.get(), 5);
56 | wait.until(ExpectedConditions.invisibilityOf(loaderMask));
57 | } catch (Exception e) {
58 | e.printStackTrace();
59 | }
60 |
61 | }
62 |
63 | public String getUserName(){
64 | waitUntilLoaderScreenDisappear();
65 | BrowserUtils.waitForVisibility(userName, 5);
66 | return userName.getText();
67 | }
68 |
69 |
70 |
71 | public void logOut(){
72 | BrowserUtils.waitFor(2);
73 | BrowserUtils.clickWithJS(userName);
74 | BrowserUtils.clickWithJS(logOutLink);
75 | }
76 | public void goToMyUser(){
77 | waitUntilLoaderScreenDisappear();
78 | BrowserUtils.waitForClickablility(userName, 5).click();
79 | BrowserUtils.waitForClickablility(myUser, 5).click();
80 |
81 | }
82 |
83 | /**
84 | * This method will navigate user to the specific module in vytrack application.
85 | * For example: if tab is equals to Activities, and module equals to Calls,
86 | * Then method will navigate user to this page: http://qa2.vytrack.com/call/
87 | *
88 | * @param tab
89 | * @param module
90 | */
91 | public void navigateToModule(String tab, String module) {
92 | String tabLocator = "//span[normalize-space()='" + tab + "' and contains(@class, 'title title-level-1')]";
93 | // String moduleLocator2 = "//span[@class='title title-level-1' and contains(text(),'"+ module + "')]";
94 |
95 | String moduleLocator = "//span[normalize-space()='" + module + "' and contains(@class, 'title title-level-2')]";
96 | // String moduleLocator2 = "//span[@class='title title-level-2' and contains(text(),'"+ module + "')]";
97 | try {
98 | BrowserUtils.waitForClickablility(By.xpath(tabLocator), 5);
99 | WebElement tabElement = Driver.get().findElement(By.xpath(tabLocator));
100 | new Actions(Driver.get()).moveToElement(tabElement).pause(200).doubleClick(tabElement).build().perform();
101 | } catch (Exception e) {
102 | BrowserUtils.clickWithWait(By.xpath(tabLocator), 5);
103 | }
104 | try {
105 | BrowserUtils.waitForPresenceOfElement(By.xpath(moduleLocator), 5);
106 | BrowserUtils.waitForVisibility(By.xpath(moduleLocator), 5);
107 | BrowserUtils.scrollToElement(Driver.get().findElement(By.xpath(moduleLocator)));
108 | Driver.get().findElement(By.xpath(moduleLocator)).click();
109 | } catch (Exception e) {
110 | BrowserUtils.clickWithTimeOut(Driver.get().findElement(By.xpath(moduleLocator)), 5);
111 |
112 | }
113 | }
114 |
115 | }
--------------------------------------------------------------------------------
/src/test/java/com/cybertek/pages/CalendarEventsPage.java:
--------------------------------------------------------------------------------
1 | package com.cybertek.pages;
2 |
3 | import com.cybertek.utilities.Driver;
4 | import org.openqa.selenium.WebElement;
5 | import org.openqa.selenium.support.FindBy;
6 | import org.openqa.selenium.support.PageFactory;
7 |
8 | public class CalendarEventsPage extends BasePage {
9 |
10 | public CalendarEventsPage() {
11 | PageFactory.initElements(Driver.get(), this);
12 | }
13 |
14 | @FindBy(css = "[title='Create Calendar event']")
15 | public WebElement createCalendarEvent;
16 |
17 | @FindBy(css = "div[class='btn btn-link dropdown-toggle']")
18 | public WebElement optionsLink;
19 |
20 | @FindBy(css = "input[type='number']")
21 | public WebElement pageNumber;
22 |
23 | @FindBy(css = "button[class='btn dropdown-toggle ']")
24 | public WebElement viewPerPage;
25 |
26 |
27 | }
--------------------------------------------------------------------------------
/src/test/java/com/cybertek/pages/ContactInfoPage.java:
--------------------------------------------------------------------------------
1 | package com.cybertek.pages;
2 |
3 | import org.openqa.selenium.WebElement;
4 | import org.openqa.selenium.support.FindBy;
5 |
6 | public class ContactInfoPage extends BasePage{
7 |
8 | @FindBy(css = "div.pull-left>h1.user-name")
9 | public WebElement fullName;
10 |
11 | @FindBy(css = "a.phone")
12 | public WebElement phone;
13 |
14 | @FindBy(css = "a.email")
15 | public WebElement email;
16 | }
17 |
--------------------------------------------------------------------------------
/src/test/java/com/cybertek/pages/ContactsPage.java:
--------------------------------------------------------------------------------
1 | package com.cybertek.pages;
2 |
3 | import com.cybertek.utilities.Driver;
4 | import org.openqa.selenium.By;
5 | import org.openqa.selenium.WebElement;
6 |
7 | public class ContactsPage extends BasePage{
8 |
9 | //since we are extending BasePage we do not need explicit constructor for this class
10 |
11 | // @FindBy(xpath = "//td[contains(text(),'mbrackstone9@example.com')][@data-column-label='Email']")
12 | // public WebElement email;
13 |
14 | public WebElement getContactEmail(String email){
15 | String xpath ="//td[contains(text(),'"+email+"')][@data-column-label='Email']";
16 | return Driver.get().findElement(By.xpath(xpath));
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/src/test/java/com/cybertek/pages/CreateCalendarEventsPage.java:
--------------------------------------------------------------------------------
1 | package com.cybertek.pages;
2 |
3 |
4 | import com.cybertek.utilities.Driver;
5 | import org.openqa.selenium.WebElement;
6 | import org.openqa.selenium.support.FindBy;
7 | import org.openqa.selenium.support.PageFactory;
8 | import org.openqa.selenium.support.ui.Select;
9 |
10 | public class CreateCalendarEventsPage extends BasePage {
11 |
12 | public CreateCalendarEventsPage(){
13 | PageFactory.initElements(Driver.get(), this);
14 | }
15 |
16 | @FindBy(css = "[id^='recurrence-repeat-view']")
17 | public WebElement repeat;
18 |
19 | @FindBy(css = "[id^='recurrence-repeats-view']")
20 | public WebElement repeatOptions;
21 |
22 | @FindBy(className = "select2-chosen")
23 | public WebElement selectedOwner;
24 |
25 | @FindBy(css = "input[id^='oro_calendar_event_form_title-']")
26 | public WebElement title;
27 |
28 | @FindBy(css = "[id^='date_selector_oro_calendar_event_form_start']")
29 | public WebElement startDate;
30 | @FindBy(css = "[id^='date_selector_oro_calendar_event_form_end']")
31 | public WebElement endDate;
32 |
33 | @FindBy(css = "[id^='time_selector_oro_calendar_event_form_start']")
34 | public WebElement startTime;
35 |
36 | @FindBy(css = "[id^='time_selector_oro_calendar_event_form_end']")
37 | public WebElement endTime;
38 |
39 | @FindBy(xpath = "(//input[@type='radio'])[1]")
40 | public WebElement days;
41 |
42 | @FindBy(xpath = "(//input[@type='radio'])[2]")
43 | public WebElement weekday;
44 |
45 | @FindBy(xpath = "(//input[@type='radio'])[3]")
46 | public WebElement never;
47 |
48 | @FindBy(xpath = "(//input[@type='radio'])[4]")
49 | public WebElement after;
50 |
51 | @FindBy(xpath = "(//input[@type='radio'])[5]")
52 | public WebElement by;
53 |
54 |
55 |
56 | public Select repeatOptionsList(){
57 | return new Select(repeatOptions);
58 | }
59 |
60 |
61 |
62 | }
--------------------------------------------------------------------------------
/src/test/java/com/cybertek/pages/DashboardPage.java:
--------------------------------------------------------------------------------
1 | package com.cybertek.pages;
2 |
3 | public class DashboardPage extends BasePage{
4 |
5 | //no need to explicitly write constructor, because it will use its parents constructor
6 |
7 | }
8 |
--------------------------------------------------------------------------------
/src/test/java/com/cybertek/pages/LoginPage.java:
--------------------------------------------------------------------------------
1 | package com.cybertek.pages;
2 |
3 | import com.cybertek.utilities.ConfigurationReader;
4 | import com.cybertek.utilities.Driver;
5 | import org.openqa.selenium.WebElement;
6 | import org.openqa.selenium.support.FindAll;
7 | import org.openqa.selenium.support.FindBy;
8 | import org.openqa.selenium.support.PageFactory;
9 |
10 | public class LoginPage {
11 |
12 | public LoginPage(){
13 | PageFactory.initElements(Driver.get(),this);
14 | }
15 |
16 | //driver.findElement(By.id("prependedInput"));
17 | @FindAll({
18 | @FindBy(id = "prependedInput"),
19 | @FindBy(name ="_username")
20 | })
21 | public WebElement usernameInput;
22 |
23 | @FindBy(id = "prependedInput2")
24 | public WebElement passwordInput;
25 |
26 | //driver.findElement(By.id("_submit"));
27 | @FindBy(id = "_submit")
28 | public WebElement loginBtn;
29 |
30 |
31 |
32 | public void login(String username,String password){
33 | usernameInput.sendKeys(username);
34 | passwordInput.sendKeys(password);
35 | loginBtn.click();
36 | }
37 |
38 | public void loginAsStoreManager(){
39 |
40 | String username = ConfigurationReader.get("storemanager_username");
41 | String password = ConfigurationReader.get("storemanager_password");
42 |
43 | usernameInput.sendKeys(username);
44 | passwordInput.sendKeys(password);
45 | loginBtn.click();
46 | }
47 |
48 | public void loginAsDriver(){
49 |
50 | String username = ConfigurationReader.get("driver_username");
51 | String password = ConfigurationReader.get("driver_password");
52 |
53 | usernameInput.sendKeys(username);
54 | passwordInput.sendKeys(password);
55 | loginBtn.click();
56 | }
57 |
58 | }
59 |
--------------------------------------------------------------------------------
/src/test/java/com/cybertek/pages/adidasPages/BasePageForAdidas.java:
--------------------------------------------------------------------------------
1 | package com.cybertek.pages.adidasPages;
2 |
3 | import com.cybertek.utilities.BrowserUtils;
4 | import com.cybertek.utilities.Driver;
5 | import org.openqa.selenium.Alert;
6 | import org.openqa.selenium.By;
7 | import org.openqa.selenium.WebElement;
8 | import org.openqa.selenium.support.PageFactory;
9 | import org.openqa.selenium.support.ui.ExpectedConditions;
10 | import org.openqa.selenium.support.ui.WebDriverWait;
11 |
12 | public abstract class BasePageForAdidas {
13 |
14 | public BasePageForAdidas(){
15 | PageFactory.initElements(Driver.get(),this);
16 | }
17 |
18 | public void navigateTo(String str){
19 | Driver.get().findElement(By.partialLinkText(str)).click();
20 | }
21 |
22 | public int productAdder(String category, String product){
23 | navigateTo(category);
24 | navigateTo(product);
25 | // I want to get my expected price for that product
26 | WebDriverWait wait = new WebDriverWait(Driver.get(),10);
27 | wait.until(ExpectedConditions.visibilityOfElementLocated(By.tagName("h3")));
28 | WebElement priceElement = Driver.get().findElement(By.tagName("h3"));
29 | String priceWholeText = priceElement.getText();
30 | String[] arr = priceWholeText.split(" ");
31 | int listPrice = Integer.parseInt(arr[0].substring(1));
32 |
33 | navigateTo("Add to cart");
34 | // handle pop up
35 | wait.until(ExpectedConditions.alertIsPresent());
36 | Alert alert = Driver.get().switchTo().alert();
37 | alert.accept();
38 | navigateTo("Home");
39 | return listPrice;
40 | }
41 |
42 | public int productRemover(String product) {
43 | // locator //tr[contains(.,'Sony vaio i5')]/td[4]/a
44 | // locator for price text : //tr[contains(.,'Sony vaio i5')]/td[3]
45 | navigateTo("Cart");
46 | WebElement priceElement = Driver.get().findElement(By.xpath("//tr[contains(.,'"+product+"')]/td[3]"));
47 | int price = Integer.parseInt(priceElement.getText());
48 | WebElement deleteButton = Driver.get().findElement(By.xpath("//tr[contains(.,'"+product+"')]/td[4]/a"));
49 | deleteButton.click();
50 | BrowserUtils.waitFor(3);
51 |
52 | return price;
53 | }
54 |
55 |
56 | }
57 |
--------------------------------------------------------------------------------
/src/test/java/com/cybertek/pages/adidasPages/CartPage.java:
--------------------------------------------------------------------------------
1 | package com.cybertek.pages.adidasPages;
2 |
3 | import com.github.javafaker.Faker;
4 | import org.openqa.selenium.By;
5 | import org.openqa.selenium.WebElement;
6 | import org.openqa.selenium.support.FindBy;
7 |
8 | public class CartPage extends BasePageForAdidas{
9 | // public CartPage(){
10 | // super();
11 | // } No need to call parent constructor, because it is already called
12 |
13 | @FindBy(css = "button[class='btn btn-success']")
14 | public WebElement placeOrderButton;
15 | @FindBy(id = "name")
16 | public WebElement nameFake;
17 | @FindBy(id = "country")
18 | public WebElement country;
19 | @FindBy(id = "city")
20 | public WebElement city;
21 | @FindBy(id = "card")
22 | public WebElement card;
23 | @FindBy(id = "month")
24 | public WebElement month;
25 | @FindBy(id = "year")
26 | public WebElement year;
27 |
28 |
29 |
30 | public void fillForm(){
31 | Faker faker = new Faker();
32 | nameFake.sendKeys(faker.name().fullName());
33 | country.sendKeys(faker.country().name());
34 | city.sendKeys(faker.country().capital());
35 | card.sendKeys(faker.finance().creditCard());
36 | month.sendKeys(""+faker.number().numberBetween(1,12));
37 | year.sendKeys(""+faker.number().numberBetween(2022,2025));
38 |
39 | }
40 |
41 |
42 | }
43 |
--------------------------------------------------------------------------------
/src/test/java/com/cybertek/pages/adidasPages/ProductPage.java:
--------------------------------------------------------------------------------
1 | package com.cybertek.pages.adidasPages;
2 |
3 | import org.openqa.selenium.WebElement;
4 | import org.openqa.selenium.support.FindBy;
5 |
6 | public class ProductPage extends BasePageForAdidas{
7 |
8 | @FindBy(tagName = "h2")
9 | public WebElement productName;
10 |
11 | @FindBy(tagName = "h3")
12 | public WebElement priceElement;
13 |
14 | @FindBy(xpath = "(//p)[4]")
15 | public WebElement productDescription;
16 |
17 | }
18 |
--------------------------------------------------------------------------------
/src/test/java/com/cybertek/tests/TestBase.java:
--------------------------------------------------------------------------------
1 | package com.cybertek.tests;
2 |
3 | import com.aventstack.extentreports.ExtentReports;
4 | import com.aventstack.extentreports.ExtentTest;
5 | import com.aventstack.extentreports.reporter.ExtentHtmlReporter;
6 | import com.cybertek.utilities.BrowserUtils;
7 | import com.cybertek.utilities.ConfigurationReader;
8 | import com.cybertek.utilities.Driver;
9 | import org.openqa.selenium.WebDriver;
10 | import org.openqa.selenium.interactions.Actions;
11 | import org.openqa.selenium.support.ui.WebDriverWait;
12 | import org.testng.ITestResult;
13 | import org.testng.annotations.*;
14 |
15 | import java.io.IOException;
16 | import java.util.concurrent.TimeUnit;
17 |
18 | public class TestBase {
19 | protected WebDriver driver;
20 | protected Actions actions;
21 | protected WebDriverWait wait;
22 | //this class is used for starting and building reports
23 | protected static ExtentReports report;
24 | //this class is used to create HTML report file
25 | protected static ExtentHtmlReporter htmlReporter;
26 | //this will define a test, enables adding logs, authors, test steps
27 | protected static ExtentTest extentLogger;
28 |
29 | //env set up
30 | protected String url;
31 |
32 | @BeforeTest
33 | public void setUpTest(){
34 | //initialize the class
35 | report = new ExtentReports();
36 |
37 | //create a report path
38 | String projectPath = System.getProperty("user.dir");
39 | String path = projectPath + "/test-output/report.html";
40 |
41 | //initialize the html reporter with the report path
42 | htmlReporter = new ExtentHtmlReporter(path);
43 |
44 | //attach the html report to report object
45 | report.attachReporter(htmlReporter);
46 |
47 | //title in report
48 | htmlReporter.config().setReportName("Vytrack Smoke Test");
49 |
50 | //set environment information
51 | report.setSystemInfo("Environment","QA");
52 | report.setSystemInfo("Browser", ConfigurationReader.get("browser"));
53 | report.setSystemInfo("OS",System.getProperty("os.name"));
54 |
55 | }
56 |
57 | @BeforeMethod
58 | @Parameters("env")
59 | public void setUp(@Optional String env){
60 |
61 | System.out.println("env== " + env);
62 | if (env==null){
63 | url =ConfigurationReader.get("url");
64 | }else{
65 |
66 | url = ConfigurationReader.get(env+"_url");
67 | }
68 | driver = Driver.get();
69 | driver.manage().window().maximize();
70 | driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);
71 | actions = new Actions(driver);
72 | wait = new WebDriverWait(driver,10);
73 | driver.get(url);
74 |
75 | }
76 | //ITestResult class describes the result of a test in TestNG
77 | @AfterMethod
78 | public void tearDown(ITestResult result) throws InterruptedException, IOException {
79 | //if test fails
80 | if(result.getStatus()==ITestResult.FAILURE){
81 | //record the name of failed test case
82 | extentLogger.fail(result.getName());
83 |
84 | //take the screenshot and return location of screenshot
85 | String screenShotPath = BrowserUtils.getScreenshot(result.getName());
86 |
87 | //add your screenshot to your report
88 | extentLogger.addScreenCaptureFromPath(screenShotPath);
89 |
90 | //capture the exception and put inside the report
91 | extentLogger.fail(result.getThrowable());
92 |
93 | }
94 | Thread.sleep(2000);
95 | Driver.closeDriver();
96 | }
97 |
98 | @AfterTest
99 | public void tearDownTest(){
100 | //this is when the report is actually created
101 | report.flush();
102 |
103 | }
104 |
105 |
106 |
107 | }
108 |
--------------------------------------------------------------------------------
/src/test/java/com/cybertek/tests/TestBaseTwo.java:
--------------------------------------------------------------------------------
1 | package com.cybertek.tests;
2 |
3 | import com.cybertek.utilities.ConfigurationReader;
4 | import com.cybertek.utilities.ConfigurationReaderTwo;
5 | import com.cybertek.utilities.Driver;
6 | import org.openqa.selenium.WebDriver;
7 | import org.openqa.selenium.interactions.Actions;
8 | import org.openqa.selenium.support.ui.WebDriverWait;
9 | import org.testng.annotations.AfterMethod;
10 | import org.testng.annotations.BeforeMethod;
11 |
12 | import java.util.concurrent.TimeUnit;
13 |
14 | public class TestBaseTwo {
15 | protected WebDriver driver;
16 | protected Actions actions;
17 | protected WebDriverWait wait;
18 |
19 | @BeforeMethod
20 | public void setUp(){
21 | driver = Driver.get(); // statically calling object
22 | driver.manage().window().maximize();
23 | driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);
24 | actions = new Actions(driver);
25 | wait = new WebDriverWait(driver,10);
26 | driver.get(ConfigurationReaderTwo.get("demoblaze.url"));
27 |
28 | }
29 |
30 | @AfterMethod
31 | public void tearDown() throws InterruptedException {
32 | Thread.sleep(2000);
33 | Driver.closeDriver();
34 | // driver.quit(); NEVER NEVER use this statement again
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/src/test/java/com/cybertek/tests/day10_actions_js/ActionsTest.java:
--------------------------------------------------------------------------------
1 | package com.cybertek.tests.day10_actions_js;
2 |
3 | import com.cybertek.utilities.WebDriverFactory;
4 | import org.openqa.selenium.By;
5 | import org.openqa.selenium.WebDriver;
6 | import org.openqa.selenium.WebElement;
7 | import org.openqa.selenium.interactions.Actions;
8 | import org.testng.Assert;
9 | import org.testng.annotations.AfterMethod;
10 | import org.testng.annotations.BeforeMethod;
11 | import org.testng.annotations.Test;
12 |
13 | import java.util.List;
14 |
15 | public class ActionsTest {
16 |
17 |
18 | WebDriver driver;
19 |
20 | @BeforeMethod
21 | public void setUp(){
22 | driver = WebDriverFactory.getDriver("chrome");
23 |
24 | }
25 |
26 | @AfterMethod
27 | public void tearDown() throws InterruptedException {
28 | Thread.sleep(2000);
29 | driver.quit();
30 | }
31 |
32 | @Test
33 | public void hoverTest() throws InterruptedException {
34 | driver.get("http://practice.cybertekschool.com/hovers");
35 |
36 | WebElement img1 = driver.findElement(By.tagName("img"));
37 | //Actions --> class that contains all the user interactions
38 | //how to create actions object --> passing driver as a constructor
39 | Actions actions = new Actions(driver);
40 | //perform() --> perform the action, complete the action
41 | //moveToElement --> move you mouse to webelement(hover over)
42 | Thread.sleep(2000);
43 | actions.moveToElement(img1).perform();
44 |
45 | WebElement viewLink = driver.findElement(By.linkText("View profile"));
46 |
47 | Assert.assertTrue(viewLink.isDisplayed(),"verify view link is displayed");
48 |
49 | }
50 |
51 | @Test
52 | public void dragAndDrop() throws InterruptedException {
53 | driver.get("https://demos.telerik.com/kendo-ui/dragdrop/index");
54 | driver.manage().window().maximize();
55 |
56 | Actions actions = new Actions(driver);
57 |
58 | List acceptAndClose = driver.findElements(By.xpath("//*[.='Accept and Close']"));
59 | List acceptCookies = driver.findElements(By.xpath("//*[.='Accept Cookies']"));
60 | Thread.sleep(1000);
61 | if(acceptAndClose.size()>0){
62 | acceptAndClose.get(0).click();
63 | }else if(acceptCookies.size()>0){
64 | acceptCookies.get(0).click();
65 | }
66 |
67 | WebElement source = driver.findElement(By.id("draggable"));
68 | WebElement target = driver.findElement(By.id("droptarget"));
69 |
70 |
71 | Thread.sleep(2000);
72 | actions.dragAndDrop(source,target).perform();
73 | }
74 |
75 | @Test
76 | public void dragAndDropChaining() throws InterruptedException {
77 | driver.get("https://demos.telerik.com/kendo-ui/dragdrop/index");
78 | driver.manage().window().maximize();
79 |
80 | Actions actions = new Actions(driver);
81 |
82 | List acceptAndClose = driver.findElements(By.xpath("//*[.='Accept and Close']"));
83 | List acceptCookies = driver.findElements(By.xpath("//*[.='Accept Cookies']"));
84 | Thread.sleep(1000);
85 | if(acceptAndClose.size()>0){
86 | acceptAndClose.get(0).click();
87 | }else if(acceptCookies.size()>0){
88 | acceptCookies.get(0).click();
89 | }
90 |
91 | WebElement source = driver.findElement(By.id("draggable"));
92 | WebElement target = driver.findElement(By.id("droptarget"));
93 |
94 | Thread.sleep(2000);
95 | actions.moveToElement(source).clickAndHold().moveToElement(target).pause(2000).release().perform();
96 |
97 |
98 | }
99 |
100 | }
101 |
--------------------------------------------------------------------------------
/src/test/java/com/cybertek/tests/day10_actions_js/HoverTest.java:
--------------------------------------------------------------------------------
1 | package com.cybertek.tests.day10_actions_js;
2 |
3 | import com.cybertek.utilities.WebDriverFactory;
4 | import org.openqa.selenium.By;
5 | import org.openqa.selenium.WebDriver;
6 | import org.openqa.selenium.WebElement;
7 | import org.openqa.selenium.interactions.Actions;
8 | import org.testng.Assert;
9 | import org.testng.annotations.AfterMethod;
10 | import org.testng.annotations.BeforeMethod;
11 | import org.testng.annotations.Test;
12 |
13 | public class HoverTest {
14 |
15 | WebDriver driver;
16 |
17 | @BeforeMethod
18 | public void setUp(){
19 | driver = WebDriverFactory.getDriver("chrome");
20 |
21 | }
22 |
23 | @AfterMethod
24 | public void tearDown() throws InterruptedException {
25 | Thread.sleep(2000);
26 | driver.quit();
27 | }
28 |
29 | /**
30 | * hover over each image in the website
31 | * verify each name:user text is displayed
32 | */
33 |
34 | @Test
35 | public void oneImage() throws InterruptedException {
36 | driver.get("http://practice.cybertekschool.com/hovers");
37 |
38 | WebElement img1 = driver.findElement(By.tagName("img"));
39 |
40 | Actions actions = new Actions(driver);
41 |
42 | Thread.sleep(2000);
43 | actions.moveToElement(img1).perform();
44 |
45 | WebElement text1 = driver.findElement(By.xpath("//h5[.='name: user1']"));
46 |
47 | Assert.assertTrue(text1.isDisplayed(),"verify text 1 is displayed");
48 |
49 | }
50 |
51 | /**
52 | * hover over each image in the website
53 | * verify each name:user text is displayed
54 | */
55 | @Test
56 | public void test2() throws InterruptedException {
57 | driver.get("http://practice.cybertekschool.com/hovers");
58 |
59 | for (int i = 1; i <= 3; i++) {
60 |
61 | String xpathImg = "(//img)["+i+"]";
62 | WebElement img = driver.findElement(By.xpath(xpathImg));
63 | System.out.println(xpathImg);
64 |
65 | Actions actions = new Actions(driver);
66 | Thread.sleep(1000);
67 | actions.moveToElement(img).perform();
68 |
69 | String textXpath = "//h5[.='name: user"+i+"']";
70 | WebElement text1 = driver.findElement(By.xpath(textXpath));
71 | System.out.println(textXpath);
72 | Assert.assertTrue(text1.isDisplayed(),"verify user "+i+" is displayed");
73 |
74 | }
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 | }
88 |
89 | }
90 |
--------------------------------------------------------------------------------
/src/test/java/com/cybertek/tests/day10_actions_js/JavaScriptExecutorDemo.java:
--------------------------------------------------------------------------------
1 | package com.cybertek.tests.day10_actions_js;
2 |
3 | import com.cybertek.utilities.WebDriverFactory;
4 | import org.openqa.selenium.By;
5 | import org.openqa.selenium.JavascriptExecutor;
6 | import org.openqa.selenium.WebDriver;
7 | import org.openqa.selenium.WebElement;
8 | import org.testng.annotations.AfterMethod;
9 | import org.testng.annotations.BeforeMethod;
10 | import org.testng.annotations.Test;
11 |
12 | public class JavaScriptExecutorDemo {
13 |
14 | WebDriver driver;
15 |
16 | @BeforeMethod
17 | public void setUp(){
18 | driver = WebDriverFactory.getDriver("chrome");
19 |
20 | }
21 |
22 | @AfterMethod
23 | public void tearDown() throws InterruptedException {
24 | Thread.sleep(2000);
25 | // driver.quit();
26 | }
27 |
28 | @Test
29 | public void clickWithJS(){
30 | driver.get("http://practice.cybertekschool.com/");
31 |
32 | WebElement dropdownLink = driver.findElement(By.linkText("Dropdown"));
33 | JavascriptExecutor jse = (JavascriptExecutor) driver;
34 |
35 | jse.executeScript("arguments[0].click();", dropdownLink);
36 |
37 | }
38 |
39 | @Test
40 | public void typeWithJS(){
41 | driver.get("http://practice.cybertekschool.com/dynamic_controls");
42 |
43 | WebElement inputBox = driver.findElement(By.cssSelector("#input-example>input"));
44 |
45 | JavascriptExecutor jse = (JavascriptExecutor) driver;
46 |
47 | String text = "Hello Disabled Input";
48 |
49 | jse.executeScript("arguments[0].setAttribute('value', '" + text +"')", inputBox);
50 |
51 | }
52 |
53 | @Test
54 | public void ScrollDownAndUp() throws InterruptedException {
55 | driver.get("http://practice.cybertekschool.com/infinite_scroll");
56 | driver.manage().window().maximize();
57 |
58 | JavascriptExecutor jse = (JavascriptExecutor) driver;
59 |
60 | for (int i = 0; i < 10; i++) {
61 | Thread.sleep(1000);
62 | jse.executeScript("window.scrollBy(0,250)");
63 |
64 | }
65 |
66 | for (int i = 0; i < 10; i++) {
67 | Thread.sleep(1000);
68 | jse.executeScript("window.scrollBy(0,-250)");
69 |
70 | }
71 |
72 |
73 | }
74 |
75 | @Test
76 | public void scrollToElement() throws InterruptedException {
77 |
78 | driver.get("https://www.amazon.com/");
79 | WebElement eng = driver.findElement(By.id("icp-touch-link-language"));
80 | Thread.sleep(2000);
81 | JavascriptExecutor jse = (JavascriptExecutor) driver;
82 |
83 | jse.executeScript("arguments[0].scrollIntoView(true);",eng);
84 |
85 |
86 | }
87 |
88 |
89 |
90 | }
91 |
--------------------------------------------------------------------------------
/src/test/java/com/cybertek/tests/day10_file_upload/FilePathExample.java:
--------------------------------------------------------------------------------
1 | package com.cybertek.tests.day10_file_upload;
2 |
3 | import org.testng.annotations.Test;
4 |
5 | public class FilePathExample {
6 |
7 | @Test
8 | public void test1(){
9 | // /Users/jamaldemir/IdeaProjects/fromgit/EU3TestNGSelenium/src/test/resources/textfile.txt
10 |
11 | // /Users/jamaldemir/IdeaProjects/fromgit/EU3TestNGSelenium src/test/resources/textfile.txt;
12 | //System.out.println(System.getProperty("user.dir"));
13 | System.out.println(System.getProperty("os.name"));
14 | String projectPath = System.getProperty("user.dir");
15 | System.out.println("projectPath = " + projectPath);
16 |
17 | String filePath = "src/test/resources/textfile.txt";
18 |
19 | String fullPath = projectPath+"/"+filePath;
20 | System.out.println(fullPath);
21 |
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/src/test/java/com/cybertek/tests/day10_file_upload/FileUploadTest.java:
--------------------------------------------------------------------------------
1 | package com.cybertek.tests.day10_file_upload;
2 |
3 | import com.cybertek.utilities.WebDriverFactory;
4 | import org.openqa.selenium.By;
5 | import org.openqa.selenium.WebDriver;
6 | import org.openqa.selenium.WebElement;
7 | import org.testng.Assert;
8 | import org.testng.annotations.AfterMethod;
9 | import org.testng.annotations.BeforeMethod;
10 | import org.testng.annotations.Test;
11 |
12 | public class FileUploadTest {
13 |
14 | WebDriver driver;
15 |
16 | @BeforeMethod
17 | public void setUp(){
18 | driver = WebDriverFactory.getDriver("chrome");
19 |
20 | }
21 |
22 | @AfterMethod
23 | public void tearDown() throws InterruptedException {
24 | Thread.sleep(2000);
25 | //driver.quit();
26 | }
27 |
28 | @Test
29 | public void test1(){
30 | driver.get("http://practice.cybertekschool.com/upload");
31 | //locating choose file button
32 | WebElement chooseFile = driver.findElement(By.name("file"));
33 | //sending file with sendKeys method
34 | chooseFile.sendKeys("C:/Users/Oscar/Desktop/cars.docx");
35 | //clicking upload button
36 | driver.findElement(By.id("file-submit")).click();
37 |
38 | //getting the file name from browser
39 | String actualFileName= driver.findElement(By.id("uploaded-files")).getText();
40 | //verify file name is file.txt
41 | Assert.assertEquals(actualFileName,"file.txt");
42 |
43 | }
44 |
45 | @Test
46 | public void test2(){
47 | driver.get("http://practice.cybertekschool.com/upload");
48 | //locating choose file button
49 | WebElement chooseFile = driver.findElement(By.name("file"));
50 |
51 | //sending file with sendKeys method
52 | String projectPath = System.getProperty("user.dir");
53 | String filePath = "src/test/resources/textfile.txt";
54 | String fullPath = projectPath+"/"+filePath;
55 | chooseFile.sendKeys(fullPath);
56 | //clicking upload button
57 | driver.findElement(By.id("file-submit")).click();
58 |
59 | //getting the file name from browser
60 | String actualFileName= driver.findElement(By.id("uploaded-files")).getText();
61 | //verify file name is file.txt
62 | Assert.assertEquals(actualFileName,"textfile.txt");
63 |
64 | }
65 |
66 | }
67 |
--------------------------------------------------------------------------------
/src/test/java/com/cybertek/tests/day11_webtables/WebTablesExample.java:
--------------------------------------------------------------------------------
1 | package com.cybertek.tests.day11_webtables;
2 |
3 | import com.cybertek.utilities.WebDriverFactory;
4 | import org.openqa.selenium.By;
5 | import org.openqa.selenium.WebDriver;
6 | import org.openqa.selenium.WebElement;
7 | import org.testng.Assert;
8 | import org.testng.annotations.BeforeMethod;
9 | import org.testng.annotations.Test;
10 |
11 | import java.util.List;
12 | import java.util.concurrent.TimeUnit;
13 |
14 | public class WebTablesExample {
15 |
16 |
17 | WebDriver driver;
18 |
19 | @BeforeMethod
20 | public void setUp(){
21 | driver = WebDriverFactory.getDriver("chrome");
22 | driver.manage().window().maximize();
23 | driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);
24 | driver.get("http://practice.cybertekschool.com/tables");
25 | }
26 |
27 | // @AfterMethod
28 | // public void tearDown() throws InterruptedException {
29 | // Thread.sleep(2000);
30 | // driver.quit();
31 | // }
32 |
33 | @Test
34 | public void printTable(){
35 | WebElement table = driver.findElement(By.xpath("//table[@id='table1']"));
36 |
37 | System.out.println(table.getText());
38 |
39 | Assert.assertTrue(table.getText().contains("jdoe@hotmail.com"));
40 | }
41 |
42 | @Test
43 | public void getAllHeaders(){
44 | //how many columns we have ?
45 | List headers = driver.findElements(By.xpath("//table[@id='table1']//th"));
46 | System.out.println("headers.size() = " + headers.size());
47 |
48 | for (WebElement header : headers) {
49 | System.out.println(header.getText());
50 | }
51 |
52 | }
53 |
54 | @Test
55 | public void printTableSize(){
56 | //how many columns we have ?
57 | List headers = driver.findElements(By.xpath("//table[@id='table1']//th"));
58 | System.out.println("headers.size() = " + headers.size());
59 |
60 | //number of rows
61 | List allRowsWithHeader = driver.findElements(By.xpath("//table[@id='table1']//tr"));
62 | System.out.println(allRowsWithHeader.size());
63 |
64 | //number of rows without header(we prefer this)
65 | List allRowsWithoutHeader = driver.findElements(By.xpath("//table[@id='table1']/tbody/tr"));
66 | System.out.println(allRowsWithoutHeader.size());
67 | }
68 |
69 | @Test
70 | public void getRow(){
71 | //print the second row information
72 | WebElement row2 = driver.findElement(By.xpath("//table[@id='table1']/tbody/tr[2]"));
73 |
74 | //System.out.println(row2.getText());
75 |
76 | //get all rows dynamically
77 | //1.find number of rows
78 | List numRows = driver.findElements(By.xpath("//table[@id='table1']/tbody/tr"));
79 | //2.iterate one by one
80 | for (int i = 1; i <= numRows.size(); i++) {
81 | WebElement row = driver.findElement(By.xpath("//table[@id='table1']/tbody/tr["+i+"]"));
82 | System.out.println(i+"-"+row.getText());
83 | }
84 |
85 | //***loop shortcuts iter and itar
86 |
87 | }
88 |
89 | @Test
90 | public void getAllCellInOneRow(){
91 | List allCellsInOneRow = driver.findElements(By.xpath("//table[@id='table1']/tbody/tr[3]/td"));
92 |
93 | for (WebElement element : allCellsInOneRow) {
94 | System.out.println(element.getText());
95 | }
96 | }
97 |
98 |
99 | @Test
100 | public void getASingleCellByIndex(){
101 | WebElement singleCell = driver.findElement(By.xpath("//table[@id='table1']/tbody/tr[3]/td[5]"));
102 | System.out.println("singleCell.getText() = " + singleCell.getText());
103 |
104 | }
105 |
106 | @Test
107 | public void printAllCellsByIndex(){
108 |
109 | int rowNumber = getNumberOfRows();
110 | int colNumber = getNumberOfColumns();
111 |
112 | System.out.println("colNumber = " + colNumber);
113 | System.out.println("rowNumber = " + rowNumber);
114 |
115 | //iterate through each row on the table
116 | for (int i = 1; i <= rowNumber; i++) {
117 |
118 | //iterate through each cell in the row
119 | for (int j = 1; j <= colNumber; j++) {
120 |
121 | String cellXpath = "//table[@id='table1']/tbody/tr["+i+"]/td["+j+"]";
122 | System.out.println(cellXpath);
123 |
124 | WebElement cell = driver.findElement(By.xpath(cellXpath));
125 | System.out.println(cell.getText());
126 |
127 | }
128 |
129 | }
130 |
131 | }
132 |
133 | @Test
134 | public void getCellInRelationToAnotherCellInSameRow(){
135 |
136 | String firstName="Jason";
137 |
138 | String xpath ="//table[@id='table1']//td[.='"+firstName+"']/../td[3]";
139 | WebElement email = driver.findElement(By.xpath(xpath));
140 | System.out.println(email.getText());
141 |
142 |
143 | }
144 |
145 |
146 | private int getNumberOfColumns() {
147 | List headers = driver.findElements(By.xpath("//table[@id='table1']//th"));
148 | return headers.size();
149 | }
150 |
151 | private int getNumberOfRows() {
152 | List allRowsWithoutHeader = driver.findElements(By.xpath("//table[@id='table1']/tbody/tr"));
153 | return allRowsWithoutHeader.size();
154 | }
155 |
156 |
157 |
158 |
159 |
160 | }
161 |
--------------------------------------------------------------------------------
/src/test/java/com/cybertek/tests/day12_properties_driver_tests/AnotherLoginTest.java:
--------------------------------------------------------------------------------
1 | package com.cybertek.tests.day12_properties_driver_tests;
2 |
3 | import com.cybertek.tests.TestBase;
4 | import com.cybertek.utilities.ConfigurationReader;
5 | import org.openqa.selenium.By;
6 | import org.openqa.selenium.Keys;
7 | import org.testng.annotations.Test;
8 |
9 | public class AnotherLoginTest extends TestBase {
10 |
11 | @Test
12 | public void test1(){
13 | driver.get(ConfigurationReader.get("url"));
14 |
15 | String username = ConfigurationReader.get("driver_username");
16 | String password = ConfigurationReader.get("driver_password");
17 |
18 | driver.findElement(By.id("prependedInput")).sendKeys(username);
19 | driver.findElement(By.id("prependedInput2")).sendKeys(password+ Keys.ENTER);
20 |
21 | }
22 |
23 |
24 | }
25 |
--------------------------------------------------------------------------------
/src/test/java/com/cybertek/tests/day12_properties_driver_tests/LoginTest.java:
--------------------------------------------------------------------------------
1 | package com.cybertek.tests.day12_properties_driver_tests;
2 |
3 | import com.cybertek.tests.TestBase;
4 | import com.cybertek.utilities.ConfigurationReader;
5 | import org.openqa.selenium.By;
6 | import org.testng.annotations.Test;
7 |
8 | public class LoginTest extends TestBase {
9 |
10 |
11 | @Test
12 | public void OpenBrowserWithConf(){
13 |
14 | driver.get(ConfigurationReader.get("url"));
15 |
16 | String username = ConfigurationReader.get("driver_username");
17 | String password = ConfigurationReader.get("driver_password");
18 |
19 | driver.findElement(By.id("prependedInput")).sendKeys(username);
20 | driver.findElement(By.id("prependedInput2")).sendKeys(password);
21 |
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/src/test/java/com/cybertek/tests/day12_properties_driver_tests/PropertiesTest.java:
--------------------------------------------------------------------------------
1 | package com.cybertek.tests.day12_properties_driver_tests;
2 |
3 | import com.cybertek.utilities.ConfigurationReader;
4 | import com.cybertek.utilities.WebDriverFactory;
5 | import org.openqa.selenium.By;
6 | import org.openqa.selenium.Keys;
7 | import org.openqa.selenium.WebDriver;
8 | import org.testng.annotations.Test;
9 |
10 | public class PropertiesTest {
11 |
12 | @Test
13 | public void test1(){
14 |
15 | String browserType = ConfigurationReader.get("browser");
16 |
17 | System.out.println("browserType = " + browserType);
18 | System.out.println("Browser: "+ConfigurationReader.get("browser"));
19 |
20 | String url = ConfigurationReader.get("url");
21 |
22 | System.out.println("url = " + url);
23 |
24 |
25 | }
26 |
27 | @Test
28 | public void OpenBrowserWithConf(){
29 |
30 | WebDriver driver = WebDriverFactory.getDriver(ConfigurationReader.get("browser"));
31 |
32 | driver.get(ConfigurationReader.get("url"));
33 |
34 | String username = ConfigurationReader.get("driver_username");
35 | String password = ConfigurationReader.get("driver_password");
36 |
37 | driver.findElement(By.id("prependedInput")).sendKeys(username);
38 | driver.findElement(By.id("prependedInput2")).sendKeys(password+ Keys.TAB);
39 |
40 | }
41 |
42 |
43 | }
44 |
--------------------------------------------------------------------------------
/src/test/java/com/cybertek/tests/day12_properties_driver_tests/Singleton.java:
--------------------------------------------------------------------------------
1 | package com.cybertek.tests.day12_properties_driver_tests;
2 |
3 | public class Singleton {
4 |
5 | //singleton class will have private constructor
6 | //it means other classes cannot create object of this class
7 | private Singleton(){}
8 |
9 | private static String str;
10 |
11 | public static String getInstance(){
12 |
13 | //if str has no value, initialize it and return it
14 | if(str==null){
15 | System.out.println("str is null. assigning value it");
16 | str="somevalue";
17 | }else{
18 | //if it has value just return it
19 | System.out.println("it has value, just returning it");
20 | }
21 |
22 | return str;
23 | }
24 |
25 | }
26 |
--------------------------------------------------------------------------------
/src/test/java/com/cybertek/tests/day12_properties_driver_tests/SingletonTest.java:
--------------------------------------------------------------------------------
1 | package com.cybertek.tests.day12_properties_driver_tests;
2 |
3 | import com.cybertek.utilities.Driver;
4 | import org.openqa.selenium.WebDriver;
5 | import org.testng.annotations.Test;
6 |
7 | public class SingletonTest {
8 |
9 | //@Test
10 | public void test1(){
11 | String s1 = Singleton.getInstance();
12 | String s2 = Singleton.getInstance();
13 |
14 | System.out.println("s1 = " + s1);
15 | System.out.println("s2 = " + s2);
16 | }
17 |
18 |
19 | @Test
20 | public void test2() throws InterruptedException {
21 | WebDriver driver = Driver.get();
22 | Thread.sleep(2000);
23 | driver.get("https://www.google.com");
24 |
25 | }
26 |
27 | @Test
28 | public void test3(){
29 | WebDriver driver = Driver.get();
30 |
31 | driver.get("https://www.amazon.com");
32 |
33 |
34 | Driver.get().get("https://www.amazon.com");
35 | }
36 |
37 | }
38 |
--------------------------------------------------------------------------------
/src/test/java/com/cybertek/tests/day13_pom/NegativeLoginTest.java:
--------------------------------------------------------------------------------
1 | package com.cybertek.tests.day13_pom;
2 |
3 | import com.cybertek.pages.LoginPage;
4 | import com.cybertek.tests.TestBase;
5 | import org.testng.Assert;
6 | import org.testng.annotations.Test;
7 |
8 | public class NegativeLoginTest extends TestBase {
9 | LoginPage loginPage = new LoginPage();
10 | @Test
11 | public void wrongPasswordTest(){
12 |
13 | // LoginPage loginPage = new LoginPage();
14 |
15 | loginPage.usernameInput.sendKeys("user1");
16 | loginPage.passwordInput.sendKeys("somepassword");
17 | loginPage.loginBtn.click();
18 |
19 | Assert.assertEquals(driver.getCurrentUrl(),"https://qa1.vytrack.com/user/login");
20 |
21 | }
22 |
23 | @Test
24 | public void wrongUsernameTest(){
25 |
26 | // LoginPage loginPage = new LoginPage();
27 |
28 | loginPage.usernameInput.sendKeys("someusername");
29 | loginPage.passwordInput.sendKeys("UserUser123");
30 | loginPage.loginBtn.click();
31 |
32 | Assert.assertEquals(driver.getCurrentUrl(),"https://qa1.vytrack.com/user/login");
33 |
34 | }
35 |
36 |
37 | }
--------------------------------------------------------------------------------
/src/test/java/com/cybertek/tests/day13_pom/PageSubtitleTest.java:
--------------------------------------------------------------------------------
1 | package com.cybertek.tests.day13_pom;
2 |
3 | import com.cybertek.pages.CalendarEventsPage;
4 | import com.cybertek.pages.DashboardPage;
5 | import com.cybertek.pages.LoginPage;
6 | import com.cybertek.tests.TestBase;
7 | import com.cybertek.utilities.BrowserUtils;
8 | import org.testng.Assert;
9 | import org.testng.annotations.Test;
10 |
11 | public class PageSubtitleTest extends TestBase {
12 |
13 | /**
14 | * Test case
15 | * Open Chrome browser
16 | * Login as a Driver
17 | * Verify that page subtitle is Quick Launchpad
18 | * Go to Activities -> Calendar Events
19 | * verify that page subtitle is Calendar Events
20 | */
21 | @Test
22 | public void test1(){
23 |
24 | LoginPage loginPage = new LoginPage();
25 |
26 | loginPage.loginAsDriver();
27 |
28 | String expectedSubtitle = "Quick Launchpad";
29 |
30 | DashboardPage dashboardPage = new DashboardPage();
31 |
32 | String actualSubtitle = dashboardPage.getPageSubTitle();
33 |
34 | Assert.assertEquals(actualSubtitle,expectedSubtitle,"Verify subtitle");
35 |
36 | dashboardPage.navigateToModule("Activities","Calendar Events");
37 |
38 | CalendarEventsPage calendarEventsPage = new CalendarEventsPage();
39 |
40 | BrowserUtils.waitFor(2);
41 |
42 | Assert.assertEquals(calendarEventsPage.getPageSubTitle(),"Calendar Events","Verify subtitle Calendar Events");
43 |
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/src/test/java/com/cybertek/tests/day13_pom/PositiveLoginTest.java:
--------------------------------------------------------------------------------
1 | package com.cybertek.tests.day13_pom;
2 |
3 | import com.cybertek.pages.LoginPage;
4 | import com.cybertek.tests.TestBase;
5 | import com.cybertek.utilities.ConfigurationReader;
6 | import org.testng.Assert;
7 | import org.testng.annotations.Test;
8 |
9 | public class PositiveLoginTest extends TestBase {
10 |
11 |
12 | @Test
13 | public void loginAsDriver(){
14 |
15 | LoginPage loginPage = new LoginPage();
16 |
17 | // String username = ConfigurationReader.get("driver_username");
18 | // String password = ConfigurationReader.get("driver_password");
19 | //
20 | // loginPage.usernameInput.sendKeys(username);
21 | // loginPage.passwordInput.sendKeys(password);
22 | // loginPage.loginBtn.click();
23 | loginPage.loginAsDriver();
24 |
25 | Assert.assertEquals(driver.getCurrentUrl(),"https://qa1.vytrack.com/");
26 |
27 |
28 | }
29 |
30 | @Test
31 | public void loginAsStoreManager(){
32 |
33 | LoginPage loginPage = new LoginPage();
34 |
35 | String username = ConfigurationReader.get("storemanager_username");
36 | String password = ConfigurationReader.get("storemanager_password");
37 | loginPage.login(username,password);
38 |
39 | Assert.assertEquals(driver.getCurrentUrl(),"https://qa1.vytrack.com/");
40 |
41 |
42 | }
43 |
44 | @Test
45 | public void loginAsStoreManager2(){
46 |
47 | LoginPage loginPage = new LoginPage();
48 |
49 | loginPage.loginAsStoreManager();
50 |
51 | Assert.assertEquals(driver.getCurrentUrl(),"https://qa1.vytrack.com/");
52 |
53 |
54 | }
55 |
56 |
57 |
58 | }
59 |
--------------------------------------------------------------------------------
/src/test/java/com/cybertek/tests/day13_pom/RepeatOptionsTests.java:
--------------------------------------------------------------------------------
1 | package com.cybertek.tests.day13_pom;
2 |
3 | import com.cybertek.pages.CalendarEventsPage;
4 | import com.cybertek.pages.CreateCalendarEventsPage;
5 | import com.cybertek.pages.DashboardPage;
6 | import com.cybertek.pages.LoginPage;
7 | import com.cybertek.tests.TestBase;
8 | import com.cybertek.utilities.BrowserUtils;
9 | import org.openqa.selenium.WebElement;
10 | import org.openqa.selenium.support.ui.Select;
11 | import org.testng.Assert;
12 | import org.testng.annotations.Test;
13 |
14 | import java.util.ArrayList;
15 | import java.util.Arrays;
16 | import java.util.List;
17 |
18 | public class RepeatOptionsTests extends TestBase {
19 |
20 | /*VERIFY RADIO BUTTONS
21 | Open Chrome browser
22 | Login as driver
23 | Go to Activities->Calendar Events
24 | Click on create calendar events
25 | Click on repeat
26 | Verify that repeat every days is checked
27 | verify that repeat weekday is not checked
28 | * */
29 | //TASK UNTIL 12:45
30 | @Test
31 | public void test1(){
32 |
33 | LoginPage loginPage = new LoginPage();
34 |
35 | //Login as driver
36 | loginPage.loginAsDriver();
37 |
38 | DashboardPage dashboardPage = new DashboardPage();
39 | //Go to Activities->Calendar Events
40 | dashboardPage.navigateToModule("Activities","Calendar Events");
41 |
42 | CalendarEventsPage calendarEventsPage = new CalendarEventsPage();
43 | //Click on create calendar events
44 | //wait for loader mask
45 | calendarEventsPage.waitUntilLoaderScreenDisappear();
46 | BrowserUtils.waitForClickablility(calendarEventsPage.createCalendarEvent,5);
47 | calendarEventsPage.createCalendarEvent.click();
48 |
49 | CreateCalendarEventsPage createCalendarEventsPage = new CreateCalendarEventsPage();
50 | // Click on repeat
51 | createCalendarEventsPage.repeat.click();
52 |
53 | //Verify that repeat every days is checked
54 | Assert.assertTrue(createCalendarEventsPage.days.isSelected(),"Verify repeat days is selected");
55 | //verify that repeat weekday is not checked
56 | Assert.assertFalse(createCalendarEventsPage.weekday.isSelected(),"Verify weekday is not selected");
57 |
58 | }
59 |
60 | /*
61 | VERIFY REPEAT OPTIONS
62 | Open Chrome browser
63 | Login as driver
64 | Go to Activities->Calendar Events
65 | Click on create calendar events button
66 | Click on repeat checkbox
67 | Verify that repeat options are Daily, Weekly, Monthly,Yearly(in this order)
68 | */
69 |
70 | @Test
71 | public void test2(){
72 |
73 | LoginPage loginPage = new LoginPage();
74 |
75 | //Login as driver
76 | loginPage.loginAsDriver();
77 |
78 | DashboardPage dashboardPage = new DashboardPage();
79 | //Go to Activities->Calendar Events
80 | dashboardPage.navigateToModule("Activities","Calendar Events");
81 |
82 | CalendarEventsPage calendarEventsPage = new CalendarEventsPage();
83 | //Click on create calendar events
84 | //wait for loader mask
85 | calendarEventsPage.waitUntilLoaderScreenDisappear();
86 | BrowserUtils.waitForClickablility(calendarEventsPage.createCalendarEvent,5);
87 | calendarEventsPage.createCalendarEvent.click();
88 |
89 | CreateCalendarEventsPage createCalendarEventsPage = new CreateCalendarEventsPage();
90 | // Click on repeat
91 | createCalendarEventsPage.repeat.click();
92 |
93 | Select repeatsDropdown = createCalendarEventsPage.repeatOptionsList();
94 |
95 | // Verify that repeat options are Daily, Weekly, Monthly,Yearly(in this order)
96 | List expectedList = Arrays.asList("Daily","Weekly","Monthly","Yearly");
97 |
98 | List actualList = new ArrayList<>();
99 |
100 | List actualOptions = repeatsDropdown.getOptions();
101 | for (WebElement option : actualOptions) {
102 | //get text of each element and add to actual List
103 | System.out.println(option.getText());
104 | actualList.add(option.getText());
105 | }
106 | System.out.println(actualList);
107 | //ready method for getting text of list of web elements
108 | List actualList2 = BrowserUtils.getElementsText(actualOptions);
109 | //Verify that repeat options are Daily, Weekly, Monthly,Yearly(in this order)
110 | Assert.assertEquals(actualList,expectedList,"Verify Daily weekly monthly yearly");
111 |
112 | }
113 | }
114 |
--------------------------------------------------------------------------------
/src/test/java/com/cybertek/tests/day14_extent_reports/ExtentDemoTest.java:
--------------------------------------------------------------------------------
1 | package com.cybertek.tests.day14_extent_reports;
2 |
3 | import com.aventstack.extentreports.ExtentReports;
4 | import com.aventstack.extentreports.ExtentTest;
5 | import com.aventstack.extentreports.reporter.ExtentHtmlReporter;
6 | import com.cybertek.utilities.ConfigurationReader;
7 | import org.testng.annotations.AfterMethod;
8 | import org.testng.annotations.BeforeMethod;
9 | import org.testng.annotations.Test;
10 |
11 | public class ExtentDemoTest {
12 |
13 | //this class is used for starting nad building reports
14 | ExtentReports report;
15 | //this class is used to create HTML report file
16 | ExtentHtmlReporter htmlReporter;
17 | //this will define a test, enables adding logs, authors, test steps
18 | ExtentTest extentLogger;
19 |
20 | @BeforeMethod
21 | public void setup(){
22 | //initialize the class
23 | report = new ExtentReports();
24 |
25 | //create a report path
26 | String projectPath = System.getProperty("user.dir");
27 | String path = projectPath + "/test-output/report.html";
28 |
29 | //initialize the html reporter with the report path
30 | htmlReporter = new ExtentHtmlReporter(path);
31 |
32 | //attach the html report to report object
33 | report.attachReporter(htmlReporter);
34 |
35 | //title in report
36 | htmlReporter.config().setReportName("Vytrack Smoke Test");
37 |
38 | //set environment information
39 | report.setSystemInfo("Environment","QA");
40 | report.setSystemInfo("Browser", ConfigurationReader.get("browser"));
41 | report.setSystemInfo("OS",System.getProperty("os.name"));
42 |
43 | }
44 |
45 | @Test
46 | public void test1(){
47 | //give name to current test
48 | extentLogger= report.createTest("TC123 Login as Driver Test");
49 |
50 | //test steps
51 | extentLogger.info("Open Chrome Browser");
52 |
53 | extentLogger.info("Go to this URL");
54 |
55 | extentLogger.info("Enter driver username password");
56 |
57 | extentLogger.info("Click Login");
58 |
59 | extentLogger.info("Verify logged in");
60 |
61 | //pass()--> marks the test case as passed
62 | extentLogger.pass("TC123 is passed");
63 |
64 | }
65 |
66 |
67 | @AfterMethod
68 | public void teardown(){
69 | //this is when the report is actually created
70 | report.flush();
71 |
72 | }
73 |
74 | }
75 |
--------------------------------------------------------------------------------
/src/test/java/com/cybertek/tests/day14_extent_reports/NegativeLoginTestWithReport.java:
--------------------------------------------------------------------------------
1 | package com.cybertek.tests.day14_extent_reports;
2 |
3 | import com.cybertek.pages.LoginPage;
4 | import com.cybertek.tests.TestBase;
5 | import org.testng.Assert;
6 | import org.testng.annotations.Test;
7 |
8 | public class NegativeLoginTestWithReport extends TestBase {
9 |
10 | @Test
11 | public void wrongPasswordTest(){
12 | //name of the test
13 | extentLogger = report.createTest("Wrong Password Test");
14 |
15 | LoginPage loginPage = new LoginPage();
16 |
17 | extentLogger.info("Enter Username: user1");
18 | loginPage.usernameInput.sendKeys("user1");
19 |
20 | extentLogger.info("Enter Password: somepassword");
21 | loginPage.passwordInput.sendKeys("somepassword");
22 |
23 | extentLogger.info("Click login Button");
24 | loginPage.loginBtn.click();
25 |
26 | extentLogger.info("Verify Page URL");
27 | Assert.assertEquals(driver.getCurrentUrl(),"https://qa1.vytrack.com/user/login");
28 |
29 | extentLogger.pass("Wrong Password Test is Passed");
30 |
31 | }
32 |
33 | @Test
34 | public void wrongUsernameTest(){
35 | //name of the test
36 | extentLogger = report.createTest("Wrong Username Test");
37 |
38 | LoginPage loginPage = new LoginPage();
39 | extentLogger.info("Enter username: someusername");
40 | loginPage.usernameInput.sendKeys("someusername");
41 |
42 | extentLogger.info("Enter password: UserUser123");
43 | loginPage.passwordInput.sendKeys("UserUser123");
44 |
45 | extentLogger.info("Click Login button");
46 | loginPage.loginBtn.click();
47 |
48 | extentLogger.info("verify page url");
49 | Assert.assertEquals(driver.getCurrentUrl(),"https://qa1.vytrack.com/user/logi");
50 | extentLogger.pass("PASSED");
51 | }
52 |
53 |
54 |
55 | }
56 |
--------------------------------------------------------------------------------
/src/test/java/com/cybertek/tests/day15_review/verifyContactInfoTest.java:
--------------------------------------------------------------------------------
1 | package com.cybertek.tests.day15_review;
2 |
3 | import com.cybertek.pages.ContactInfoPage;
4 | import com.cybertek.pages.ContactsPage;
5 | import com.cybertek.pages.DashboardPage;
6 | import com.cybertek.pages.LoginPage;
7 | import com.cybertek.tests.TestBase;
8 | import com.cybertek.utilities.ConfigurationReader;
9 | import org.testng.Assert;
10 | import org.testng.annotations.Test;
11 |
12 | public class verifyContactInfoTest extends TestBase {
13 | /**
14 | * open the chrome
15 | * go to qa1.vytrack
16 | * login as a sales manager
17 | * navigate to customers ->contacts
18 | * click on email mbrackstone9@example.com
19 | * verify that full name is Mariam Brackstone
20 | * verify that email is mbrackstone9@example.com
21 | * verify that phone number is +18982323434
22 | */
23 | @Test
24 | public void contactDetailsTest(){
25 |
26 | extentLogger = report.createTest("Contact Info Verification");
27 |
28 | LoginPage loginPage = new LoginPage();
29 |
30 | String username = ConfigurationReader.get("salesmanager_username");
31 | String password = ConfigurationReader.get("salesmanager_password");
32 | extentLogger.info("username: "+username);
33 | extentLogger.info("password: "+password);
34 | extentLogger.info("Login as a Sales Manager");
35 | loginPage.login(username,password);
36 |
37 | extentLogger.info("Navigate to --> Customers > Contacts");
38 | new DashboardPage().navigateToModule("Customers","Contacts");
39 |
40 | ContactsPage contactsPage = new ContactsPage();
41 |
42 | extentLogger.info("Click on mbrackstone9@example.com");
43 | contactsPage.waitUntilLoaderScreenDisappear();
44 | contactsPage.getContactEmail("mbrackstone9@example.com").click();
45 |
46 | ContactInfoPage contactInfoPage = new ContactInfoPage();
47 |
48 | String expectedFullName = "Mariam Brackstone";
49 | String actualFullName = contactInfoPage.fullName.getText();
50 |
51 | extentLogger.info("Verify full name is "+ expectedFullName);
52 | Assert.assertEquals(actualFullName,expectedFullName,"verify fullname");
53 |
54 | extentLogger.info("verify email is mbrackstone9@example.com");
55 | Assert.assertEquals(contactInfoPage.email.getText(),"mbrackstone9@example.com","Verify email");
56 |
57 | extentLogger.info("verify phone number is +18982323434");
58 | Assert.assertEquals(contactInfoPage.phone.getText(),"+18982323434","verify phone number");
59 |
60 | extentLogger.pass("PASSED");
61 |
62 | }
63 |
64 |
65 | }
66 |
--------------------------------------------------------------------------------
/src/test/java/com/cybertek/tests/day16_ddf/DDFLoginTest.java:
--------------------------------------------------------------------------------
1 | package com.cybertek.tests.day16_ddf;
2 |
3 | import com.cybertek.pages.DashboardPage;
4 | import com.cybertek.pages.LoginPage;
5 | import com.cybertek.tests.TestBase;
6 | import com.cybertek.utilities.ExcelUtil;
7 | import org.testng.Assert;
8 | import org.testng.annotations.DataProvider;
9 | import org.testng.annotations.Test;
10 |
11 | public class DDFLoginTest extends TestBase {
12 |
13 | @DataProvider
14 | public Object [][] userData(){
15 |
16 | ExcelUtil qa3short = new ExcelUtil("src/test/resources/Vytracktestdata.xlsx","QA3-all");
17 |
18 | String [][] dataArray =qa3short.getDataArrayWithoutFirstRow();
19 |
20 | return dataArray;
21 | }
22 |
23 | @Test(dataProvider = "userData")
24 | public void test1(String username,String password,String firstName,String lastName){
25 | extentLogger=report.createTest("Test "+firstName+" "+lastName);
26 | LoginPage loginPage = new LoginPage();
27 |
28 | loginPage.login(username,password);
29 |
30 | DashboardPage dashboardPage = new DashboardPage();
31 | dashboardPage.waitUntilLoaderScreenDisappear();
32 |
33 | String actualFullName = dashboardPage.getUserName();
34 | String expectedFullName = firstName+" "+lastName;
35 |
36 | Assert.assertEquals(actualFullName,expectedFullName,"verify fullname");
37 | extentLogger.pass("PASSED");
38 | }
39 |
40 |
41 | }
42 |
--------------------------------------------------------------------------------
/src/test/java/com/cybertek/tests/day16_ddf/DDFWithDataProvider.java:
--------------------------------------------------------------------------------
1 | package com.cybertek.tests.day16_ddf;
2 |
3 | import org.testng.annotations.DataProvider;
4 | import org.testng.annotations.Test;
5 |
6 | public class DDFWithDataProvider {
7 |
8 | @DataProvider
9 | public Object [][] testData(){
10 | String [][] data = {{"Person of Interest","10"}, {"Sherlock","9"}, {"Breaking Bad","9"}, {"The Office","8"},
11 | {"Friends","7"},
12 | {"Westworld","10"},
13 | {"Gotham","9"},
14 | {"Dark","8"}
15 | };
16 | return data;
17 | }
18 |
19 |
20 | @Test(dataProvider ="testData")
21 | public void test1(String tvshow,String rating){
22 | System.out.println("Tv show: "+tvshow +" has rating "+rating);
23 |
24 | }
25 |
26 |
27 |
28 |
29 |
30 | }
31 |
--------------------------------------------------------------------------------
/src/test/java/com/cybertek/tests/day16_ddf/ExcelUtilsDemo.java:
--------------------------------------------------------------------------------
1 | package com.cybertek.tests.day16_ddf;
2 |
3 | import com.cybertek.utilities.ExcelUtil;
4 | import org.testng.annotations.Test;
5 |
6 | import java.util.Arrays;
7 | import java.util.List;
8 | import java.util.Map;
9 |
10 | public class ExcelUtilsDemo {
11 |
12 |
13 | @Test
14 | public void readExcelFile(){
15 |
16 | //Create an object from ExcelUtil
17 | //it accepts two argument
18 | //Argument 1: location of the file(path)
19 | //Argument 2: sheet that wew want to open(sheetName)
20 |
21 | ExcelUtil qa3short = new ExcelUtil("src/test/resources/Vytracktestdata.xlsx","QA3-short");
22 |
23 | //how many rows in the sheet
24 | System.out.println("qa3short.rowCount() = " + qa3short.rowCount());
25 |
26 | //how many columns in the sheet
27 | System.out.println("qa3short.columnCount() = " + qa3short.columnCount());
28 |
29 | //get all column names
30 | System.out.println("qa3short.getColumnsNames() = " + qa3short.getColumnsNames());
31 |
32 | //get all data in list of maps
33 | List