Skip to content
Open
Show file tree
Hide file tree
Changes from 3 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
38 changes: 38 additions & 0 deletions src/com/qualityworkscg/pages/Page.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
package com.qualityworkscg.pages;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;

public class Page {

protected WebDriver driver;

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 Page(WebDriver driver) {
this.driver = driver;
}
Expand All @@ -17,6 +25,36 @@ public void navigate(String url) {
public String getTitle() {
return driver.getTitle();
}

//Function to click the Services dropdown
public void clickServices(){
WebElement pageElement = driver.findElement(By.cssSelector(SERVICES_LOCATOR));
pageElement.click();
}

//Function to click the Mobile Automation dropdown
public void clickMobileAutomation(){
WebElement pageElement = driver.findElement(By.cssSelector(MOBILE_AUTOMATION_LOCATOR));
pageElement.click();
}

//Function to click the DevOps Consultancy dropdown
public void clickDevOpsConsultancy(){
WebElement pageElement = driver.findElement(By.cssSelector(DEVOPS_CONSULTANCY_LOCATOR));
pageElement.click();
}

//Function to click the Software Development dropdown
public void clickSoftwareDevelopment(){
WebElement pageElement = driver.findElement(By.cssSelector(SOFTWARE_DEVELOPMENT_LOCATOR));
pageElement.click();
}

//Function to click the Agile Coaching dropdown
public void clickAgileCoaching(){
WebElement pageElement = driver.findElement(By.cssSelector(AGILE_COACHING_LOCATOR));
pageElement.click();
}

public void tearDown() {
try {
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();
}
}
}
48 changes: 48 additions & 0 deletions src/com/qualityworkscg/tests/ServicesTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
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 () throws InterruptedException{
page.clickServices();
Thread.sleep(1000);
page.clickMobileAutomation();
Thread.sleep(2000);
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 () throws InterruptedException{
page.clickServices();
Thread.sleep(1000);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jpottinger Is there a way can test these without explicitly calling Thread.sleep

page.clickDevOpsConsultancy();
Thread.sleep(2000);
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 () throws InterruptedException{
page.clickServices();
Thread.sleep(1000);
page.clickSoftwareDevelopment();
Thread.sleep(2000);
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 () throws InterruptedException{
page.clickServices();
Thread.sleep(1000);
page.clickAgileCoaching();
Thread.sleep(2000);
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 -->