diff --git a/pom.xml b/pom.xml index f893a22..cde69eb 100644 --- a/pom.xml +++ b/pom.xml @@ -33,6 +33,11 @@ 4.12 test + + junit + junit + RELEASE + \ No newline at end of file diff --git a/src/main/java/automation/pages/ContactUsPage.java b/src/main/java/automation/pages/ContactUsPage.java index 1a27b54..3e1809a 100644 --- a/src/main/java/automation/pages/ContactUsPage.java +++ b/src/main/java/automation/pages/ContactUsPage.java @@ -2,9 +2,63 @@ import org.openqa.selenium.WebElement; import org.openqa.selenium.support.FindBy; +import org.openqa.selenium.support.PageFactory; public class ContactUsPage extends BasePage { - @FindBy(xpath="//*[@class='page-heading bottom-indent']") + @FindBy(xpath="//h1[@class='page-heading bottom-indent']") WebElement contactUsPageTitile; + @FindBy(xpath="//div[@id='center_column']/h1") + WebElement contactPageHeader; + @FindBy(css="#id_contact") + WebElement subjectHeading; + + @FindBy(css="#email") + WebElement mail; + + @FindBy(css="#id_order") + WebElement orderReference; + + @FindBy(css="#fileUpload") + WebElement fileUpload; + + @FindBy(css="#submitMessage") + WebElement submitMessage; + + @FindBy(css="#message") + WebElement message; + + @FindBy(xpath = "//div[@id='center_column']/p") + WebElement confirmationMessage; + + public ContactUsPage(){ PageFactory.initElements(driver,this); } + + public void setSubjectHeading(String selectSubjectHeading){ + Utils.selectFromList(subjectHeading,selectSubjectHeading); + } + + public boolean isUserOnContactPage(){ + return contactPageHeader.isDisplayed(); + } + + public void setMail(String email){ + mail.sendKeys(email); + } + + public void setOrderReference(String settingOrderReference){ + orderReference.sendKeys(settingOrderReference); + } + public void setFileUpload(String filePath){ + + fileUpload.sendKeys(filePath); + } + public void setSubmitMessage(){ + submitMessage.click(); + } + public void setMessage(){ + message.sendKeys("Product is not Yet Delivered"); + } + public String getConfirmationMessage(){ + return confirmationMessage.getText(); + } } diff --git a/src/main/java/automation/pages/HomePage.java b/src/main/java/automation/pages/HomePage.java index 59c4d42..8801931 100644 --- a/src/main/java/automation/pages/HomePage.java +++ b/src/main/java/automation/pages/HomePage.java @@ -4,9 +4,11 @@ import org.openqa.selenium.By; import org.openqa.selenium.WebElement; import org.openqa.selenium.support.FindBy; +import org.openqa.selenium.support.PageFactory; public class HomePage extends BasePage { - + @FindBy(css="#contact-link") + WebElement clickOnContactUs; @FindBy(xpath="//*[@class='login']") WebElement signinbtn; @FindBy(xpath="//*[@title='Contact Us']") @@ -28,17 +30,19 @@ public class HomePage extends BasePage { @FindBy(xpath="html/body/div[1]/div[2]/div/div[3]/div[2]/div[1]/div[2]/form/button") WebElement compareBtn; + + public HomePage(){ + PageFactory.initElements(driver,this); + } + + public void navigateToContactUsPage(){ + clickOnContactUs.click(); + } //for a valid user name and password who already registered public void signin() { - signinbtn.click(); + signinbtn.click(); } - - public void contactUsLinkPresence() { - contactuslink.isEnabled(); - contactuslink.click(); - /*boolean res =contactpage.contactUsPageTitile.isDisplayed(); - assertTrue(res);*/ - } + public void search(String itemname) { searchBox.sendKeys(itemname); searchclickbtn.click(); diff --git a/src/test/java/automation/BaseTests.java b/src/test/java/automation/BaseTests.java index 10b4e35..efa6872 100644 --- a/src/test/java/automation/BaseTests.java +++ b/src/test/java/automation/BaseTests.java @@ -12,7 +12,7 @@ public static void openbrowser() { BasePage.startBrowser(); } - @AfterClass + //@AfterClass public static void closedown() { BasePage.closebrowser(); } diff --git a/src/test/java/automation/HomePageTests.java b/src/test/java/automation/HomePageTests.java index 9e820dd..62642b4 100644 --- a/src/test/java/automation/HomePageTests.java +++ b/src/test/java/automation/HomePageTests.java @@ -3,18 +3,35 @@ import automation.pages.ContactUsPage; import automation.pages.HomePage; import automation.pages.SigninPage; +import org.junit.Assert; import org.junit.Test; import org.openqa.selenium.support.PageFactory; public class HomePageTests extends BaseTests { - + //TestData + String selectSubjectHeading="Customer service"; + String email="anugu.archana@gmail.com"; + String settingorderReference="KYJUXWFXQ - 10/09/2017"; + String filePath="C:\\Users\\sridhar\\Desktop\\mon.jpg"; + String message="Your message has been successfully sent to our team."; + + //Creating object for Reusable function classes + HomePage homePage=new HomePage(); + ContactUsPage contactUsPage=new ContactUsPage(); + @Test public void verifyContactUs() { - ContactUsPage contactus=PageFactory.initElements(driver,ContactUsPage.class); - HomePage homepage=PageFactory.initElements(driver,HomePage.class); - homepage.contactUsLinkPresence(); + homePage.navigateToContactUsPage(); + Assert.assertTrue(contactUsPage.isUserOnContactPage()); + contactUsPage.setSubjectHeading(selectSubjectHeading); + contactUsPage.setMail(email); + contactUsPage.setOrderReference(settingorderReference); + contactUsPage.setFileUpload(filePath); + contactUsPage.setMessage(); + contactUsPage.setSubmitMessage(); + Assert.assertEquals(contactUsPage.getConfirmationMessage(),message); } @Test