Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added contactUsPage #5

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@
<version>4.12</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>RELEASE</version>
</dependency>

</dependencies>
</project>
56 changes: 55 additions & 1 deletion src/main/java/automation/pages/ContactUsPage.java
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}
22 changes: 13 additions & 9 deletions src/main/java/automation/pages/HomePage.java
Original file line number Diff line number Diff line change
Expand Up @@ -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']")
Expand All @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/automation/BaseTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public static void openbrowser() {
BasePage.startBrowser();

}
@AfterClass
//@AfterClass
public static void closedown() {
BasePage.closebrowser();
}
Expand Down
25 changes: 21 additions & 4 deletions src/test/java/automation/HomePageTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -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="[email protected]";
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
Expand Down