Exemplo n.º 1
0
		driver.get("http://demo.magentocommerce.com/");
		
	}
	
	@Test
	public void testSearchByCategory() {

		// Creamos el WebElement Search Field
		WebElement searchField = driver.findElement(By.id("search"));
		
		// Introducimos la busqueda
		searchField.sendKeys("phones");
		
		// realizamos la busqueda
		searchField.submit();
		//driver.findElement(By.className("search-button")).click();
		
		// Capturamos todos los elementos que devuelve la busqueda
		List<WebElement> products = driver.findElements(By.cssSelector(".product-name a"));
		
		// validamos el resultado
		assert products.size() == 2;
	}
	
	@After
	public void TearDown() {
		driver.quit();
	}

}
Exemplo n.º 2
0
	
	private WebDriver driver;

	@BeforeClass
	public void setUp() {
		//Creating new Firefox profile
		FirefoxProfile profile = new FirefoxProfile();
		profile.setAcceptUntrustedCertificates(true); 
		profile.setAssumeUntrustedCertificateIssuer(false);
		driver = new FirefoxDriver(profile); 
		driver.manage().window().maximize();
	}
	
	@Test
	public void openApplication() {
		System.out.println("Navigating application");
		driver.get("https://cacert.org/");
		WebElement headingEle = driver.findElement(By.cssSelector(".story h3"));
		//Validate heading after accepting untrusted connection
		String expectedHeading = "Are you new to CAcert?";
		Assert.assertEquals(headingEle.getText(), expectedHeading);
	}
	
	@AfterClass
	public void tearDown() {
		if(driver!=null) 
			driver.quit();
	}
	
}