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. + * + * + * + * + * + * + * + * + * -> starting of tag1 (Note: tag-names CANNOT have spaces) + * + * -> closing of tag1 + * + * eg: html, head, body, script, div, form, input, span + */ + /** + * Tags, attributes and attribute's-value + * + * + * attr1, attr2, attr3, attr4 --> attributes of tag1 + * (Note: attribute-names CANNOT have spaces) + * (Note: attribute may or mayNOT have a value) + * + * attr1 has value = val1 + * attr2 has value = null + * attr3 has value = val11 + * attr4 has value = val111 + * + * eg: + * + * type, autocomplete, name, value are attributes of input-tag + * + * + * + * Test Value + * "Test Value" is the text of tag1 + * + * + * --> button tag has text value = "Log In" + * + * + * + * --> img-tag has No text value + * + * + * + * text value + * + * + * text value again + * + * text data + * + * + * + * text with tag1 = text data + * text with tag2 = text value + * text with tag3 = text value again + * + */ + /** + * Verify button text on login button is Log In + * 1. Open browser + * 2. Launch facebook.com + * 3. Verify the text of login button is "Log In" + * 4. Close the browser + * + * Verify the text of login button is "Log In" + * String expectedText = "Log In" + * String actualText = get the Text of button-tag + * Assert.assertEquals(actualText, expectedText, ""); + * + * + * + * Verify text on login email pr phone number field is "Email or phone number" + * 1. Open browser + * 2. Launch facebook.com + * 3. Verify text on login email pr phone number field is "Email or phone number" + * 4. Close the browser + * + * Verify text on login email pr phone number field is "Email or phone number" + * String expectedText = "Email or phone number" + * String actualText = get the value of placeholder-attribute + * Assert.assertEquals(actualText, expectedText, ""); + * + */ + + /** + * + * + * Not Unique Text + * Unique Text + * + * Unique Text + * Unique Text + * + * + * Unique Text + * + * + * + * + * + * + * + * children of tag1 --> tag2, tag4, tag6 (therefore, tag2, tag4, tag6 are siblings) + * children of tag3 --> subTag + * + * sibling of a-tag --> None + * sibling of tag11 --> tag3 and tag21 + * + * following-sibling (sibling-tags which appearing in the dom after the tag) + * following-sibling of tag11 --> tag21 + * following-sibling of tag3 --> tag11, tag21 + * + * preceding-sibling (sibling-tags appearing in the dom before the tag) + * preceding-sibling of tag11 --> tag3 + * preceding-sibling of tag3 --> 0 + * + * following (tags in the dom appearing after the tag) + * following of tag3 --> subTag, tag11, tag21, tag4, a, tag6, tag7 + * following of tag6 --> tag7 + * + * preceding (tags in the dom appearing before the tag) + * preceding of tag3 --> tag2, tag1 + * preceding of tag6 --> a, tag4, tag21, tag11, subTag, tag3, tag2, tag1 + * preceding of tag11 --> subTag, tag3, tag2, tag1 + * + * descendant (tags in the family chain appearing in the dom after the tag) + * descendant of tag3 --> subTag + * descendant of tag2 --> tag3, subTag, tag11, tag21 + * descendant of a --> 0 + * + * ancestor (tags in the family chain appearing in the dom after the tag) + * ancestor of tag6 --> tag1 + * ancestor of tag11 --> tag2, tag1 + * + * + * + * + * Not Unique Text + * Unique Text + * + * Unique Text + * Unique Text + * + * + * Unique Text + * + * + * + * + * + * + * what is the text of tag3? -> Not Unique Text + * how many attributes with tag3? -> 0 + * + * + * + * text value + * + * + * text value again + * + * text data + * + * + * + * what is the value of attribute(attr13) with tag1 -> null + */ +} diff --git a/src/test/java/Class4/Class4.java b/src/test/java/Class4/Class4.java new file mode 100644 index 0000000..106e984 --- /dev/null +++ b/src/test/java/Class4/Class4.java @@ -0,0 +1,4 @@ +package Class4; + +public class Class4 { +} diff --git a/src/test/java/Class4/Homework2.java b/src/test/java/Class4/Homework2.java new file mode 100644 index 0000000..207308a --- /dev/null +++ b/src/test/java/Class4/Homework2.java @@ -0,0 +1,235 @@ +package Class4; + +import Helper.Misc; +import Web.MyDriver; +import org.openqa.selenium.By; +import org.openqa.selenium.WebDriver; +import org.openqa.selenium.WebElement; +import org.testng.Assert; +import org.testng.annotations.AfterMethod; +import org.testng.annotations.AfterSuite; +import org.testng.annotations.Test; + +import java.awt.*; + +public class Homework2 { + + // Due date: Apr-28 + + /** + * Testcase-1: + *

+ *

+ * 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() { + public WebElement apply(WebDriver driver) { + return driver.findElement(locator); + } + }); + return element; + } + + // Create a local method to find WebElements + public List findWebElements(By locator) { + return MyDriver.getDriver().findElements(locator); + } + + // Create a local method to type in the webElement + public void type(By locator, String data) { + findWebElement(locator).sendKeys(data); + } + + public String getTextOfWebElement(By locator) { + return findWebElement(locator).getText(); + } + + public String getAttributeValueFromWebElement(By locator, String attribute) { + return findWebElement(locator).getText(); + } + + // Create a local method to click on the webElement + public void clickIt(By locator) { + findWebElement(locator).click(); + } + + // Create a local method to clear input from a webElement + public void clearField(By locator) { + findWebElement(locator).clear(); + } + + + // Create a local method to click on the webElement after scroll + public void clickItWithScroll(By locator) { + scrollToElement(locator).click(); + } + + // Create a local method to find if element is enabled + public boolean isElementEnabled(By locator) { + return findWebElement(locator).isEnabled(); + } + + // Create a local method to select a value from a dropdown + public void selectInDropdown(By locator, String dataToSelect) { + WebElement ddElement = findWebElement(locator); + Select dropdown = new Select(ddElement); + dropdown.selectByVisibleText(dataToSelect); + } + + + // Create a local method to find if element is displayed + public boolean isElementDisplayed(By locator) { + return findWebElement(locator).isDisplayed(); + } + + // Create custom method to scroll + public WebElement scrollToElement(By locator) { + WebElement element = null; + for (int i=0 ; i <= 15 ; i++) { + try { + element = findWebElement(locator); + break; + } catch (ElementClickInterceptedException | NoSuchElementException e) { + //scroll by 100 + JavascriptExecutor js = (JavascriptExecutor) MyDriver.getDriver(); + js.executeScript("scrollBy(0,100)"); + } + } + return element; + } + + // custom methods to switch to a window + public void switchToWindow(String newHandle) { + MyDriver.getDriver().switchTo().window(newHandle); + } + + // custom method to get current window-handle + public String getCurrentWindowHandle() { + return MyDriver.getDriver().getWindowHandle(); + } + + // custom method to get all window-handles + public Set getAllWindowHandles() { + return MyDriver.getDriver().getWindowHandles(); + } + + // custom method to select date from Calendar + public void selectDateInCalendar(By locator, String userDate) { + List allDates = MyDriver.getDriver().findElements(locator); + for (WebElement dateElement : allDates) { + String dateValue = dateElement.getAttribute("data-day"); + if (dateValue.equals(userDate)) { + dateElement.click(); + break; + } + } + } + + public void selectFromSuggestions(By locator, String userSuggestion) { + List allSuggestions = MyDriver.getDriver().findElements(locator); + for (WebElement suggestion : allSuggestions) { + if(suggestion.getText().equalsIgnoreCase(userSuggestion)) { + suggestion.click(); + break; + } + } + } + + public void switchToAlert() { + WebDriverWait eWait = new WebDriverWait(MyDriver.getDriver(), 20); + eWait.until(ExpectedConditions.alertIsPresent()); + myAlert = MyDriver.getDriver().switchTo().alert(); + } + + public void clickPositiveActionBtnOnAlert() { + if(myAlert == null) { + switchToAlert(); + } + myAlert.accept(); + } + + public void clickNegativeActionBtnOnAlert() { + if(myAlert == null) { + switchToAlert(); + } + myAlert.dismiss(); + } + + public String getTextFromAlert() { + if(myAlert == null) { + switchToAlert(); + } + return myAlert.getText(); + } + + public void typeInAlert(String data) { + if(myAlert == null) { + switchToAlert(); + } + myAlert.sendKeys(data); + } + + // Custom method/function to switch on Frame using iframe-id + public void switchToFrame (String frameId) { + MyDriver.getDriver().switchTo().frame(frameId); + } + + // Custom method/function to switch on Frame using iframe-element + public void switchToFrame (By locator) { + WebElement myFrame = findWebElement(locator); + MyDriver.getDriver().switchTo().frame(myFrame); + } + + // Custom method/function to switch on Frame using iframe-index + public void switchToFrame (int frameIndex) { + MyDriver.getDriver().switchTo().frame(frameIndex); + } + + public void switchToMainWindowFromFrame () { + MyDriver.getDriver().switchTo().defaultContent(); + } + +} diff --git a/src/test/java/Pages/Darksky/LandingPage.java b/src/test/java/Pages/Darksky/LandingPage.java new file mode 100644 index 0000000..e9c6e4f --- /dev/null +++ b/src/test/java/Pages/Darksky/LandingPage.java @@ -0,0 +1,65 @@ +package Pages.Darksky; + +import Pages.Commands; +import org.openqa.selenium.By; +import org.openqa.selenium.WebElement; + +public class LandingPage extends Commands { + + // Locators of Landing Page elements + By timeMachineLocator = By.xpath("//a[text()='Time Machine' or text()='TIME MACHINE']"); + By searchInputLocator = By.xpath("//form[@id='searchForm']//input"); + By searchBtnLocator = By.xpath("//form[@id='searchForm']//a[@class='searchButton']"); + String weatherAttributeValue_starts = "//div[@class='"; + String weatherAttributeValue_ends = "']//span[contains(@class, '__value')]"; + + By currentForecastLocator = By.xpath("//span[@class='summary swap']"); + + + + // Method to interact with Landing Page elements + // method to scroll and find if Time Machine button is enabled + + + public void enterSearchLocation(String location) { + clearField(searchInputLocator); + type(searchInputLocator, location); + } + + public void clickSearchButton() { + clickIt(searchBtnLocator); + } + + // method to scroll to Time Machine button + public WebElement scrollToTimeMachineButton() { + return scrollToElement(timeMachineLocator); + } + + // method to check if Time Machine button is enabled + public boolean isTimeMachineButtonEnabled() { + return scrollToTimeMachineButton().isEnabled(); + } + + public String getWeatherAttributeValue(String attribute) { + String xpathValue = weatherAttributeValue_starts + attribute.toLowerCase() + weatherAttributeValue_ends; + return getTextOfWebElement(By.xpath(xpathValue)); + } + + public String getForecast() { + return getTextOfWebElement(currentForecastLocator); + } + + public boolean isForecastDisplayed() { + return isElementDisplayed(currentForecastLocator); + } + + + // method to check if Time Machine button is displayed + + + // method to click Time Machine button + + + + +} diff --git a/src/test/java/Pages/Facebook/LandingPage.java b/src/test/java/Pages/Facebook/LandingPage.java new file mode 100644 index 0000000..9935799 --- /dev/null +++ b/src/test/java/Pages/Facebook/LandingPage.java @@ -0,0 +1,46 @@ +package Pages.Facebook; + + +import Pages.Commands; +import Web.MyDriver; +import org.openqa.selenium.By; + +public class LandingPage extends Commands { + + // Variables (Locators) + By loginEmailLocator = By.id("email"); + By loginPassLocator = By.id("pass"); + By loginButtonLocator = By.tagName("button"); + By createNewAccountBtnLocator = By.xpath("//a[@data-testid='open-registration-form-button']"); + + + // Methods (to interact with webElements present on this webpage) + public void enterLoginEmail(String loginEmail) { + // MyDriver.getDriver().findElement(loginEmailLocator).sendKeys(loginEmail); + type(loginEmailLocator, loginEmail); + } + + public void enterLoginPassword(String loginPwd) { + // MyDriver.getDriver().findElement(loginPassLocator).sendKeys(loginPwd); + type(loginPassLocator, loginPwd); + } + + public void clickLoginButton() { + // MyDriver.getDriver().findElement(loginButtonLocator).click(); + clickIt(loginButtonLocator); + } + + public void clickCreateNewAccountBtn() { + // MyDriver.getDriver().findElement(createNewAccountBtnLocator).click(); + clickIt(createNewAccountBtnLocator); + } + + public boolean isLoginBtnEnabled() { + return MyDriver.getDriver().findElement(loginButtonLocator).isEnabled(); + } + + public boolean isCreateNewAccountBtnEnabled() { + return isElementEnabled(createNewAccountBtnLocator); + } + +} diff --git a/src/test/java/Pages/Facebook/LoginErrorPage.java b/src/test/java/Pages/Facebook/LoginErrorPage.java new file mode 100644 index 0000000..eec9db5 --- /dev/null +++ b/src/test/java/Pages/Facebook/LoginErrorPage.java @@ -0,0 +1,18 @@ +package Pages.Facebook; + +import Pages.Commands; +import org.openqa.selenium.By; + +public class LoginErrorPage extends Commands { + + + By loginErrorLocator = By.xpath("//div[contains(text(),'or mobile number you entered isn')]"); + + + public boolean isLoginErrorDisplayed() { + return isElementDisplayed(loginErrorLocator); + } + + + +} diff --git a/src/test/java/Pages/Facebook/SignUpPage.java b/src/test/java/Pages/Facebook/SignUpPage.java new file mode 100644 index 0000000..16205f0 --- /dev/null +++ b/src/test/java/Pages/Facebook/SignUpPage.java @@ -0,0 +1,39 @@ +package Pages.Facebook; + +import Pages.Commands; +import org.openqa.selenium.By; + +public class SignUpPage extends Commands { + + // Variables (Locators) + By monthDdLocator = By.id("month"); + By yearDdLocator = By.id("year"); + By dayDdLocator = By.id("day"); + + + // Methods (to interact with webElements present on this webpage) + public void selectBirthMonth(String monthName) { + selectInDropdown(monthDdLocator, monthName); + } + + public void selectBirthDay(String day) { + selectInDropdown(dayDdLocator,day); + } + + public void selectBirthYear(String year) { + selectInDropdown(yearDdLocator, year); + } + + public void selectBirthDate(String birthDate) { + String[] birthDateData = birthDate.split(" "); + selectBirthMonth(birthDateData[0]); + selectBirthDay(birthDateData[1]); + selectBirthYear(birthDateData[2]); + } + + + + + + +} diff --git a/src/test/java/Pages/Guru/LandingPage.java b/src/test/java/Pages/Guru/LandingPage.java new file mode 100644 index 0000000..de7dd27 --- /dev/null +++ b/src/test/java/Pages/Guru/LandingPage.java @@ -0,0 +1,32 @@ +package Pages.Guru; + +import Pages.Commands; +import org.openqa.selenium.By; + +public class LandingPage extends Commands { + + By cusIdInputLocator = By.name("cusid"); + By submitBtnLocator = By.name("submit"); + + + + public void enterCustomerId(String cusId) { + type(cusIdInputLocator, cusId); + } + + public void clickSubmitBtn() { + clickIt(submitBtnLocator); + } + + public void clickOkOnAlert() { + clickPositiveActionBtnOnAlert(); + } + + public String getAlertText() { + return getTextFromAlert(); + } + + + + +} diff --git a/src/test/java/Pages/Hotels/FeedbackPage.java b/src/test/java/Pages/Hotels/FeedbackPage.java new file mode 100644 index 0000000..f0f24a9 --- /dev/null +++ b/src/test/java/Pages/Hotels/FeedbackPage.java @@ -0,0 +1,19 @@ +package Pages.Hotels; + +import Helper.Misc; +import Pages.Commands; +import org.openqa.selenium.By; + +public class FeedbackPage extends Commands { + By feedBackLocator = By.xpath("//header/nav[@id='secondaryNav']/div[@id='gc-custom-header-nav-bar-acct-menu']/div[1]/div[2]/a[5]/div[1]"); + By submitButtonLocator = By.xpath("//button[@id='submit-button']"); + + + public void clickSubmitButton (){ + + clickItWithScroll(submitButtonLocator);} + public void clickFeedbackLink (){clickIt(feedBackLocator); Misc.pause(2);} + public void findElementForNewW (){ + findWebElementWithWait(submitButtonLocator).click(); + } +} diff --git a/src/test/java/Pages/Hotels/LandingPage.java b/src/test/java/Pages/Hotels/LandingPage.java new file mode 100644 index 0000000..d87804c --- /dev/null +++ b/src/test/java/Pages/Hotels/LandingPage.java @@ -0,0 +1,123 @@ +package Pages.Hotels; + +import Helper.Misc; +import Pages.Commands; +import org.openqa.selenium.By; +import org.openqa.selenium.WebElement; + +import java.util.List; + +public class LandingPage extends Commands { + + // + By checkInDateBoxLocator = By.id("d1-btn"); + By checkInDisabledDatesLocator = By.xpath("//table[@class='uitk-date-picker-weeks']//button[@disabled]"); + + + By june2022DatesLocator = By.xpath("//h2[text()='June 2022']/following-sibling::table//button[@data-day]"); + /* + + monthYear = August 2022 + "//h2[text()='" + monthYear + "']/following-sibling::table//button[@data-day]" + monthDates_1 + monthYear + monthDates_2 + */ + String monthDates_1 = "//h2[text()='"; + String monthDates_2 = "']/following-sibling::table//button[@data-day]"; + + By calendarHeading = By.xpath("(//div[@data-stid='date-picker-month'])[1]//h2"); + By nextMonthArrow = By.xpath("(//button[@data-stid='date-picker-paging'])[2]"); + By signInLinkLocator = By.xpath("//button[contains(text(),'Sign in')]"); + By signUpLinkLocator = By.xpath("//a[contains(text(),'Sign up, it’s free')]"); + By doneButtonOnCalendarLocator = By.xpath("//button[contains(text(),'Done')and@data-stid]"); + By searchBarLocator = By.xpath("//button[@data-testid='submit-button']"); + By travelersButtonLocator = By.xpath("//button[contains(text(),'1 room, 2 travelers')]"); + By signInButtonLocator = By.xpath("//a[contains(text(),'Sign in')]"); + By backButtonInCCLocator = By.xpath("(//button[@data-stid='date-picker-paging'])[1]"); + By disabledDatesInCCLocator = By.xpath("//table[@class='uitk-date-picker-weeks']//button[@disabled]"); + By backButtonInCOCLocator = By.xpath(""); + By disabledDatesInCOCLocator = By.xpath(""); + By checkInBoxLocator = By.xpath("//button[@id='d1-btn']"); + + + + By destinationInputBoxLocator = By.xpath("//button[@aria-label='Going to']"); + By destinationInputLocator = By.id("location-field-destination"); + By destinationSuggestions = By.xpath("//div[@class='uitk-typeahead-results']//div[contains(@class,'truncat') and not(contains(@class,'uitk'))]"); + By boraBoraFromSuggestionLocator = By.xpath("//body/div[@id='app-blossom-flex-ui']/div[@id='app-layer-manager']/div[@id='app-layer-base']/div[1]/div[2]/div[1]/div[1]/div[1]/div[1]/div[1]/div[1]/form[1]/div[1]/div[1]/div[1]/div[1]/div[1]/div[1]/div[1]/div[1]/div[2]/div[2]/ul[1]/li[1]/button[1]/div[1]/div[2]"); + By checkOutButtonLocator = By.xpath("//button[@id='d2-btn']"); + + + + + + public void clickSignInButton (){clickIt(signInButtonLocator); + Misc.pause(2);} + public void clickTravelersButton (){clickIt(travelersButtonLocator);} + public void clickCheckInBox() {clickIt(checkInBoxLocator); + Misc.pause(2);} + public void clickSearchButton(){clickIt(searchBarLocator); + Misc.pause(2);} + public void clickSignInLink (){clickIt(signInLinkLocator); + Misc.pause(2);} + public void clickSignUpLink (){clickIt(signUpLinkLocator);} + public void clickBoraBora (){clickIt(boraBoraFromSuggestionLocator);} + + public void clickCheckOutButton (){clickIt(checkOutButtonLocator); + Misc.pause(2);} + public boolean isBackButtonDisabled() { + return isElementDisplayed(backButtonInCCLocator);} + public boolean arePastDaysDisabled() { + return isElementDisplayed(disabledDatesInCCLocator); + } + + + public void clickDoneButtonOnCalendar (){clickIt(doneButtonOnCalendarLocator);} + + + public List getAllDisabledDates() { + return findWebElements(checkInDisabledDatesLocator); + } + + public void selectDateInJune2022(String dateToSelect) { + selectDateInCalendar(june2022DatesLocator, dateToSelect); + } + + public void enterDestination(String destination) { + clickIt(destinationInputBoxLocator); + type(destinationInputLocator, destination); + Misc.pause(3); + } + + + + public void selectFromDestinationSuggestion(String userChoice) { + selectFromSuggestions(destinationSuggestions, userChoice); + } + + public void goToMonth(String monthYear) { + for (int i=0 ; i<12 ; i++) { + if (getTextOfWebElement(calendarHeading).equalsIgnoreCase(monthYear)) { + break; + } + clickIt(nextMonthArrow); + } + } + + public void selectDateFromAnyMonth(String monthYear, String dateValue) { + goToMonth(monthYear); + By allDatesLocator = By.xpath(monthDates_1 + monthYear + monthDates_2); + selectDateInCalendar(allDatesLocator, dateValue); + } + + + public void selectDateFromAnyMonth(String dateMonthYear) { + String[] dateValues = dateMonthYear.split(" "); + goToMonth(dateValues[1] + " " + dateValues[2]); + By allDatesLocator = By.xpath(monthDates_1 + dateValues[1] + " " + dateValues[2] + monthDates_2); + selectDateInCalendar(allDatesLocator, dateValues[0]); + Misc.pause(2); + } + + + +} diff --git a/src/test/java/Pages/Hotels/SearchPage.java b/src/test/java/Pages/Hotels/SearchPage.java new file mode 100644 index 0000000..792af34 --- /dev/null +++ b/src/test/java/Pages/Hotels/SearchPage.java @@ -0,0 +1,30 @@ +package Pages.Hotels; + +import Pages.Commands; +import org.openqa.selenium.By; + +public class SearchPage extends Commands { + + By tellUsHowWeCanImproveTxtLocator = By.xpath("//span[contains(text(),'Tell us how we can improve our site')]"); + By shareFeedbackButtonLocator = By.xpath("//a[contains(text(),'Share feedback')]"); + + public boolean isTellUsHowWeCanImproveEnabled (){ + return + isElementDisplayed(tellUsHowWeCanImproveTxtLocator); + } + + public boolean isShareFeedbackButtonEnabled (){ + return + isElementDisplayed(shareFeedbackButtonLocator); + } + + + + + + + + + + +} diff --git a/src/test/java/Pages/Hotels/SignInPage.java b/src/test/java/Pages/Hotels/SignInPage.java new file mode 100644 index 0000000..ea29702 --- /dev/null +++ b/src/test/java/Pages/Hotels/SignInPage.java @@ -0,0 +1,43 @@ +package Pages.Hotels; + +import Helper.Misc; +import Pages.Commands; +import io.cucumber.java.en.And; +import org.openqa.selenium.By; + +public class SignInPage extends Commands { + + + + + By emailBoxLocator = By.xpath(" //input[@id='loginFormEmailInput']"); + By passwordLocator = By.xpath("//input[@id='loginFormPasswordInput']"); + By signInButtonLocator = By.xpath("//button[@id='loginFormSubmitButton']"); + By errorMessageLocator = By.xpath("//h3[contains(text(),'Email and password')]"); + + + + + + + + + + + public void typeEmailAddress (String emailAddress){ + type(emailBoxLocator , emailAddress);} + + public void typePassword (String password){ + type(passwordLocator, password);} + + public void clickSignIndBTonSInP (){ + clickIt(signInButtonLocator); + Misc.pause(8); + } + + public boolean isErrorMessageDisplayed (){ + return + isElementDisplayed(errorMessageLocator); + } + +} diff --git a/src/test/java/Pages/Hotels/SignUpPage.java b/src/test/java/Pages/Hotels/SignUpPage.java new file mode 100644 index 0000000..9ee8326 --- /dev/null +++ b/src/test/java/Pages/Hotels/SignUpPage.java @@ -0,0 +1,69 @@ +package Pages.Hotels; + +import Helper.Misc; +import Pages.Commands; +import Web.MyDriver; +import org.openqa.selenium.By; + +import java.util.Set; + +public class SignUpPage extends Commands { + + By termsAndConditionsLinkLocator = By.xpath("//a[contains(text(),'Terms and Conditions')]"); + By privacyStatementsLinkLocator = By.xpath("//a[contains(text(),'Privacy Statement')]"); + + + + + public void clickTermsAndConditionsLink (){clickIt(termsAndConditionsLinkLocator);} + + public void clickPrivacyStatementsLink (){clickIt(privacyStatementsLinkLocator);} + + public String verifyTCPInNewT() { + + String currentWindowHandle = MyDriver.getDriver().getWindowHandle(); + Set allWindows = MyDriver.getDriver().getWindowHandles(); + String currentTitle = null; + for (String window : allWindows) { + if (!currentWindowHandle.equalsIgnoreCase(window)) { + MyDriver.getDriver().switchTo().window(window); + currentTitle = MyDriver.getDriver().getTitle(); + Misc.pause(2); + MyDriver.getDriver().close(); + MyDriver.getDriver().switchTo().window(currentWindowHandle); + } + } + return currentTitle; + } + + public String verifyPrivacyStatementInNewTab () { + + String currentWindowHandle = MyDriver.getDriver().getWindowHandle(); + Set allWindow = MyDriver.getDriver().getWindowHandles(); + String Title = null; + for (String windows : allWindow) { + if (!currentWindowHandle.equalsIgnoreCase(windows)) { + MyDriver.getDriver().switchTo().window(windows); + Title = MyDriver.getDriver().findElement(privacyStatementsLinkLocator).getText(); + Misc.pause(2); + MyDriver.getDriver().close(); + MyDriver.getDriver().switchTo().window(currentWindowHandle); + } + } + return Title; + } + + + + + + + + + + + + + + +} diff --git a/src/test/java/StepDefinition/CommonSD.java b/src/test/java/StepDefinition/CommonSD.java new file mode 100644 index 0000000..196698b --- /dev/null +++ b/src/test/java/StepDefinition/CommonSD.java @@ -0,0 +1,34 @@ +package StepDefinition; + +import Web.MyDriver; +import io.cucumber.java.en.Given; + +public class CommonSD { + + @Given("^I am on (facebook|darksky|hotels|Guru) landing page$") + public void openWebPage(String webPageName) { + switch (webPageName.toLowerCase()) { + case "facebook": + MyDriver.launchUrlOnNewWindow("https://www.facebook.com/"); + break; + case "darksky": + MyDriver.launchUrlOnNewWindow("https://www.darksky.net/"); + break; + case "hotels": + MyDriver.launchUrlOnNewWindow("https://www.hotels.com/"); + break; + case "guru": + MyDriver.launchUrlOnNewWindow("https://demo.guru99.com/test/delete_customer.php/delete_customer.php/"); + default: + System.out.println("Invalid webpage name"); + } + /* + I am on facebook landing page + + I am on darksky landing page + + I am on hotels landing page + */ + + } +} diff --git a/src/test/java/StepDefinition/Darksky/SearchSD.java b/src/test/java/StepDefinition/Darksky/SearchSD.java new file mode 100644 index 0000000..e10327e --- /dev/null +++ b/src/test/java/StepDefinition/Darksky/SearchSD.java @@ -0,0 +1,36 @@ +//package StepDefinition.Darksky; +// +//import Pages.Darksky.LandingPage; +//import Web.MyDriver; +//import cucumber.api.java.en.Given; +//import cucumber.api.java.en.Then; +//import cucumber.api.java.en.When; +//import io.cucumber.java.en.Then; +//import io.cucumber.java.en.When; +//import org.testng.Assert; +// +//public class SearchSD { +// LandingPage lpage = new LandingPage(); +// +//// @Given("I am on darksky landing page") +//// public void openDarksky() { +//// MyDriver.launchUrlOnNewWindow("https://www.darksky.net/"); +//// } +// +// +// @When("I search temperature using (.+)") +// public void searchTempFor(String searchFor) { +// lpage.enterSearchLocation(searchFor); +// lpage.clickSearchButton(); +// } +// +// +// @Then("I verify forecast is displayed for (.+)") +// public void isForecastDisplayed(String searchedFor) { +// Assert.assertTrue(lpage.isForecastDisplayed(), "Forecast is not displayed for " + searchedFor); +// } +// +// +// +// +//} diff --git a/src/test/java/StepDefinition/Facebook/LoginSD.java b/src/test/java/StepDefinition/Facebook/LoginSD.java new file mode 100644 index 0000000..ce8313b --- /dev/null +++ b/src/test/java/StepDefinition/Facebook/LoginSD.java @@ -0,0 +1,90 @@ +//package StepDefinition.Facebook; +// +//import Pages.Facebook.LandingPage; +//import Pages.Facebook.LoginErrorPage; +//import Web.MyDriver; +//import cucumber.api.java.en.Given; +//import cucumber.api.java.en.Then; +//import cucumber.api.java.en.When; +//import org.testng.Assert; +// +//public class LoginSD { +// LandingPage lpage = new LandingPage(); +// LoginErrorPage lePage = new LoginErrorPage(); +// +// +//// // Glue code +//// @Given("^I am on facebook landing page$") +//// public void openFacebook() { +//// MyDriver.launchUrlOnNewWindow("https://www.facebook.com/"); +//// } +// +//// @Given("^I am on (facebook|darksky|hotels) landing page$") +//// public void openWebPage(String webPageName) { +//// switch (webPageName) { +//// case "facebook": +//// MyDriver.launchUrlOnNewWindow("https://www.facebook.com/"); +//// break; +//// case "darksky": +//// MyDriver.launchUrlOnNewWindow("https://www.darksky.net/"); +//// break; +//// case "hotels": +//// MyDriver.launchUrlOnNewWindow("https://www.hotels.com/"); +//// break; +//// default: +//// System.out.println("Invalid webpage name"); +//// } +// /* +// I am on facebook landing page +// +// I am on darksky landing page +// +// I am on hotels landing page +// */ +// +// } +// +// @When("^I click on login button$") +// public void clickLoginBtn() { +// lpage.clickLoginButton(); +// } +// +//// @Given("^I enter (.+) in login username$") +//// public void enterLoginUsername(String username) { +//// lpage.enterLoginEmail(username); +//// } +//// +//// @Given("^I enter (.+) in login password$") +//// public void enterLoginPwd(String pwd) { +//// lpage.enterLoginPassword(pwd); +//// } +// +// +// /* +// pattern starts with I +// enter ANYTHING in login patternEnds +// */ +// @Given("^I enter (.+) in login (password|username)$") +// public void enterLoginCredentials(String data, String field) { +// switch (field.toLowerCase()) { +// case "username": +// lpage.enterLoginEmail(data); +// break; +// case "password": +// lpage.enterLoginPassword(data); +// break; +// default: +// System.out.println("Incorrect field name -> " + field); +// } +// } +// +// @Then("^I [vV]erify error is displayed$") +// public void isLoginErrorDisplayed() { +// Assert.assertTrue(lePage.isLoginErrorDisplayed(), "Login error is not displayed"); +// } +// +// +// +// +// +//} diff --git a/src/test/java/StepDefinition/Facebook/SignUpSD.java b/src/test/java/StepDefinition/Facebook/SignUpSD.java new file mode 100644 index 0000000..7ad76ff --- /dev/null +++ b/src/test/java/StepDefinition/Facebook/SignUpSD.java @@ -0,0 +1,6 @@ +package StepDefinition.Facebook; + +public class SignUpSD { + + +} diff --git a/src/test/java/StepDefinition/Hotels/TC_17_VerifyPastDateAndBackButtonOnCurrentMonths.java b/src/test/java/StepDefinition/Hotels/TC_17_VerifyPastDateAndBackButtonOnCurrentMonths.java new file mode 100644 index 0000000..9f9869b --- /dev/null +++ b/src/test/java/StepDefinition/Hotels/TC_17_VerifyPastDateAndBackButtonOnCurrentMonths.java @@ -0,0 +1,48 @@ +package StepDefinition.Hotels; + +import Pages.Hotels.LandingPage; +import io.cucumber.java.en.Then; +import org.testng.Assert; + +public class TC_17_VerifyPastDateAndBackButtonOnCurrentMonths { + + + LandingPage lPage = new LandingPage(); + + /** + * + * TC-17 + * + * Launch [Hotels.com](http://Hotels.com) + * Click on Checkin Calendar + * Go to current month if not displayed + * Verify For current month + * 1) Past dates (if any) are disabled. + * 2) Back button on current month is disabled + * Click on Done button on calendar + * Click on Checkout Calendar + * Go to current month if not displayed + * Verify For current month + * 1) Past dates (if any) are disabled. + * 2) Back button on current month is disabled + * + */ + + + @Then("^I verify that current month back button is disabled$") + public void verifyThatBackButtonIsDisabledONCC (){ + Assert.assertTrue(lPage.isBackButtonDisabled(), "Back Button is enabled"); + } + + + @Then("^I verify that past dates are disabled$") + public void doesPastDatesDisabled() { + Assert.assertTrue(lPage.arePastDaysDisabled(), "Past days are displayed"); + } + + + + + + +} diff --git a/src/test/java/StepDefinition/Hotels/TC_18_VerifyUserCanUpdateNumberOfGuestsOnHomePage.java b/src/test/java/StepDefinition/Hotels/TC_18_VerifyUserCanUpdateNumberOfGuestsOnHomePage.java new file mode 100644 index 0000000..aac9098 --- /dev/null +++ b/src/test/java/StepDefinition/Hotels/TC_18_VerifyUserCanUpdateNumberOfGuestsOnHomePage.java @@ -0,0 +1,30 @@ +package StepDefinition.Hotels; + +import Pages.Hotels.LandingPage; +import io.cucumber.java.en.When; + +public class TC_18_VerifyUserCanUpdateNumberOfGuestsOnHomePage { + + + LandingPage lPage = new LandingPage(); + /** + * + * TC-18 + * + *1. Launch [Hotels.com](http://Hotels.com) + * 1. Click on Travelers + * 1. Select “Adults as 6 + * 1. Select “Children” as 2 + * 1. Select first child age: 4 + * 1. Select second child age: Under 1 + * 1. Click Done + * 1. Verify total number of guests in sum of adults and children as same as selected on step #3 and #4. + * + */ + + @When("^I click travelers button$") + public void clickOnTravelers (){lPage.clickTravelersButton();} + + + +} diff --git a/src/test/java/StepDefinition/Hotels/TC_19_VerifyShareFeedbackSD.java b/src/test/java/StepDefinition/Hotels/TC_19_VerifyShareFeedbackSD.java new file mode 100644 index 0000000..86bf3af --- /dev/null +++ b/src/test/java/StepDefinition/Hotels/TC_19_VerifyShareFeedbackSD.java @@ -0,0 +1,86 @@ +package StepDefinition.Hotels; + +import Pages.Hotels.LandingPage; +import Pages.Hotels.SearchPage; +import io.cucumber.java.en.And; +import io.cucumber.java.en.Then; +import io.cucumber.java.en.When; +import org.testng.Assert; + +public class TC_19_VerifyShareFeedbackSD { + + LandingPage lPage = new LandingPage(); + SearchPage searchP = new SearchPage(); + + /** + * TC-19 + * Hotels: Verify Share feedback button is displayed at the end of search results + * Launch [Hotels.com](http://Hotels.com) + * Enter “bora” in destination + * Select “Bora Bora, Leeward Islands, French Polynesia” from auto suggestion + * Select August 1, 2022 as Check-in + * Select August 10, 2022 as Check-out + * Click Apply + * Click on “Search”button + * Verify at the end of search results: + * Text: Tell us how we can improve our site is displayed + * Button [Share feedback] is displayed and enabled + */ + + + + @When("I enter bora in destination") + public void Enter_In_Destination (){ + lPage.enterDestination("bora");; + } + @When("I select Bora Bora from suggestion") + public void clickBoraBoraDestination (){ + lPage.selectFromDestinationSuggestion("Bora Bora"); + } + + @When("I click check in button") + public void clickCheckInButton (){ + lPage.clickCheckInBox(); + } + + @When("^I select (.+) as Check-in$") + public void selectCheckInDate (String Date){ + lPage.selectDateFromAnyMonth(Date); + } + + @And("I click done button in calendar") + public void clickDoneButtonInCalendar (){ + lPage.clickDoneButtonOnCalendar(); + } + + @And("I click check out button") + public void clickCheckOutButton (){ + lPage.clickCheckOutButton(); + } + + @And("^I select (.+) as checkout$") + public void selectCheckOutDate (String Data){ + lPage.selectDateFromAnyMonth(Data); + } + + @When("I click on search button") + public void clickOnSearchButton (){ + lPage.clickSearchButton(); + } + + @Then("^I verify that the message tell us how we can improve is displayed$") + public void verifyIsTellUsHowWeCanImproveEnabled (){ + Assert.assertTrue(searchP.isTellUsHowWeCanImproveEnabled()); + } + + @Then("^I verify that share button is enabled") + public void verifyIfShareButtonIsDisplayed (){ + Assert.assertTrue(searchP.isShareFeedbackButtonEnabled()); + } + + + + + + +} diff --git a/src/test/java/StepDefinition/Hotels/TC_20_VerifyTCLinkAndPSLinkSD.java b/src/test/java/StepDefinition/Hotels/TC_20_VerifyTCLinkAndPSLinkSD.java new file mode 100644 index 0000000..0bec049 --- /dev/null +++ b/src/test/java/StepDefinition/Hotels/TC_20_VerifyTCLinkAndPSLinkSD.java @@ -0,0 +1,78 @@ +package StepDefinition.Hotels; + +import Helper.Misc; +import Pages.Commands; +import Pages.Hotels.LandingPage; +import Pages.Hotels.SignUpPage; +import Web.MyDriver; +import io.cucumber.java.en.And; +import io.cucumber.java.en.Given; +import io.cucumber.java.en.Then; +import io.cucumber.java.en.When; +import org.testng.Assert; + +public class TC_20_VerifyTCLinkAndPSLinkSD { + + LandingPage lPage = new LandingPage(); + SignUpPage sUpPage = new SignUpPage(); + Commands cPage = new Commands(); + + /** + * + * TC-20 + * + * Hotels: Verify TermsAndConditions link and PrivacyStatements link open correct page on new tab + * Launch [Hotels.com](http://Hotels.com) + * Click Sign in link + * Click Sign up link + * Click “Terms and Conditions” link + * Verify “Terms and Conditions” page opens in new tab + * Click “Privacy Statement” link + * Verify “Privacy Statement” page opens in new tab + */ + + @Given("^I am on Hotels Landing Page$") + public void Hotels_Landing_Page(){ + + MyDriver.launchUrlOnNewWindow("https://www.hotels.com/"); + } + + @When("^I click sign in link$") + public void Click_Sign_In_Link (){ + lPage.clickSignInLink(); + + } + + @When("I click sign up link") + public void Click_Sign_Up_Link (){ + MyDriver.getDriver().manage().window().maximize(); + lPage.clickSignUpLink(); + } + + @And("I click terms and conditions link") + public void Click_Terms_And_Conditions_Link (){ + sUpPage.clickTermsAndConditionsLink(); + } + + @Then("^I verify terms and conditions page opens in new tab$") + public void verifyTCPInNewTab (){ + Assert.assertEquals(sUpPage.verifyTCPInNewT(), + "Hotels.com - Deals & Discounts for Hotel Reservations from Luxury Hotels to Budget Accommodations"); + + } + + + @And("I click privacy statements link") + public void Click_Privacy_Statements_Link (){ + sUpPage.clickPrivacyStatementsLink(); + } + + + @Then("^I verify privacy statement page opens in new tab$") + public void verifyPrivacyStatementInNewTab (){ + Assert.assertEquals(sUpPage.verifyPrivacyStatementInNewTab(), + "Privacy Statement");} + + + +} diff --git a/src/test/java/StepDefinition/Hotels/TC_21_VerifyVerificationMessageForInvalidSignInCredentials.java b/src/test/java/StepDefinition/Hotels/TC_21_VerifyVerificationMessageForInvalidSignInCredentials.java new file mode 100644 index 0000000..37eedbd --- /dev/null +++ b/src/test/java/StepDefinition/Hotels/TC_21_VerifyVerificationMessageForInvalidSignInCredentials.java @@ -0,0 +1,46 @@ +package StepDefinition.Hotels; + +import Pages.Hotels.LandingPage; +import Pages.Hotels.SignInPage; +import io.cucumber.java.en.And; +import io.cucumber.java.en.Then; +import org.testng.Assert; + +public class TC_21_VerifyVerificationMessageForInvalidSignInCredentials { + LandingPage lPage = new LandingPage(); + SignInPage sPage = new SignInPage(); + + + /** + * + * + * Launch [hotels](http://hotels.com) website + * Click on “Sign in” link + * Enter invalid email address + * Enter invalid password + * Click on Sign in button + * Verify Verification message is displayed. + * + */ + + + @And("^I click sign in button$") + public void click_sign_in_button (){lPage.clickSignInButton();} + + @And("^I enter (.+) email address$") + public void typeEmailADdress (String email){sPage.typeEmailAddress(email);} + + @And("^I enter (.+) password$") + public void typePassword (String password){sPage.typePassword(password);} + + @And("^I click on sign in button$") + public void signInButtonInSinP (){sPage.clickSignIndBTonSInP();} + + @Then("^I verify that the message is displayed$") + public void verifyErrorMessageIsEnabled (){ + Assert.assertTrue(sPage.isErrorMessageDisplayed()); + } + + + +} diff --git a/src/test/java/StepDefinition/Hotels/TC_24_VerifyErrorIsDisplayedWhenUserSubmitsTheEmptyFeedbackForm.java b/src/test/java/StepDefinition/Hotels/TC_24_VerifyErrorIsDisplayedWhenUserSubmitsTheEmptyFeedbackForm.java new file mode 100644 index 0000000..185eb36 --- /dev/null +++ b/src/test/java/StepDefinition/Hotels/TC_24_VerifyErrorIsDisplayedWhenUserSubmitsTheEmptyFeedbackForm.java @@ -0,0 +1,34 @@ +package StepDefinition.Hotels; + +import Pages.Hotels.FeedbackPage; +import Pages.Hotels.LandingPage; +import io.cucumber.java.en.And; +import io.cucumber.java.en.When; + +public class TC_24_VerifyErrorIsDisplayedWhenUserSubmitsTheEmptyFeedbackForm { + + LandingPage lPage = new LandingPage(); + FeedbackPage fPage = new FeedbackPage(); + + /** + * + * Launch Hotels + * Select “Sign In” from Help dropdown + * Click on Submit button + * Verify error message is displayed (Please fill in the required information highlighted below.) + * Verify star boxes section is in a red dotted box. + * + */ + + + @When("^I click Feedback link$") + public void clickFeedbackOnSignIn (){fPage.clickFeedbackLink();} + + @And("^I click submit button$") + public void clickSubmitButtn (){ + + fPage.clickSubmitButton();} + + + +} diff --git a/src/test/java/StepDefinition/OthersSD/OthersSD.java b/src/test/java/StepDefinition/OthersSD/OthersSD.java new file mode 100644 index 0000000..7f4f94d --- /dev/null +++ b/src/test/java/StepDefinition/OthersSD/OthersSD.java @@ -0,0 +1,36 @@ +//package StepDefinition.OthersSD; +// +//import Pages.Guru.LandingPage; +//import Web.MyDriver; +//import cucumber.api.java.en.Given; +//import cucumber.api.java.en.Then; +//import cucumber.api.java.en.When; +//import org.testng.Assert; +// +//public class OthersSD { +// LandingPage lPage = new LandingPage(); +// +//// @Given("^I am on Guru landing page$") +//// public void openGugu() { +//// MyDriver.launchUrlOnNewWindow("https://demo.guru99.com/test/delete_customer.php/delete_customer.php/"); +//// } +// +// @When("I enter the customer id as (.+)") +// public void enterCustomerId(String idValue) { +// lPage.enterCustomerId(idValue); +// } +// +// @When("I click on Submit button") +// public void clickSubmit() { +// lPage.clickSubmitBtn(); +// } +// +// @Then("I verify '(.+)' is displayed") +// public void verifyCustomerDeleted(String msg) { +// lPage.clickOkOnAlert(); +// Assert.assertEquals(lPage.getAlertText(), msg, "Error"); +// +// } +// +// +//} diff --git a/src/test/java/Web/MyDriver.java b/src/test/java/Web/MyDriver.java new file mode 100644 index 0000000..ce0defb --- /dev/null +++ b/src/test/java/Web/MyDriver.java @@ -0,0 +1,34 @@ +package Web; + +import org.openqa.selenium.WebDriver; +import org.openqa.selenium.chrome.ChromeDriver; + +public class MyDriver { + + private static WebDriver driver; + + public static void launchUrlOnNewWindow(String url) { + System.setProperty("webdriver.chrome.driver", "./Drivers/chromedriver"); + driver = new ChromeDriver(); + + driver.get(url); + + try { + Thread.sleep(5000); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + + public static void quitWindows() { + driver.quit(); + } + + public static WebDriver getDriver() { + return driver; + } + + + + +} diff --git a/src/test/resources/.DS_Store b/src/test/resources/.DS_Store new file mode 100644 index 0000000..5d17d03 Binary files /dev/null and b/src/test/resources/.DS_Store differ diff --git a/src/test/resources/Darksky/search.feature b/src/test/resources/Darksky/search.feature new file mode 100644 index 0000000..35b2c74 --- /dev/null +++ b/src/test/resources/Darksky/search.feature @@ -0,0 +1,28 @@ +@searchDarkSky @regression +Feature: Search + +# Scenario: Verify user can search temperature using zipcode +# Given I am on darksky landing page +# When I search temperature using 10010 +# Then I verify forecast is displayed +# +# Scenario: Verify user can search temperature using full address +# Given I am on darksky landing page +# When I search temperature using 98 11th Ave, New York, NY +# Then I verify forecast is displayed +# +# Scenario: Verify user can search temperature using country name +# Given I am on darksky landing page +# When I search temperature using Brazil +# Then I verify forecast is displayed + + @ddtDarksky @search + Scenario Outline: Verify user can search temperature using + Given I am on darksky landing page + When I search temperature using + Then I verify forecast is displayed for + Examples: + | dataType | dataValue | + | zipcode | 10010 | + | country name | Brazil | + | full address | 98 11th Ave, New York, NY | \ No newline at end of file diff --git a/src/test/resources/Data.properties b/src/test/resources/Data.properties new file mode 100644 index 0000000..16c6f7a --- /dev/null +++ b/src/test/resources/Data.properties @@ -0,0 +1,7 @@ +url=https://www.darksky.net/ +browser=chrome +version=latest +runOn=sauce +sauceUser=oauth-ddeeeeppaakk4-a7144 +sauceKey=f08c2013-cfac-47f9-8417-7bd31a71b36d +os=windows 10 diff --git a/src/test/resources/Facebook/login.feature b/src/test/resources/Facebook/login.feature new file mode 100644 index 0000000..d94af91 --- /dev/null +++ b/src/test/resources/Facebook/login.feature @@ -0,0 +1,52 @@ +@login @regression +Feature: Facebook login +# Feature name + + # section of feature file that will run before every scenario of this feature-file + # Background section will be executed before every scenario of this feature file + Background: + Given I am on facebook landing page + +# # Scenario name +# @sanity @invalidLogin +# Scenario: Verify user cannot login with invalid credentials +# # steps (Gherkin steps) +# When I enter $%^&*( in login username +# And I enter abcd@1234 in login password +# And I click on login button +# Then I verify error is displayed +# +# @sanity @invalidLogin2 +# Scenario: Verify user cannot login with invalid credentials2 +# When I enter var@gmail.com in login username +# And I enter valkdfjklsdhfkljsdhf;s@1234 in login password +# And I click on login button +# Then I verify error is displayed + + @sanity @invalidLogins @ddtLogin + Scenario Outline: Verify user cannot login with invalid credentials + When I enter in login username + And I enter in login password + And I click on login button + Then I verify error is displayed + Examples: + | username | password | + | $%^&*( | abcd@1234 | + | var@gmail.com | valkdfjklsdhfkljsdhf;s@1234 | + | var@test.com | abcdNoPwd | + + + # Comment in feature file + # valid user credentials are not available. + @validLogin + Scenario: Verify user can login with valid credentials + When I enter validUser@gmail.com in login username + And I enter validPass@1234 in login password + And I click on login button + Then I verify Facebook Homepage is displayed + + @emptyLogin + Scenario: Verify user cannot login with empty credentials + And I click on login button + Then I verify error is displayed + diff --git a/src/test/resources/Facebook/signUp.feature b/src/test/resources/Facebook/signUp.feature new file mode 100644 index 0000000..8036c9d --- /dev/null +++ b/src/test/resources/Facebook/signUp.feature @@ -0,0 +1,24 @@ +@signup @regression +Feature: Facebook Sign Up + + Background: + Given I am on facebook landing page + When I click on Create New Account button + + @sanity @createNewActBtn + Scenario: Verify user can sign up + And I submit Sign up form + Then I verify account is created + + @sanity @dob + Scenario: Verify dob on sign up is current date + Then I verify dob is current date + + @sanity @genderBtn + Scenario: Verify no gender is selected on Sign Up form + Then I verify no gender is selected + + Scenario: User cannot submit form without entering all mandatory field + And I fill form except gender + And I click on the submit button + Then I verify error is displayed \ No newline at end of file diff --git a/src/test/resources/Hotels/Hotels.comS1.feature b/src/test/resources/Hotels/Hotels.comS1.feature new file mode 100644 index 0000000..5eafa98 --- /dev/null +++ b/src/test/resources/Hotels/Hotels.comS1.feature @@ -0,0 +1,74 @@ + + +Feature:Hotels.com S1 + Background: + Given I am on Hotels Landing Page + + Scenario: TC-17 Verify past date and back button on Current month's calendar is disabled + When I click check in button + Then I verify that current month back button is disabled + Then I verify that past dates are disabled + And I click done button in calendar + And I click check out button + Then I verify that past dates are disabled + Then I verify that current month back button is disabled + + + + Scenario: TC-18 Verify user can update number of guests on Home page + When I click travelers button + + + + + Scenario: TC-19 Verify Share feedback button is displayed at the end of search results + When I enter bora in destination + When I select Bora Bora from suggestion + And I click check in button + And I select 1 August 2022 as Check-in + And I click done button in calendar + And I click check out button + And I select 10 August 2022 as checkout + And I click done button in calendar + When I click on search button + Then I verify that the message tell us how we can improve is displayed + Then I verify that share button is enabled + + + + + + + Scenario: TC-20 Verify TermsAndConditions link and PrivacyStatements link open correct page on new tab + When I click sign in link + When I click sign up link + And I click terms and conditions link + And I verify terms and conditions page opens in new tab + And I click privacy statements link + And I verify privacy statement page opens in new tab + + + + Scenario: TC-21 Verify Verification message for invalid sign in credentials + When I click sign in link + When I click sign in button + When I enter krshnik@gmail.com email address + When I enter TechnoSoft* password + And I click on sign in button + Then I verify that the message is displayed + + + Scenario: TC-24 Verify error is displayed when user submits the empty feedback form + When I click sign in link + When I click Feedback link + And I click submit button + + + + + + + + + + diff --git a/src/test/resources/Others.feature b/src/test/resources/Others.feature new file mode 100644 index 0000000..84a8409 --- /dev/null +++ b/src/test/resources/Others.feature @@ -0,0 +1,7 @@ +Feature: Other Automation scenarios + + Scenario: Verify customer is deleted msg is displayed on guru99 + Given I am on Guru landing page + When I enter the customer id as 100 + And I click on Submit button + Then I verify 'Customer Successfully Delete!' is displayed \ No newline at end of file diff --git a/src/test/resources/Others/Others.feature b/src/test/resources/Others/Others.feature new file mode 100644 index 0000000..a863a85 --- /dev/null +++ b/src/test/resources/Others/Others.feature @@ -0,0 +1,9 @@ +@others @regression +Feature: Other Automation scenarios + + @guru99 + Scenario: Verify customer is deleted msg is displayed on guru99 + Given I am on Guru landing page + When I enter the customer id as 100 + And I click on Submit button + Then I verify 'Customer Successfully Delete!' is displayed \ No newline at end of file diff --git a/src/test/resources/Others/SampleFeature.feature b/src/test/resources/Others/SampleFeature.feature new file mode 100644 index 0000000..e69de29 diff --git a/src/test/resources/SampleFeature.feature b/src/test/resources/SampleFeature.feature new file mode 100644 index 0000000..e69de29