From 5c2abe88bf81037934376964a272189c7a46559c Mon Sep 17 00:00:00 2001 From: srikanth99 Date: Mon, 23 Oct 2017 22:11:40 +0100 Subject: [PATCH 1/3] added contactUsPage --- pom.xml | 5 ++ .../java/automation/pages/ContactUsPage.java | 53 +++++++++++++++++++ src/test/java/automation/BaseTests.java | 2 +- src/test/java/automation/HomePageTests.java | 14 ++++- 4 files changed, 72 insertions(+), 2 deletions(-) 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..16b4e7d 100644 --- a/src/main/java/automation/pages/ContactUsPage.java +++ b/src/main/java/automation/pages/ContactUsPage.java @@ -2,9 +2,62 @@ 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']") WebElement contactUsPageTitile; + @FindBy(xpath="//div[@id='center_column']/h1") + WebElement contactPageHeader; + @FindBy(xpath="//*[@id='id_contact']") + WebElement subjectHeading; + + @FindBy(id="email") + WebElement mail; + + @FindBy(id="id_order") + WebElement orderReference; + + @FindBy(id="fileUpload") + WebElement fileUpload; + + @FindBy(id="submitMessage") + WebElement submitMessage; + + @FindBy(id="message") + WebElement message; + + @FindBy(xpath = "//div[@id='center_column']/p") + WebElement confirmationMessage; + + + public void setSubjectHeading(){ + Utils.selectFromList(subjectHeading,"Customer service"); + } + + public boolean isUserOnContactPage(){ + return contactPageHeader.isDisplayed(); + } + + public void setMail(String email){ + mail.sendKeys(email); + } + + public void setOrderReference(){ + orderReference.sendKeys("KYJUXWFXQ - 10/09/2017"); + } + 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/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..18db5f0 100644 --- a/src/test/java/automation/HomePageTests.java +++ b/src/test/java/automation/HomePageTests.java @@ -3,18 +3,30 @@ 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 email="anugu.archana@gmail.com"; + String filePath="C:\\Users\\sridhar\\Desktop\\mon.jpg"; @Test public void verifyContactUs() { ContactUsPage contactus=PageFactory.initElements(driver,ContactUsPage.class); HomePage homepage=PageFactory.initElements(driver,HomePage.class); homepage.contactUsLinkPresence(); + Assert.assertTrue(contactus.isUserOnContactPage()); + contactus.setSubjectHeading(); + contactus.setMail(email); + contactus.setOrderReference(); + contactus.setFileUpload(filePath); + contactus.setMessage(); + contactus.setSubmitMessage(); + Assert.assertEquals(contactus.getConfirmationMessage(),"Your message has been successfully sent to our team."); + } @Test From 35c87ef2ff173cac948e00eae8e19829eb3b5702 Mon Sep 17 00:00:00 2001 From: srikanth99 Date: Mon, 23 Oct 2017 22:52:39 +0100 Subject: [PATCH 2/3] added contactUsPage --- .../java/automation/pages/ContactUsPage.java | 1 + src/main/java/automation/pages/HomePage.java | 22 +++++++++------- src/test/java/automation/HomePageTests.java | 26 ++++++++++--------- 3 files changed, 28 insertions(+), 21 deletions(-) diff --git a/src/main/java/automation/pages/ContactUsPage.java b/src/main/java/automation/pages/ContactUsPage.java index 16b4e7d..05f25db 100644 --- a/src/main/java/automation/pages/ContactUsPage.java +++ b/src/main/java/automation/pages/ContactUsPage.java @@ -31,6 +31,7 @@ public class ContactUsPage extends BasePage { @FindBy(xpath = "//div[@id='center_column']/p") WebElement confirmationMessage; + public ContactUsPage(){ PageFactory.initElements(driver,this); } public void setSubjectHeading(){ Utils.selectFromList(subjectHeading,"Customer service"); diff --git a/src/main/java/automation/pages/HomePage.java b/src/main/java/automation/pages/HomePage.java index 59c4d42..732b056 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(id="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/HomePageTests.java b/src/test/java/automation/HomePageTests.java index 18db5f0..1ab4945 100644 --- a/src/test/java/automation/HomePageTests.java +++ b/src/test/java/automation/HomePageTests.java @@ -13,20 +13,22 @@ public class HomePageTests extends BaseTests { //TestData String email="anugu.archana@gmail.com"; String filePath="C:\\Users\\sridhar\\Desktop\\mon.jpg"; + + //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(); - Assert.assertTrue(contactus.isUserOnContactPage()); - contactus.setSubjectHeading(); - contactus.setMail(email); - contactus.setOrderReference(); - contactus.setFileUpload(filePath); - contactus.setMessage(); - contactus.setSubmitMessage(); - Assert.assertEquals(contactus.getConfirmationMessage(),"Your message has been successfully sent to our team."); - + homePage.navigateToContactUsPage(); + Assert.assertTrue(contactUsPage.isUserOnContactPage()); + contactUsPage.setSubjectHeading(); + contactUsPage.setMail(email); + contactUsPage.setOrderReference(); + contactUsPage.setFileUpload(filePath); + contactUsPage.setMessage(); + contactUsPage.setSubmitMessage(); + Assert.assertEquals(contactUsPage.getConfirmationMessage(),"Your message has been successfully sent to our team."); } @Test From eabcb1ab3ccf89b3013e6d8801a76a81d1bde8a0 Mon Sep 17 00:00:00 2001 From: srikanth99 Date: Wed, 25 Oct 2017 17:55:19 +0100 Subject: [PATCH 3/3] added contactUsPage --- .../java/automation/pages/ContactUsPage.java | 22 +++++++++---------- src/main/java/automation/pages/HomePage.java | 2 +- src/test/java/automation/HomePageTests.java | 9 +++++--- 3 files changed, 18 insertions(+), 15 deletions(-) diff --git a/src/main/java/automation/pages/ContactUsPage.java b/src/main/java/automation/pages/ContactUsPage.java index 05f25db..3e1809a 100644 --- a/src/main/java/automation/pages/ContactUsPage.java +++ b/src/main/java/automation/pages/ContactUsPage.java @@ -5,27 +5,27 @@ 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(xpath="//*[@id='id_contact']") + @FindBy(css="#id_contact") WebElement subjectHeading; - @FindBy(id="email") + @FindBy(css="#email") WebElement mail; - @FindBy(id="id_order") + @FindBy(css="#id_order") WebElement orderReference; - @FindBy(id="fileUpload") + @FindBy(css="#fileUpload") WebElement fileUpload; - @FindBy(id="submitMessage") + @FindBy(css="#submitMessage") WebElement submitMessage; - @FindBy(id="message") + @FindBy(css="#message") WebElement message; @FindBy(xpath = "//div[@id='center_column']/p") @@ -33,8 +33,8 @@ public class ContactUsPage extends BasePage { public ContactUsPage(){ PageFactory.initElements(driver,this); } - public void setSubjectHeading(){ - Utils.selectFromList(subjectHeading,"Customer service"); + public void setSubjectHeading(String selectSubjectHeading){ + Utils.selectFromList(subjectHeading,selectSubjectHeading); } public boolean isUserOnContactPage(){ @@ -45,8 +45,8 @@ public void setMail(String email){ mail.sendKeys(email); } - public void setOrderReference(){ - orderReference.sendKeys("KYJUXWFXQ - 10/09/2017"); + public void setOrderReference(String settingOrderReference){ + orderReference.sendKeys(settingOrderReference); } public void setFileUpload(String filePath){ diff --git a/src/main/java/automation/pages/HomePage.java b/src/main/java/automation/pages/HomePage.java index 732b056..8801931 100644 --- a/src/main/java/automation/pages/HomePage.java +++ b/src/main/java/automation/pages/HomePage.java @@ -7,7 +7,7 @@ import org.openqa.selenium.support.PageFactory; public class HomePage extends BasePage { - @FindBy(id="contact-link") + @FindBy(css="#contact-link") WebElement clickOnContactUs; @FindBy(xpath="//*[@class='login']") WebElement signinbtn; diff --git a/src/test/java/automation/HomePageTests.java b/src/test/java/automation/HomePageTests.java index 1ab4945..62642b4 100644 --- a/src/test/java/automation/HomePageTests.java +++ b/src/test/java/automation/HomePageTests.java @@ -11,8 +11,11 @@ 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(); @@ -22,13 +25,13 @@ public class HomePageTests extends BaseTests { public void verifyContactUs() { homePage.navigateToContactUsPage(); Assert.assertTrue(contactUsPage.isUserOnContactPage()); - contactUsPage.setSubjectHeading(); + contactUsPage.setSubjectHeading(selectSubjectHeading); contactUsPage.setMail(email); - contactUsPage.setOrderReference(); + contactUsPage.setOrderReference(settingorderReference); contactUsPage.setFileUpload(filePath); contactUsPage.setMessage(); contactUsPage.setSubmitMessage(); - Assert.assertEquals(contactUsPage.getConfirmationMessage(),"Your message has been successfully sent to our team."); + Assert.assertEquals(contactUsPage.getConfirmationMessage(),message); } @Test