Skip to content

Instantly share code, notes, and snippets.

public class GoogleSearchTest {
private DefaultSelenium selenium;
@Before
public void startSeleniumClient() {
selenium = new DefaultSelenium("localhost", 4444, "firefox", "http://www.google.com");
selenium.start();
}
public class GoogleSearchTest {
private DefaultSelenium selenium;
private GoogleSearchPage googleSearchPage;
@Before
public void startSeleniumClient() {
selenium = new DefaultSelenium("localhost", 4444, "firefox", "http://www.google.com");
googleSearchPage = new GoogleSearchPage(selenium);
selenium.start();
@Test
public void searchQueryShouldBePartOfTheTitleOfTheResultPage() {
assertThat(new GoogleSearchPage(selenium)
.searchFor("Selenium OpenQA")
.title(),
containsString("Selenium OpenQA"));
}
public class GoogleAplicationDriver extends TestWatchman {
private DefaultSelenium selenium;
@Override
public void starting(FrameworkMethod method) {
selenium = new DefaultSelenium("localhost", 4444, "firefox", "http://www.google.com");
selenium.start();
}
@Override
public class GoogleSearchTest {
@Rule
GoogleAplicationDriver googleAplicationDriver = new GoogleAplicationDriver();
@Test
public void searchQueryShouldBePartOfTheTitleOfTheResultPage() {
GoogleResultPage googleResultPage = googleAplicationDriver
.goToSearchPage()
.searchFor("Selenium OpenQA")
String mensaje = "El usuario Alfredo Casado tiene el dni: 123456798P";
assertTrue(mensaje.contains("Alfredo Casado"));
assertTrue(mensaje.contains("123456798P"));
String mensaje = "El usuario Alfredo Casado tiene el dni: 123456798P";
assertThat(mensaje, allOf(containsString("Alfredo Casado"),
containsString("123456798P")));
Expected: (a string containing "Alfredo Casado" and a string containing "123456798P")
got: "El usuario Alfredo Casado tiene el dni: 123556798P"
)
assertThat(mensaje, allOf(containsString(WITH_EXPECTED_USER_NAME),
containsString(WITH_EXPECTED_DNI)));
Set<String> cesta = new HashSet();
cesta.add("manzana");
cesta.add("platano");
cesta.add("fresa");
assertTrue(cesta.contains("manzana") || cesta.contains("pera"));