Skip to content
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
62 changes: 57 additions & 5 deletions src/com/qualityworkscg/pages/Page.java
Original file line number Diff line number Diff line change
@@ -1,24 +1,76 @@
package com.qualityworkscg.pages;

import java.util.concurrent.TimeUnit;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
import org.testng.Assert;

public class Page {

protected WebDriver driver;
WebDriverWait wait;


public static final String SERVICES_LOCATOR = "a[title='Services']";
public static final String MOBILE_AUTOMATION_LOCATOR = "a[title='Mobile & Web Test Automation']";
public static final String DEVOPS_CONSULTANCY_LOCATOR = "a[title='DevOps Consultancy']";
public static final String SOFTWARE_DEVELOPMENT_LOCATOR ="a[title='Software Development Consultancy']";
public static final String AGILE_COACHING_LOCATOR = "a[title='Agile Coaching']";

public static final String BASE_URL = "http://www.qualityworkscg.com/";

public Page(WebDriver driver) {
public Page (WebDriver driver) {
this.driver = driver;
wait = new WebDriverWait (driver, 10);
}

public void navigate(String url) {
public void navigate (String url) {
driver.navigate().to(url);
}
}

public String getTitle() {
public String getTitle () {
return driver.getTitle();
}

//Function to click the Services dropdown
public void clickServices () {
WebElement pageElement = wait.until(ExpectedConditions.visibilityOfElementLocated(By.cssSelector(SERVICES_LOCATOR)));
pageElement.click();
}

//Function to click the Mobile Automation dropdown
public void clickMobileAutomation () {
WebElement pageElement = wait.until(ExpectedConditions.visibilityOfElementLocated(By.cssSelector(MOBILE_AUTOMATION_LOCATOR)));
pageElement.click();
wait.until(ExpectedConditions.urlMatches(BASE_URL + "automation/"));
}

//Function to click the DevOps Consultancy dropdown
public void clickDevOpsConsultancy () {
WebElement pageElement = wait.until(ExpectedConditions.visibilityOfElementLocated(By.cssSelector(DEVOPS_CONSULTANCY_LOCATOR)));
pageElement.click();
wait.until(ExpectedConditions.urlMatches(BASE_URL + "devops/"));
}

//Function to click the Software Development dropdown
public void clickSoftwareDevelopment () {
WebElement pageElement = wait.until(ExpectedConditions.visibilityOfElementLocated(By.cssSelector(SOFTWARE_DEVELOPMENT_LOCATOR)));
pageElement.click();
wait.until(ExpectedConditions.urlMatches(BASE_URL + "software-development-consultancy/"));
}

//Function to click the Agile Coaching dropdown
public void clickAgileCoaching () {
WebElement pageElement = wait.until(ExpectedConditions.visibilityOfElementLocated(By.cssSelector(AGILE_COACHING_LOCATOR)));
pageElement.click();
wait.until(ExpectedConditions.urlMatches(BASE_URL + "agile-coaching/"));
}

public void tearDown() {
public void tearDown () {
try {
this.driver.quit();
} catch(Exception e) {
Expand Down
2 changes: 1 addition & 1 deletion src/com/qualityworkscg/tests/AbstractTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ public void setup(String url) {
public void afterTest() {
page.tearDown();
}
}
}
40 changes: 40 additions & 0 deletions src/com/qualityworkscg/tests/ServicesTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package com.qualityworkscg.tests;

import org.testng.Assert;
import org.testng.annotations.Test;

public class ServicesTest extends AbstractTest{

@Test
//Function to verify that the Mobile Automation drop down navigates to the correct page.
public void verifyNavigationMobileAutomation () {
page.clickServices();
page.clickMobileAutomation();
Assert.assertEquals(page.getTitle(), "QualityWorks Consulting Group | Mobile and Web Automation", "Testing if title is QualityWorks Consulting Group | Mobile and Web Automation");
}

@Test
//Function to verify that the DevOps Consultancy drop down navigates to the correct page.
public void verifyNavigationDevOpsConsultancy () {
page.clickServices();
page.clickDevOpsConsultancy();
Assert.assertEquals(page.getTitle(), "QualityWorks Consulting Group | DevOps Consultancy", "Testing if title is QualityWorks Consulting Group | Mobile and Web Automation");
}

@Test
//Function to verify that the Software Development drop down navigates to the correct page.
public void verifyNavigationSoftwareDevelopment () {
page.clickServices();
page.clickSoftwareDevelopment();
Assert.assertEquals(page.getTitle(), "QualityWorks Consulting Group | Software Development Consultancy", "Testing if title is QualityWorks Consulting Group | Mobile and Web Automation");
}

@Test
//Function to verify that the Agile Coaching drop down navigates to the correct page.
public void verifyNavigationAgileCoaching () {
page.clickServices();
page.clickAgileCoaching();
Assert.assertEquals(page.getTitle(), "QualityWorks Consulting Group | Agile Coaching and Training", "Testing if title is QualityWorks Consulting Group | Mobile and Web Automation");
}

}
1 change: 1 addition & 0 deletions testng.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<parameter name="url" value="http://www.qualityworkscg.com"></parameter>
<classes>
<class name="com.qualityworkscg.tests.HomeTest"/>
<class name="com.qualityworkscg.tests.ServicesTest"/>
</classes>
</test> <!-- Test -->
</suite> <!-- Suite -->