Test Scenario: To check whether Agent Names are filtered alphabetically
Test Steps:
Navigate to http://propertyguru.com.sg
Click on Find Agent on Main Menu Bar
Click on Alphabet C.
Verify if the results >10 e.g. (130 Agents Found), then Check that the first 10 agent names (results) start with Alphabet “C”.
Else print “Results are not sorted Alphabetically”.
Test Case Code Snippet
package com;
import java.util.concurrent.TimeUnit;
import org.junit.Before;
import org.junit.After;
import org.junit.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
public class ChromeDriverTest {
private WebDriver driver;
private String baseUrl;
private String strTextToVerify;
@Before
public void setUp() throws Exception{
driver = new FirefoxDriver();
baseUrl = "http://www.propertyguru.com.sg";
driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);
System.out.println("SetUp executed succesfully");
}
@Test
public void testPropertyGuru() throws Exception{
driver.get(baseUrl + "/");
driver.findElement(By.linkText("Find Agent")).click();
driver.findElement(By.id("name_2")).click();
if (Integer.valueOf(driver.findElement(By.cssSelector("font.redtext")).getText()).intValue() > 10){
System.out.println(Integer.valueOf(driver.findElement(By.cssSelector("font.redtext")).getText()).intValue());
for (int i =3; i <22 i="" span="">22>
strTextToVerify = driver.findElement(By.xpath(".//*[@id='homeleft']/div["+i+"]/div[2]/div[1]/div[1]/a")).getText();
System.out.println("Agent name " +strTextToVerify+ " starts with " +"'"+strTextToVerify.charAt(0)+"'");
i = i+1;
}
} else {
System.out.println("testPropertyGuru() executed succesfully");
}
System.out.println("testPropertyGuru() executed succesfully");
}
@After
public void tearDown() throws Exception{
driver.quit();
System.out.println("tearDown() executed succesfully");
}
}
Test Steps:
Navigate to http://propertyguru.com.sg
Click on Find Agent on Main Menu Bar
Click on Alphabet C.
Verify if the results >10 e.g. (130 Agents Found), then Check that the first 10 agent names (results) start with Alphabet “C”.
Else print “Results are not sorted Alphabetically”.
Test Case Code Snippet
package com;
import java.util.concurrent.TimeUnit;
import org.junit.Before;
import org.junit.After;
import org.junit.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
public class ChromeDriverTest {
private WebDriver driver;
private String baseUrl;
private String strTextToVerify;
@Before
public void setUp() throws Exception{
driver = new FirefoxDriver();
baseUrl = "http://www.propertyguru.com.sg";
driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);
System.out.println("SetUp executed succesfully");
}
@Test
public void testPropertyGuru() throws Exception{
driver.get(baseUrl + "/");
driver.findElement(By.linkText("Find Agent")).click();
driver.findElement(By.id("name_2")).click();
if (Integer.valueOf(driver.findElement(By.cssSelector("font.redtext")).getText()).intValue() > 10){
System.out.println(Integer.valueOf(driver.findElement(By.cssSelector("font.redtext")).getText()).intValue());
for (int i =3; i <22 i="" span="">22>
strTextToVerify = driver.findElement(By.xpath(".//*[@id='homeleft']/div["+i+"]/div[2]/div[1]/div[1]/a")).getText();
System.out.println("Agent name " +strTextToVerify+ " starts with " +"'"+strTextToVerify.charAt(0)+"'");
i = i+1;
}
} else {
System.out.println("testPropertyGuru() executed succesfully");
}
System.out.println("testPropertyGuru() executed succesfully");
}
@After
public void tearDown() throws Exception{
driver.quit();
System.out.println("tearDown() executed succesfully");
}
}
No comments:
Post a Comment