diff --git a/.DS_Store b/.DS_Store index 79af67c..a6bf957 100644 Binary files a/.DS_Store and b/.DS_Store differ diff --git a/drivers/chromedriver b/drivers/chromedriver index f0f1469..21bbdc8 100755 Binary files a/drivers/chromedriver and b/drivers/chromedriver differ diff --git a/src/.DS_Store b/src/.DS_Store new file mode 100644 index 0000000..2367baf Binary files /dev/null and b/src/.DS_Store differ diff --git a/src/test/.DS_Store b/src/test/.DS_Store new file mode 100644 index 0000000..5dfea09 Binary files /dev/null and b/src/test/.DS_Store differ diff --git a/src/test/java/.DS_Store b/src/test/java/.DS_Store new file mode 100644 index 0000000..163af7c Binary files /dev/null and b/src/test/java/.DS_Store differ diff --git a/src/test/java/Class1.java b/src/test/java/Class1/Class1.java similarity index 95% rename from src/test/java/Class1.java rename to src/test/java/Class1/Class1.java index 4ede708..4b32165 100644 --- a/src/test/java/Class1.java +++ b/src/test/java/Class1/Class1.java @@ -1,3 +1,5 @@ +package Class1; + import org.openqa.selenium.WebDriver; import org.openqa.selenium.chrome.ChromeDriver; import org.testng.annotations.Test; diff --git a/src/test/java/Class1/Homework1.java b/src/test/java/Class1/Homework1.java new file mode 100644 index 0000000..b182a25 --- /dev/null +++ b/src/test/java/Class1/Homework1.java @@ -0,0 +1,28 @@ +package Class1; + +public class Homework1 { + + /** + * + * Due Date: Tue (Apr 19) + * + * + * Create new repository in Github + * Invite Ahsan or Fara as Collaborator in the repository + * Clone repository in local + * Create a branch + * Checkout to the branch + * Create a Maven Project in the above cloned repository + * Add TestNG and Selenium dependencies in the pom.xml-file + * Check the version of Chrome installed in your machine + * Download and save the compatible ChromeDriver + * Create a new package in src/test/java + * Create a new class in above create package + * Create a Test-method in above created class using @Test annotation + * Write code to Launch amazon.com (https://www.amazon.com/) + * + * Push all code in the github + * Create a new Pull request and assign it to the Collaborator (Lab Instructor) + * + */ +} diff --git a/src/test/java/Class1/UseSelenium.java b/src/test/java/Class1/UseSelenium.java new file mode 100644 index 0000000..fa30af7 --- /dev/null +++ b/src/test/java/Class1/UseSelenium.java @@ -0,0 +1,21 @@ +package Class1; + +import org.openqa.selenium.WebDriver; +import org.openqa.selenium.chrome.ChromeDriver; +import org.testng.annotations.Test; + +public class UseSelenium { + + @Test + public void useSeleniumLib() { + + // path of chromedriver + System.setProperty("webdriver.chrome.driver", "./Drivers/chromedriver"); // Mac + // System.setProperty("webdriver.chrome.driver", "./Drivers/chromedriver.exe"); // Windows + + WebDriver driver = new ChromeDriver(); + + driver.get("https://www.facebook.com/"); + + } +} diff --git a/src/test/java/Class1/UseTestNG.java b/src/test/java/Class1/UseTestNG.java new file mode 100644 index 0000000..5926b12 --- /dev/null +++ b/src/test/java/Class1/UseTestNG.java @@ -0,0 +1,49 @@ +package Class1; + +import org.testng.Assert; +import org.testng.annotations.Test; + +public class UseTestNG { + + /** + * Use of TestNG: + * 1. to create Test Method + * 2. to assert a test step + * assertEquals -> use when what to compare two values to be equal/identical + * eg: Assert.assertEquals(val1, val2, msg) + * Here, we are verifying if val1 is equals to val2 + * if equals, the test-Step will pass + * else the testcase will fail, and msg will be printed out + * + * assertTrue -> use when what to check if a boolean is true + * eg: Assert.assertTrue(val, msg) + * Here, we are verifying if val is true + * if val is true, the test-Step will pass + * else the testcase will fail, and msg will be printed out + * + * assertFalse -> use when what to check if a boolean is false + * eg: Assert.assertFalse(val, msg) + * Here, we are verifying if val is false + * if val is false, the test-Step will pass + * else the testcase will fail, and msg will be printed out + * + * + * Use of Selenium: + * to automate the web-testcases + * + */ + + @Test // Test - Annotation from testNG Library + public void verify2Plus2Is4() { + // Assert Library is part of TestNG Library + Assert.assertEquals(2+2 , 14, "2+2 is not coming as expected"); + + } + + + @Test + public void verify3Plus3Is6() { + // Assert + Assert.assertEquals(3+3 , 6, "3+3 is not coming as expected"); + } +} diff --git a/src/test/java/Class2/BasicMethods.java b/src/test/java/Class2/BasicMethods.java new file mode 100644 index 0000000..041cb00 --- /dev/null +++ b/src/test/java/Class2/BasicMethods.java @@ -0,0 +1,171 @@ +package Class2; + +import org.openqa.selenium.WebDriver; +import org.openqa.selenium.chrome.ChromeDriver; +import org.testng.Assert; +import org.testng.annotations.Test; + +public class BasicMethods { + + @Test + public void basicMethods() { + + // path of chromedriver + System.setProperty("webdriver.chrome.driver", "./Drivers/chromedriver"); + + WebDriver driver = new ChromeDriver(); + /** + * WebDriver is an Interface + * ChromeDriver/FirefoxDriver is a Class (which is related to WebDriver Interface) + * + * WebDriver driver -> driver is a variable of WebDriver Interface + * new ChromeDriver() -> object of ChromeDriver class + * + * WebDriver driver = new ChromeDriver(); + * Storing ChromeDriver-object into WebDriver-variable. + * + * ChromeDriver(C) extends RemoteWebDriver(C) ; RemoteWebDriver(C) implements WebDriver(I) + * + */ + + /** + * To launch a webpage + * + * Method-1 : get() + * + * Method-2 : navigate().to() + */ + String url = "https://www.facebook.com/"; + driver.get(url); + // OR + // driver.navigate().to(url); + /** + * get() vs navigate().to() + * + * get() -> launches the webpage and wait for few seconds (for webpage to load) + * before executing the next line in the code + * + * navigate().to() -> launches the webpage + * and goes to execute the next line in the code + */ + + // Sleep so that webpage loads completely (temporary solution) + try { + Thread.sleep(5000); // sleep for 5-seconds + } catch (InterruptedException e) { + e.printStackTrace(); + } + + /** + * Method to maximize the webpage + * + * method: maximize() + */ + // driver.manage().window().maximize(); + + /** + * To get the url from browser-window + * + * method: getCurrentUrl() + * Return type: String + */ + String currentUrl = driver.getCurrentUrl(); + System.out.println("Current url -> " + currentUrl); + + /** + * To get page title of the webpage + * + * method: getTitle() + */ + String pageTitle = driver.getTitle(); + System.out.println("Page title -> " + pageTitle); + + /** + * To back/forward in a web-browser + * + * method : back() + * method : forward() + */ + driver.navigate().back(); + + try { + Thread.sleep(2000); + } catch (InterruptedException e) { + e.printStackTrace(); + } + System.out.println("Page title -> " + driver.getTitle()); + + driver.navigate().forward(); + + try { + Thread.sleep(2000); + } catch (InterruptedException e) { + e.printStackTrace(); + } + System.out.println("Page title -> " + driver.getTitle()); + + + /** + * To refresh a webpage + * + * Method-1: click refresh-icon (method: refresh()) + * + * Method-2: go back then forward + * + * Method-3: Launch the current url + * + */ + // 1 + driver.navigate().refresh(); + + // 2 + driver.navigate().back(); + driver.navigate().forward(); + + // 3 + /* + 1. get the current url (getCurrentUrl) + 2. launch the url got from step-1 (get) + */ + String myUrl = driver.getCurrentUrl(); + driver.get(myUrl); + + /** + * To close a webpage + * + * Method-1 : close() + * will close ONLY web-window associated/connected with driver + * + * + * Method-2 : quit() + * will close ALL web-windows opened due to automation code/script + */ + // driver.close(); + } + + // Verify correct url is launch + /* + Open a browser window + Launch facebook.com + verify currentUrl is facebook.com + + */ + @Test + public void verifyCorrectUrl() { + System.setProperty("webdriver.chrome.driver", "./Drivers/chromedriver"); + WebDriver driver = new ChromeDriver(); + String url = "https://www.facebook.com/"; + driver.get(url); + try { + Thread.sleep(5000); + } catch (InterruptedException e) { + e.printStackTrace(); + } + + String currentUrl = driver.getCurrentUrl(); + + Assert.assertEquals(url, currentUrl, "Current url is NOT same as launched url"); + + + } +} diff --git a/src/test/java/Class2/BasicMethods_Practice.java b/src/test/java/Class2/BasicMethods_Practice.java new file mode 100644 index 0000000..69535a1 --- /dev/null +++ b/src/test/java/Class2/BasicMethods_Practice.java @@ -0,0 +1,65 @@ +package Class2; + +import Helper.Misc; +import Web.MyDriver; +import org.testng.Assert; +import org.testng.annotations.Test; + +public class BasicMethods_Practice { + + // TC-1: Verify the facebook page title starts with "facebook" on facebook home page + /* + Steps: + 1. Launch a new browser window + 2. Open facebook.com + 3. Verify page title starts with "facebook" + */ + @Test + public void verifyTitle() { + MyDriver.launchUrlOnNewWindow("https://www.facebook.com/"); + + String pageTitle = MyDriver.getDriver().getTitle(); + boolean isStartsWith_facebook = pageTitle.startsWith("facebook"); + Assert.assertTrue(isStartsWith_facebook , "Facebook title does NOT start with 'facebook'"); + + MyDriver.quitWindows(); + + } + + // TC-2: Verify the url stays same after refreshing the facebook home page + /* + 1. Launch a new browser window + 2. Open facebook.com + 3. Observe the url-value + 4. Refresh the webpage + 5. Verify url value is same as of Step-3 + + */ + @Test + public void verifyUrlAfterRefresh() { + MyDriver.launchUrlOnNewWindow("https://www.facebook.com/"); + + String urlAfterLaunch = MyDriver.getDriver().getCurrentUrl(); + + MyDriver.getDriver().navigate().refresh(); + Misc.pause(5); + + String urlAfterRefresh = MyDriver.getDriver().getCurrentUrl(); + Assert.assertEquals(urlAfterLaunch, urlAfterRefresh, "Facebook url is NOT same after refresh"); + + MyDriver.quitWindows(); + } + + // TC-3: Verify current url is ending with "/" on facebook home page + @Test + public void verifyUrlEnding() { + MyDriver.launchUrlOnNewWindow("https://www.facebook.com/"); + + String urlAfterLaunch = MyDriver.getDriver().getCurrentUrl(); + + boolean urlEndsWith_Slash = urlAfterLaunch.endsWith("/"); + Assert.assertTrue(urlEndsWith_Slash, "Facebook url does NOT end with '/'"); + + MyDriver.quitWindows(); + } +} diff --git a/src/test/java/Class3/Class3.java b/src/test/java/Class3/Class3.java new file mode 100644 index 0000000..706fe72 --- /dev/null +++ b/src/test/java/Class3/Class3.java @@ -0,0 +1,9 @@ +package Class3; + +public class Class3 { + + + + + +} diff --git a/src/test/java/Class3/Locators_1.java b/src/test/java/Class3/Locators_1.java new file mode 100644 index 0000000..764f2b7 --- /dev/null +++ b/src/test/java/Class3/Locators_1.java @@ -0,0 +1,70 @@ +package Class3; + +public class Locators_1 { + + /** + * Types of WebElements: + * Button -> click + * TextBox/InputField -> type + * Links -> click + * Dropdown -> click + * Radio Button -> click + * CheckBox -> click + * Image -> click, get text from Image + * Text/Copy -> + * Alert + * Frames + */ + + /** + * Chropath plugin: + * https://chrome.google.com/webstore/detail/chropath/ljngjbnaijcbncmcnjfhigebomdlkcjo + */ + + /** + * Locator is a kind of route to reach/find a particular webElement. + * Datatype of locator -> By + * + * + * + * Steps to interact with webElement: + * 1. Find the unique address to reach to the WebElement using DOM + * 2. Depending upon the type of address, + * we use specific method from By-Class to create locator + * 3. Use locator to find the WebElement using findElement() + * 4. once webElement is found, interact with it + */ + /** + * Address: + * 1. using the id-attribute + * In chropath, check if id-value is unique --> //*[@id='idAttr-Value'] + * By locatorUsingId = By.id("idAttr-Value") + * + * eg: + * By loginEmailLocator = By.id("email"); + * + * 2. using name-attribute + * In chropath, check if name-value is unique --> //*[@name='nameAttr-Value'] + * By locatorUsingName = By.name("nameAttr-Value"); + * + * eg: + * By loginButtonLocator = By.name("login"); + * + * 3. using the tagName + * In chropath, check if tag is unique --> //tagName + * By locatorUsingTagName = By.tagName("tagNameValue") + * + * eg: + * By loginBtnLocator = By.tagName("button") + * + * 4. using the class-attribute + * In chropath, check if class-value is unique --> //*[@class='classAttr-Value'] + * By locatorUsingClassName = By.className("classAttr-Value") + * + * eg: + * By locatorUsingClassName = By.className("_8esk"); + * + * + */ + +} diff --git a/src/test/java/Class3/UseLocator_1.java b/src/test/java/Class3/UseLocator_1.java new file mode 100644 index 0000000..dc19c53 --- /dev/null +++ b/src/test/java/Class3/UseLocator_1.java @@ -0,0 +1,73 @@ +package Class3; + +import Helper.Misc; +import Web.MyDriver; +import org.openqa.selenium.By; +import org.openqa.selenium.WebElement; +import org.testng.annotations.Test; + +public class UseLocator_1 { + + /** + * To find a WebElement + * method: findElement + * input: By (locator for WebElement which we want to interact with) + * return type: WebElement + * + * if the element is found using the locator + * method returns WebElement + * else + * NoSuchElement Exception + */ + + /** + * To type in a webElement + * method: sendKeys() + * input: String (data that we want to type in the webElement) + */ + + /** + * To click on a webElement + * method: click() + */ + + /** + * To clear the text in a webElement + * method: clear() + */ + + // Using Selenium enter data in login Email and password ; and click login button + @Test + public void useLocators_1() { + MyDriver.launchUrlOnNewWindow("https://www.facebook.com/"); + + String loginEmailIdValue = "email"; + By loginEmailLocator = By.id(loginEmailIdValue); + WebElement loginEmailBox = MyDriver.getDriver().findElement(loginEmailLocator); + loginEmailBox.sendKeys("abcd@test.com"); + + Misc.pause(5); + // loginEmailBox.clear(); + // Misc.pause(3); + // loginEmailBox.sendKeys("testing@abc.com"); + + String loginPassNameValue = "pass"; + By loginPassLocator = By.name(loginPassNameValue); + WebElement loginPassBox = MyDriver.getDriver().findElement(loginPassLocator); + loginPassBox.sendKeys("abcd@1234"); + + + Misc.pause(5); + + + String loginButtonNameValue = "login"; + By loginLoginBtnLocator = By.name(loginButtonNameValue); + WebElement loginButton = MyDriver.getDriver().findElement(loginLoginBtnLocator); + loginButton.click(); + + + + + + } +} diff --git a/src/test/java/Class3/WebElements_DOM.java b/src/test/java/Class3/WebElements_DOM.java new file mode 100644 index 0000000..5a21793 --- /dev/null +++ b/src/test/java/Class3/WebElements_DOM.java @@ -0,0 +1,180 @@ +package Class3; + +public class WebElements_DOM { + + /** + * DOM -> Document Object Model + * + * Front End code -> generates DOM -> DOM creates the website + * + * DOM is always a html document. + * + * + *
+ * + * + * + * + * + *+ *
+ * Verify "Keep me signed in" is NOT selected for messenger login page + *
+ * Click "Log in" button + *
+ * Verify "Incorrect email or phone number" is displayed + *
+ * Verify "Continue" button is enabled + */ + + + @AfterMethod + public void pause() { + + Misc.pause(3); + } + + + @Test + public void openMessenger() { + + MyDriver.launchUrlOnNewWindow("https://www.facebook.com/"); + String messengerText = "Messenger"; + By messengerLocator = By.linkText(messengerText); + WebElement messengerLink = MyDriver.getDriver().findElement(messengerLocator); + + String hrefValue = messengerLink.getAttribute("href"); + Assert.assertTrue(hrefValue.contains("messenger.com"), "href on messenger link is incorrect"); + + + messengerLink.click(); + + String urlAfterLink = MyDriver.getDriver().getCurrentUrl(); + Assert.assertTrue(urlAfterLink.contains("messenger.com"), "Url is incorrect"); + + MyDriver.getDriver().manage().window().maximize(); + } + + + @Test + public void checkKeepMeSignIn() { + + + openMessenger(); + + + String checkBoxXPath = "//input[@type='checkbox']/following-sibling::span"; + By checkBoxLocator = By.xpath(checkBoxXPath); + WebElement checkBoxKeepMeLogIN = MyDriver.getDriver().findElement(checkBoxLocator); + Assert.assertEquals(false, checkBoxKeepMeLogIN.isSelected()); + + } + + + @Test + public void clickLogInButton() { + + + checkKeepMeSignIn(); + + + String logInEmailId = "email"; + By logInEmailLocator = By.id(logInEmailId); + WebElement logInEmail = MyDriver.getDriver().findElement(logInEmailLocator); + logInEmail.sendKeys("kreshniknikci@hotmail.com"); + + + String logInPass = "pass"; + By logInPassLocator = By.id(logInPass); + WebElement logInPassword = MyDriver.getDriver().findElement(logInPassLocator); + logInPassword.sendKeys("TechnoSoft*@2022"); + + + String logInButton = "loginbutton"; + By logInButtonLocator = By.id(logInButton); + WebElement logInBtn = MyDriver.getDriver().findElement(logInButtonLocator); + + + logInBtn.click(); + + + } + + + @Test + public void errorMessage() { + + + clickLogInButton(); + + + String errorMsgXpath = "//div[contains(text(),'Incorrect Email')]"; + By loginErrorLocator = By.xpath(errorMsgXpath); + WebElement loginError = MyDriver.getDriver().findElement(loginErrorLocator); + Assert.assertEquals(loginError.getText(), "Incorrect Email", "Login error is not displayed"); + //Assert.assertEquals(loginError.getText(), errorMsgXpath, "Login error is not displayed"); + + + //By loginbutton = By.xpath("//button[@text='Continue']"); + + + //MyDriver.quitWindows(); + } + + + @Test + public void verifyContinueButtonIsEnabled() { + + + errorMessage(); + + + String continueButtonStr = "loginbutton"; + By continueLocatorById = By.id(continueButtonStr); + WebElement continueButton = MyDriver.getDriver().findElement(continueLocatorById); + Assert.assertEquals(true, continueButton.isEnabled()); + + + } + + @AfterSuite + public void closeWindows() { + MyDriver.quitWindows(); + } + + + /** + * Testcase-2: + * On Create new account page: + *
+ * Verify the "Sign Up" button is enabled when user lands on the form + *
+ * Enter the below details in Sign Up form EXCEPT DOB + * First name + * Last name + * email + * re-enter email + * new password + * click Sign Up + *
+ * Verify "Please choose a gender. You can change who can see this later." is displayed
+ */
+
+
+ @Test
+ public void verifySignUpButton() {
+
+ MyDriver.launchUrlOnNewWindow("https://www.facebook.com/");
+
+ By createNewAccountLocator = By.partialLinkText("Create new account");
+ WebElement createNewAccBtn = MyDriver.getDriver().findElement(createNewAccountLocator);
+
+ createNewAccBtn.click();
+
+ String signUpButtonLinkText = "Sign Up";
+ By signUpButtonLocator = By.linkText(signUpButtonLinkText);
+ WebElement signUpButton = MyDriver.getDriver().findElement(signUpButtonLocator);
+ Assert.assertEquals(true, signUpButton.isEnabled());
+
+
+ Misc.pause(3);
+ MyDriver.quitWindows();
+ }
+
+ @Test
+
+ public void enterDetails (){
+
+ MyDriver.launchUrlOnNewWindow("https://www.facebook.com/");
+
+ By createNewAccountLocator = By.partialLinkText("Create new account");
+ WebElement createNewAccBtn = MyDriver.getDriver().findElement(createNewAccountLocator);
+
+ createNewAccBtn.click();
+ Misc.pause(3);
+
+ MyDriver.getDriver().manage().window().maximize();
+ String firstNameByContains = "//div[@id='fullname_field']//input[@name='firstname']";
+ By firstNameLocationByXpath = By.xpath(firstNameByContains);
+ WebElement firstName = MyDriver.getDriver().findElement(firstNameLocationByXpath);
+ firstName.sendKeys("kreshnik");
+
+
+ String lastNameById = "lastname";
+ By lastNameLocationByName = By.name(lastNameById);
+ WebElement lastName = MyDriver.getDriver().findElement(lastNameLocationByName);
+ lastName.sendKeys("nikci");
+
+
+ String mobileNumberOrEmailById = "//div[contains(text(),'number or email')]/following-sibling::input";
+ By mobileNumberOrEmailLocationByXpath = By.xpath(mobileNumberOrEmailById);
+ WebElement mobileNumberOrEmail = MyDriver.getDriver().findElement(mobileNumberOrEmailLocationByXpath);
+ mobileNumberOrEmail.sendKeys("kreshnik.nikci@gmail.com");
+
+
+
+
+ String reEnterEmailByXpath = "//div[contains(text(),'Re-enter email')]/following-sibling::input";
+ By reEnterEmailLocationByXpath = By.xpath(reEnterEmailByXpath);
+ WebElement reEnterEmail = MyDriver.getDriver().findElement(reEnterEmailLocationByXpath);
+ reEnterEmail.sendKeys("kreshnik.nikci@gmail.com");
+
+
+
+ String newPasswordById = "//div[contains(text(),'New password')]/following-sibling::input";
+ By newPasswordLocationByID = By.xpath(newPasswordById);
+ WebElement newPassword = MyDriver.getDriver().findElement(newPasswordLocationByID);
+ newPassword.sendKeys("Kreshnik*@TechnoSoft2022");
+
+
+ }
+
+
+}
diff --git a/src/test/java/Class4/Locators_2.java b/src/test/java/Class4/Locators_2.java
new file mode 100644
index 0000000..440fa32
--- /dev/null
+++ b/src/test/java/Class4/Locators_2.java
@@ -0,0 +1,127 @@
+package Class4;
+
+public class Locators_2 {
+
+
+ /**
+ * Types of WebElements:
+ * Button -> click
+ * TextBox/InputField -> type
+ * Links -> click
+ * Dropdown -> click
+ * Radio Button -> click
+ * CheckBox -> click
+ * Image -> click, get text from Image
+ * Text/Copy ->
+ * Alert
+ * Frames
+ */
+
+ /**
+ * Chropath plugin:
+ * https://chrome.google.com/webstore/detail/chropath/ljngjbnaijcbncmcnjfhigebomdlkcjo
+ */
+
+ /**
+ * Locator is a kind of route to reach/find a particular webElement.
+ * Datatype of locator -> By
+ *
+ *
+ *
+ * Steps to interact with webElement:
+ * 1. Find the unique address to reach to the WebElement using DOM
+ * 2. Depending upon the type of address,
+ * we use specific method from By-Class to create locator
+ * 3. Use locator to find the WebElement using findElement()
+ * 4. once webElement is found, interact with it
+ */
+ /**
+ * Address:
+ * 5. linkText (Refer Link discussion below)
+ * In chropath, check if the linkText is unique --> //a[text()='linkText']
+ * By locatorUsingLinkText = By.linkText("link text value")
+ *
+ * eg:
+ * By createNewAccountLocator = By.linkText("Create new account");
+ *
+ * 6. partialLinkText (Refer Link discussion below)
+ * In chropath, check if the linkText is unique --> //a[contains(text() , 'link t')]
+ * By locatorUsingPartialLinkText = By.partialLinkText("k text va")
+ *
+ * eg:
+ * By createNewAccountLocator = By.partialLinkText("e new a");
+ *
+ * 7. Xpath
+ * In chropath, create x-path to find the webElement
+ * By locatorUsingXpath = By.xpath("//xpath that you have created to find the webElement");
+ *
+ */
+
+ /**
+ * Link:
+ * 1. Always with 'a' tag
+ * 2. Text associated with a link (or a-tag) is called Link-Text
+ * 3. The value of href-attribute defines where user will land if click the link.
+ */
+ /**
+ * XPATH
+ *
+ * Types:
+ * 1. Absolute Xpath
+ * a) starts with single slash (/)
+ * b) tells the rout to reach to a particular webElement from the root-tag (html-tag)
+ * c) not reliable, any change in the webPage can break the absolute xpath
+ *
+ * 2. Relative Xpath
+ * a) starts with double slash (//)
+ * b) reliable bcz we use tagName, attribute-value, text-Value in any combination
+ *
+ * -> simple xpath (direct xpath)
+ * -> advanced xpath (indirect xpath)
+ *
+ */
+
+ /**
+ * Simple xpath (direct xpath)
+ *
+ * 1. Using any attribute's value:
+ * //tag[@attrName='attr-value']
+ * --> find the tag in dom, which has attrName(attribute) with value equals to attr-value
+ * eg:
+ * //input[@data-testid='royal_email']
+ *
+ * 2. Using text-value:
+ * //tag[text()='webElement text value']
+ * --> find the tag in dom, which has text-value with value equals to "webElement text value"
+ * eg:
+ * //button[text()='Log In']
+ *
+ * 3. Using any attribute's partial value
+ * //tag[contains(@attrName,'attr-va')]
+ * --> find the tag in dom, which has attrName(attribute)'s value contains "attr-va"
+ * eg:
+ * //button[contains(@data-testid,'royal_l')]
+ *
+ * 4. Using partial text value:
+ * //tag[contains(text(),'Text va')]
+ * --> find the tag in dom, where text-value contains "Text va"
+ * eg:
+ * //a[contains(text() , 'got p')]
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ */
+
+
+ /**
+ * //*[contains(@data-testid,'login_bu')]
+ * --> find any tag in dom, where attribute(data-testid) contains "login_bu"
+ *
+ *
+ */
+}
diff --git a/src/test/java/Class4/UseLocators_2.java b/src/test/java/Class4/UseLocators_2.java
new file mode 100644
index 0000000..01913bb
--- /dev/null
+++ b/src/test/java/Class4/UseLocators_2.java
@@ -0,0 +1,213 @@
+package Class4;
+
+import Helper.Misc;
+import Web.MyDriver;
+import org.openqa.selenium.By;
+import org.openqa.selenium.WebElement;
+import org.testng.Assert;
+import org.testng.annotations.Test;
+
+public class UseLocators_2 {
+
+ /**
+ * To find a WebElement
+ * method: findElement
+ * input: By (locator for WebElement which we want to interact with)
+ * return type: WebElement
+ *
+ * if the element is found using the locator
+ * method returns WebElement
+ * else
+ * NoSuchElement Exception
+ */
+
+ /**
+ * To type in a webElement
+ * method: sendKeys()
+ * input: String (data that we want to type in the webElement)
+ */
+
+ /**
+ * To click on a webElement
+ * method: click()
+ */
+
+ /**
+ * To clear the text in a webElement
+ * method: clear()
+ */
+
+ /**
+ * To get the value of one of the attribute of a webElement
+ * method: getAttribute()
+ * input: attrName
+ * return type: String
+ */
+
+ /**
+ * To get the text of a webElement
+ * method: getText()
+ * return type: String
+ */
+
+ /**
+ * To get if a webElement is enabled or not
+ * method: isEnabled()
+ * return type: boolean
+ */
+
+ /**
+ * To get if a webElement is displayed or not
+ * method: isDisplayed()
+ * return type: boolean
+ */
+
+ /**
+ * To get if a webElement is selected or not
+ * method: isSelected()
+ * return type: boolean
+ */
+
+ // TC -> Verify user lands on correct page after click Messenger link
+ /*
+ Steps:
+ 1. Launch browser
+ 2. Open facebook.com
+ 3. Click Messenger link
+ 4. Verify user lands on messenger.com
+
+ 3. Click Messenger link
+ find the locator of Messenger link
+ find the webElement using the locator
+ get the value of href-attribute
+ verify href-attribute's value is "messenger.com"
+ click the webElement
+
+ 4. Verify user lands on messenger.com
+ get current-url using getCurrentUrlMethod
+ verify currentUrl is "messenger.com"
+ */
+ @Test
+ public void verifyMessengerLink() {
+ MyDriver.launchUrlOnNewWindow("https://www.facebook.com/");
+
+ String messengerText = "Messenger";
+ By messengerLocator = By.linkText(messengerText);
+ WebElement messengerLink = MyDriver.getDriver().findElement(messengerLocator);
+
+ String hrefValue = messengerLink.getAttribute("href");
+ Assert.assertTrue(hrefValue.contains("messenger.com"), "href on messenger link is incorrect");
+
+ messengerLink.click();
+
+ Misc.pause(5);
+
+ String urlAfterLink = MyDriver.getDriver().getCurrentUrl();
+ Assert.assertTrue(urlAfterLink.contains("messenger.com"), "Url is incorrect");
+
+ MyDriver.quitWindows();
+ }
+
+ // TC -> Verify create new account button text is "Create New Account"
+ /*
+ Steps:
+ 1. Launch browser
+ 2. Open facebook.com
+ 3. Verify text/copy on create new account btn is "Create New Account"
+
+
+ 3. Verify text/copy on create new account btn is "Create New Account"
+ find the locator for create new account btn
+ find the webElement using locator
+ get the text of the WebElement
+ verify text is equals to "Create New Account"
+ */
+ @Test
+ public void verifyCreateNewAccountBtnText() {
+ MyDriver.launchUrlOnNewWindow("https://www.facebook.com/");
+
+ By createNewAccountLocator = By.partialLinkText("ccount");
+ WebElement createNewAccBtn = MyDriver.getDriver().findElement(createNewAccountLocator);
+ String createNewAccBtnText = createNewAccBtn.getText();
+ Assert.assertEquals(createNewAccBtnText, "Create New Account", "Create new account btn copy is not correct");
+
+ MyDriver.quitWindows();
+
+ }
+
+ // TC -> Verify the login button is enabled when user lands on facebook.com
+ /*
+ Steps:
+ 1. Launch browser
+ 2. Open facebook.com
+ 3. Verify Login button is enabled
+
+
+ 3. Verify Login button is enabled
+ find locator for login button
+ find webElement using the locator
+ Verify webElement is enabled
+ */
+ @Test
+ public void isLoginEnabled() {
+ MyDriver.launchUrlOnNewWindow("https://www.facebook.com/");
+
+ String loginBtnXpath = "//button[@type='submit']";
+ By loginBtnLocator = By.xpath(loginBtnXpath);
+ WebElement loginBtn = MyDriver.getDriver().findElement(loginBtnLocator);
+
+ boolean isLoginBtnEnabled = loginBtn.isEnabled();
+ Assert.assertTrue(isLoginBtnEnabled, "Login btn is not enabled when user lands on facebook.com");
+
+ MyDriver.quitWindows();
+
+ }
+
+
+ // TC -> Verify error message is displayed for invalid credentials
+ /*
+ Steps:
+ 1. Launch browser
+ 2. Open facebook.com
+ 3. Enter "$%^&*(" as login email
+ 4. Enter "abcd@1234" as login pwd
+ 5. Click login button
+ 6. Verify error msg is displayed (The email or mobile number you entered isn’t connected to an account.)
+ */
+ @Test
+ public void verifyErrorMsgOnInvalidLoginCredentials() {
+ MyDriver.launchUrlOnNewWindow("https://www.facebook.com/");
+
+ String loginEmailId = "email";
+ By loginEmailLocator = By.id(loginEmailId);
+ WebElement loginEmail = MyDriver.getDriver().findElement(loginEmailLocator);
+ loginEmail.sendKeys("$%^&*(");
+
+ // String loginPassXpath = "//input[contains(@data-testid , '_pass')]";
+ // By loginPassLocator = By.xpath(loginPassXpath);
+ // WebElement loginPass = MyDriver.getDriver().findElement(loginPassLocator);
+ // loginPass.sendKeys("abcd@1234");
+
+ MyDriver.getDriver().findElement(By.xpath("//input[contains(@data-testid , '_pass')]")).sendKeys("abcd@1234");
+
+ By loginBtnLocator = By.xpath("//*[@data-testid='royal_login_button']");
+ WebElement loginBtn = MyDriver.getDriver().findElement(loginBtnLocator);
+ loginBtn.click();
+
+ Misc.pause(5);
+
+ String expErrorMsg = "The email or mobile number you entered isn’t connected to an account.";
+ By loginErrorLocator = By.xpath("//div[contains(text() , 'connected to an')]");
+ WebElement loginError = MyDriver.getDriver().findElement(loginErrorLocator);
+ Assert.assertEquals(loginError.getText().trim(), expErrorMsg, "Login error is not displayed");
+ // get the text of WebElement
+ // Verify the text of WebElement is equals to "The email or mobile number you entered isn’t connected to an account."
+
+ // OR
+
+ By loginErrorLocator2 = By.xpath("//div[text()='The email or mobile number you entered isn’t connected to an account. ']");
+ WebElement loginError2 = MyDriver.getDriver().findElement(loginErrorLocator2);
+ Assert.assertTrue(loginError2.isDisplayed(), "Login error is not displayed");
+
+ }
+}
diff --git a/src/test/java/Class5/Actions_Concept.java b/src/test/java/Class5/Actions_Concept.java
new file mode 100644
index 0000000..45b62f2
--- /dev/null
+++ b/src/test/java/Class5/Actions_Concept.java
@@ -0,0 +1,48 @@
+package Class5;
+
+import Web.MyDriver;
+import org.openqa.selenium.By;
+import org.openqa.selenium.WebElement;
+import org.openqa.selenium.interactions.Actions;
+import org.testng.annotations.Test;
+
+public class Actions_Concept {
+
+ /**
+ * mouseHover -> moveToElement()
+ * right click -> contextClick()
+ * double click -> doubleClick()
+ * Drag and drop -> dragAndDrop()
+ * click -> click()
+ * type -> sendKeys()
+ *
+ */
+ // TC -> Verify user can see news/notification when perform mouse hover on bell icon
+ /*
+ 1. launch browser
+ 2. open yahoo.com
+ 3. move mouse on bell-icon
+ 4. Verify news/notification is displayed
+ */
+ @Test
+ public void ActionsDemo() {
+
+ MyDriver.launchUrlOnNewWindow("https://www.yahoo.com/");
+
+ By bellIconLocator = By.xpath("//label[@for='ybarNotificationMenu']");
+ WebElement bellIcon = MyDriver.getDriver().findElement(bellIconLocator);
+
+ Actions action = new Actions(MyDriver.getDriver());
+ action.moveToElement(bellIcon).perform();
+ }
+
+ /**
+ * .build().perform() vs .perform();
+ *
+ * when a method (from Actions class) is doing only 1-action -> .perform() is enough
+ * [but we can use .build().perform() as well]
+ *
+ * when a method (from Actions class) is more than 1-action -> .build().perform()
+ *
+ */
+}
diff --git a/src/test/java/Class5/Dropdowns.java b/src/test/java/Class5/Dropdowns.java
new file mode 100644
index 0000000..dccd446
--- /dev/null
+++ b/src/test/java/Class5/Dropdowns.java
@@ -0,0 +1,69 @@
+package Class5;
+
+import Helper.Misc;
+import Web.MyDriver;
+import org.openqa.selenium.By;
+import org.openqa.selenium.WebElement;
+import org.openqa.selenium.support.ui.Select;
+import org.testng.annotations.Test;
+
+public class Dropdowns {
+
+ /**
+ * Dropdowns
+ *
+ * dropdown are either 'select' or any other tag
+ *
+ * Dropdown with select-tag --> Select class
+ *
+ * 1. find the locator of the dropdown webElement (or select-tag)
+ * 2. find the dropdown-webElement using step-1 locator
+ * 3. Create an object of Select-class, and pass the dropdown-WebElement (found on Step-2) in the Constructor
+ * 4. Use relevant method form Select class to select the desired value in the dropdown
+ * selectByVisibleText | selectByValue | selectByIndex
+ */
+
+ // TC -> Select date of birth values in the sign up dropdown
+ // Jan 01 1990
+ /*
+ Steps:
+ 1. Launch browser
+ 2. open facebook.com
+ 3. Click 'Create new account' button
+ 4. Select Jan 01 1990 in date of birth dropdown
+ */
+ @Test
+ public void dropdowns() {
+
+ MyDriver.launchUrlOnNewWindow("https://www.facebook.com/");
+
+ By createNewAccountLocator = By.xpath("//a[text()='Create new account' or text()='Create New Account']");
+ MyDriver.getDriver().findElement(createNewAccountLocator).click();
+
+ Misc.pause(5);
+
+ By monthDdLocator = By.id("month");
+ WebElement monthDdElement = MyDriver.getDriver().findElement(monthDdLocator);
+ Select monthDd = new Select(monthDdElement);
+ monthDd.selectByVisibleText("Jan");
+
+ By dateDdLocator = By.name("birthday_day");
+ WebElement dateDdElement = MyDriver.getDriver().findElement(dateDdLocator);
+ Select dateDd = new Select(dateDdElement);
+ dateDd.selectByValue("1");
+
+ By yearDdLocator = By.xpath("//select[starts-with(@title, 'Ye')]");
+ WebElement yearDdElement = MyDriver.getDriver().findElement(yearDdLocator);
+ Select yearDd = new Select(yearDdElement);
+ yearDd.selectByIndex(2);
+
+ }
+
+
+ @Test
+ public void dropdownsNotSelectTag() {
+
+
+
+ }
+}
diff --git a/src/test/java/Class5/Homework3.java b/src/test/java/Class5/Homework3.java
new file mode 100644
index 0000000..4d2a20e
--- /dev/null
+++ b/src/test/java/Class5/Homework3.java
@@ -0,0 +1,64 @@
+package Class5;
+
+import Web.MyDriver;
+import org.openqa.selenium.By;
+import org.openqa.selenium.WebElement;
+import org.testng.Assert;
+import org.testng.annotations.Test;
+
+public class Homework3 {
+
+ // Due date: Fri (Apr 29)
+
+ /**
+ * TC-1: darksky.net
+ * Verify correct temperature value is displayed after changing temperature units
+ */
+
+ /**
+ * TC-2: facebook.com
+ * Verify current date is selected in the dropdown when user lands on the Create new account form
+ */
+
+ /**
+ * TC-3: https://classroomessentialsonline.com/
+ * Verify user lands on Economy Church Chairs page after clicking the option from Church Chairs
+ */
+
+ @Test
+ public void verifyChangeTempValue (){
+
+ MyDriver.launchUrlOnNewWindow("https://darksky.net/");
+
+ MyDriver.getDriver().manage().window().maximize();
+
+ String arrowLocatorXpath = "//body/div[@id='header']/div[1]/div[1]/div[2]/b[1]";
+ By arrowLocatorByXpath = By.xpath(arrowLocatorXpath);
+ WebElement arrowLocator = MyDriver.getDriver().findElement(arrowLocatorByXpath);
+ arrowLocator.click();
+
+ String changeToCTempKmhXpath = "//body/div[@id='header']/div[1]/div[1]/div[3]/div[1]/ul[1]/li[3]";
+ By changeToCTempKmhByXpath = By.xpath(changeToCTempKmhXpath);
+ WebElement changeToCTempKmh = MyDriver.getDriver().findElement(changeToCTempKmhByXpath);
+ changeToCTempKmh.click();
+
+ String verifyTempValueContains = "//span[@class='desc swap']";
+ By verifyTempValueByText = By.xpath(verifyTempValueContains);
+ WebElement verifyTempValue = MyDriver.getDriver().findElement(verifyTempValueByText);
+ verifyTempValue.isEnabled();
+
+
+ }
+
+
+ @Test
+ public void verifyCurrentDateIsSelected () {
+
+ MyDriver.launchUrlOnNewWindow("https://www.facebook.com/");
+
+ By createNewAccountLocator = By.partialLinkText("Create new account");
+ WebElement createNewAccBtn = MyDriver.getDriver().findElement(createNewAccountLocator);
+
+ createNewAccBtn.click();
+ }
+}
diff --git a/src/test/java/Class5/Locators_3.java b/src/test/java/Class5/Locators_3.java
new file mode 100644
index 0000000..4cbdd95
--- /dev/null
+++ b/src/test/java/Class5/Locators_3.java
@@ -0,0 +1,95 @@
+package Class5;
+
+public class Locators_3 {
+
+ /**
+ * Types of WebElements:
+ * Button -> click
+ * TextBox/InputField -> type
+ * Links -> click
+ * Dropdown -> click
+ * Radio Button -> click
+ * CheckBox -> click
+ * Image -> click, get text from Image
+ * Text/Copy ->
+ * Alert
+ * Frames
+ */
+
+ /**
+ * Chropath plugin:
+ * https://chrome.google.com/webstore/detail/chropath/ljngjbnaijcbncmcnjfhigebomdlkcjo
+ */
+
+ /**
+ * Locator is a kind of route to reach/find a particular webElement.
+ * Datatype of locator -> By
+ *
+ *
+ *
+ * Steps to interact with webElement:
+ * 1. Find the unique address to reach to the WebElement using DOM
+ * 2. Depending upon the type of address,
+ * we use specific method from By-Class to create locator
+ * 3. Use locator to find the WebElement using findElement()
+ * 4. once webElement is found, interact with it
+ */
+
+ /**
+ * Simple xpath (direct xpath)
+ *
+ * 5. Using the starting portion of attribute's value
+ * //tag[starts-with(@attrName, 'starting portion of attrName's value')]
+ * --> find the tag in dom, which has attrName(attribute)'s value starts with "starting portion of attrName's value"
+ * eg:
+ * //input[starts-with(@aria-label, 'Fir')]
+ *
+ * 6. Using the starting portion of text-value
+ * //tag[starts-with(text(), 'starting portion of text-value')]
+ * --> find the tag in dom, which has text-value starts with "starting portion of text-value"
+ * eg:
+ * //label[starts-with(text(), 'Fe')]
+ *
+ * 7. Using not() method
+ * //tag[not(@attrName='attr-value')]
+ * --> find the tag in dom, which has attrName(attribute) with value NOT equals to attr-value
+ *
+ * //tag[not(text()='webElement text value')]
+ * --> find the tag in dom, which has text-value with value NOT equals to "webElement text value"
+ *
+ * 8. and/or operator
+ * //tag[contains(text(), 'text Val') and @attrName='attr-value']
+ * --> find the tag in dom, where
+ * text contains 'text Val'
+ * and
+ * attribute(attrName) has value equals to 'attr-value'
+ *
+ * //tag[text()='text value' or starts-with(@attrName, 'Attr Va')]
+ * --> find the tag in dom, where
+ * text is equals to 'text value'
+ * or
+ * attribute(attrName)'s value starts with 'Attr Va'
+ *
+ *
+ * //tag[text()='text value' or starts-with(@attrName, 'Attr Va') or contains(@attrName1, 'Attr1 Va')]
+ * --> find the tag in dom, where
+ * text is equals to 'text value'
+ * or
+ * attribute(attrName)'s value starts with 'Attr Va'
+ * or
+ * attribute(attrName1)'s value contains 'Attr1 Va'
+ *
+ *
+ * //button[text()='Sign Up' or text()='Submit']
+ * //a[text()='Create new account' or text()='Create New Account']
+ *
+ */
+
+
+ /**
+ * //*[contains(@data-testid,'login_bu')]
+ * --> find any tag in dom, where attribute(data-testid) contains "login_bu"
+ *
+ *
+ */
+}
diff --git a/src/test/java/Class5/Locators_4.java b/src/test/java/Class5/Locators_4.java
new file mode 100644
index 0000000..5b11e77
--- /dev/null
+++ b/src/test/java/Class5/Locators_4.java
@@ -0,0 +1,76 @@
+package Class5;
+
+public class Locators_4 {
+
+ /**
+ * Types of WebElements:
+ * Button -> click
+ * TextBox/InputField -> type
+ * Links -> click
+ * Dropdown -> click
+ * Radio Button -> click
+ * CheckBox -> click
+ * Image -> click, get text from Image
+ * Text/Copy ->
+ * Alert
+ * Frames
+ */
+
+ /**
+ * Chropath plugin:
+ * https://chrome.google.com/webstore/detail/chropath/ljngjbnaijcbncmcnjfhigebomdlkcjo
+ */
+
+ /**
+ * Locator is a kind of route to reach/find a particular webElement.
+ * Datatype of locator -> By
+ *
+ *
+ *
+ * Steps to interact with webElement:
+ * 1. Find the unique address to reach to the WebElement using DOM
+ * 2. Depending upon the type of address,
+ * we use specific method from By-Class to create locator
+ * 3. Use locator to find the WebElement using findElement()
+ * 4. once webElement is found, interact with it
+ */
+
+ /**
+ * Advanced Xpath (Indirect xpath):
+ *
+ * 1. Using parent/grandParent tag
+ * //div[contains(@class, 'selectric-below')]//div[@class='selectric']//b
+ *
+ * 2. Xpath axes:
+ * 1. following-sibling
+ * //tag[condition(s)]/following-sibling::tag2[condition(s)]
+ * eg:
+ * //label[text()='Female']/following-sibling::input
+ * //h2[text()='June 2022']/following-sibling::table//button[@data-day='20']
+ *
+ * 2. preceding-sibling
+ * //tag[condition(s)]/preceding-sibling::tag2[condition(s)]
+ *
+ * 3. following
+ * //tag[condition(s)]/following::tag2[condition(s)]
+ * eg:
+ * //a[text()='Help']/following::div[contains(@class, 'copyright')]//span[text()=' Meta © 2022']
+ *
+ * 4. preceding
+ * //tag[condition(s)]/preceding::tag2[condition(s)]
+ * eg:
+ * //a[text()='Create new account']/preceding::button[@name='login']
+ *
+ * 5. ancestor
+ * //tag[condition(s)]/ancestor::tag2[condition(s)]
+ *
+ * 6. descendant
+ * //tag[condition(s)]/descendant::tag2[condition(s)]
+ */
+
+
+ /**
+ * //*[contains(@data-testid,'login_bu')]
+ * --> find any tag in dom, where attribute(data-testid) contains "login_bu"
+ */
+}
diff --git a/src/test/java/Class5/exHomework3.java b/src/test/java/Class5/exHomework3.java
new file mode 100644
index 0000000..5df5a79
--- /dev/null
+++ b/src/test/java/Class5/exHomework3.java
@@ -0,0 +1,123 @@
+package Class5;
+
+public class exHomework3 {
+
+ @Test
+ public void isTempValCorrect(){
+
+ MyDriver.launchUrlOnNewWindow("https://www.darksky.net/");
+
+ MyDriver.getDriver().manage().window().maximize();
+
+ By tempValLocator = By.xpath("//span[contains(text() ,'Feels Like')]/following-sibling::*");
+ WebElement tempValElement = MyDriver.getDriver().findElement(tempValLocator);
+ String TempValDisplayedF = tempValElement.getText();
+ String TempValDisplayedFDegRemoved = TempValDisplayedF.substring(0,TempValDisplayedF.length()-1);
+ double fahrenheitTempVal = Integer.parseInt(TempValDisplayedFDegRemoved);
+
+ By dropDownLocator = By.xpath("(//span[contains(text(),'F,')]//following-sibling::b[@class='button'])[1]");
+ WebElement dropDownElement = MyDriver.getDriver().findElement(dropDownLocator);
+ dropDownElement.click();
+
+ Misc.pause(2);
+
+ By selectingCelsiusLocator = By.xpath("(//li[contains(text(),'m/s') and @data-index='1'])[1]");
+ WebElement selectingCelsiusElement = MyDriver.getDriver().findElement(selectingCelsiusLocator);
+ selectingCelsiusElement.click();
+
+ Misc.pause(2);
+
+ By tempValLocatorAfterC = By.xpath("//div[@id='title']//span[@class='feels-like-text']");
+ WebElement tempValCElement = MyDriver.getDriver().findElement(tempValLocatorAfterC);
+ String tempValCInString = tempValCElement.getText();
+ String tempValCStringRemovalDegree = tempValCInString.substring(0,tempValCInString.length()-1);
+ double celsiusTempVal = Integer.parseInt(tempValCStringRemovalDegree);
+
+ double actualTempValInCUsingF = Math.round((fahrenheitTempVal-32)*5/9);
+ double actualTempValInFUsingC = Math.floor((celsiusTempVal * 9/5 )+ 32 );
+
+ Assert.assertEquals(actualTempValInCUsingF,celsiusTempVal,"The conversion is incorrect");
+ Assert.assertEquals(actualTempValInFUsingC,fahrenheitTempVal,"The conversion is incorrect");
+
+ MyDriver.quitWindow();
+ }
+
+
+ @Test
+ public void verifyCurrentDateIsPresent(){
+
+ MyDriver.launchUrlOnNewWindow("https://www.facebook.com/");
+
+ By createButtonLocator = By.xpath("//a[contains(.,'Create new account')]");
+ WebElement createButtonElement = MyDriver.getDriver().findElement(createButtonLocator);
+ createButtonElement.click();
+ Misc.pause(3);
+
+ MyDriver.getDriver().manage().window().maximize();
+
+ SimpleDateFormat sdFormatMonth = new SimpleDateFormat("MMM");
+ Date now = new Date();
+ String month = sdFormatMonth.format(now);
+
+ By monthLocator = By.xpath("//select[@id='month']//option[@selected='1']");
+ WebElement monthLocatorElement = MyDriver.getDriver().findElement(monthLocator);
+ String monthTextValue = monthLocatorElement.getText();
+
+ Assert.assertEquals(month,monthTextValue,"Current month is not present");
+
+ SimpleDateFormat sdFormatDay = new SimpleDateFormat("d");
+ String day = sdFormatDay.format(now);
+
+ By dayLocator = By.xpath("//select[@id='day']//option[@selected='1']");
+ WebElement dayLocatorElement = MyDriver.getDriver().findElement(dayLocator);
+ String dayTextValue = dayLocatorElement.getText();
+
+ Assert.assertEquals(day,dayTextValue,"Current day is not present");
+
+ SimpleDateFormat sdFormatYear = new SimpleDateFormat("yyyy");
+ String year= sdFormatYear.format(now);
+
+ By yearLocator = By.xpath("//select[@id='year']//option[@selected='1']");
+ WebElement yearLocatorElement = MyDriver.getDriver().findElement(yearLocator);
+ String yearTextValue = yearLocatorElement.getText();
+
+ Assert.assertEquals(year,yearTextValue,"Current year is not present");
+
+ MyDriver.quitWindow();
+ }
+
+ @Test
+ public void verifyEconomyChurchChairs(){
+
+ MyDriver.launchUrlOnNewWindow("https://www.classroomessentialsonline.com/");
+
+ By churchChairLocator = By.xpath("(//a[contains(text(),'Church Chairs')])[1]");
+ WebElement churchChairElement = MyDriver.getDriver().findElement(churchChairLocator);
+
+ Actions dropDown = new Actions(MyDriver.getDriver());
+ dropDown.moveToElement(churchChairElement).build().perform();
+ Misc.pause(1);
+
+ WebElement economicChairElement = MyDriver.getDriver().
+ findElement(By.xpath("(//a[contains(text(),'Economy Church Chairs')])[1]"));
+
+ economicChairElement.click();
+ Misc.pause(2);
+
+ MyDriver.getDriver().manage().window().maximize();
+
+
+ WebElement economicChairTextElement = MyDriver.getDriver().
+ findElement(By.xpath("//h1[@class='page-heading']"));
+
+ boolean isItDisplayed = economicChairTextElement.isDisplayed();
+ Assert.assertTrue(isItDisplayed,"It is not displayed");
+
+ String text= economicChairTextElement.getText();
+ Assert.assertEquals(text,"ECONOMY CHURCH CHAIRS","Wrong title is present");
+
+ MyDriver.quitWindow();
+
+
+ }
+}
diff --git a/src/test/java/Class6/PageObjectModel.java b/src/test/java/Class6/PageObjectModel.java
new file mode 100644
index 0000000..270a674
--- /dev/null
+++ b/src/test/java/Class6/PageObjectModel.java
@@ -0,0 +1,4 @@
+package Class6;
+
+public class PageObjectModel {
+}
diff --git a/src/test/java/Helper/Misc.java b/src/test/java/Helper/Misc.java
new file mode 100644
index 0000000..395d090
--- /dev/null
+++ b/src/test/java/Helper/Misc.java
@@ -0,0 +1,13 @@
+package Helper;
+
+public class Misc {
+
+ public static void pause(int seconds) {
+ try {
+ Thread.sleep(seconds*1000);
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
+
+}
diff --git a/src/test/java/Pages/Commands.java b/src/test/java/Pages/Commands.java
new file mode 100644
index 0000000..8fdad19
--- /dev/null
+++ b/src/test/java/Pages/Commands.java
@@ -0,0 +1,200 @@
+package Pages;
+
+import Helper.Misc;
+import Web.MyDriver;
+import com.google.common.base.Function;
+import org.openqa.selenium.*;
+import org.openqa.selenium.support.ui.*;
+
+import java.time.Duration;
+import java.util.List;
+import java.util.Set;
+
+public class Commands {
+ Alert myAlert;
+
+
+
+ // Create a local method to find WebElement
+ public WebElement findWebElement(By locator) {
+ return MyDriver.getDriver().findElement(locator);
+ }
+
+ // Create a local method to find WebElement
+ public WebElement findWebElementWithWait(By locator) {
+ Wait fWait = new FluentWait(MyDriver.getDriver())
+ .withTimeout(Duration.ofSeconds(30))
+ .pollingEvery(Duration.ofSeconds(1))
+ .ignoring(NoAlertPresentException.class)
+ .ignoring(StaleElementReferenceException.class)
+ .ignoring(ElementClickInterceptedException.class)
+ .withMessage("Fluent wait timeout, waited for 30-seconds");
+
+ WebElement element = (WebElement) fWait.until(new Function