@Ignore @Test public void test() { // try to type correct login and password. beginAt("logOn.jsp"); // start on logOn.jsp clickLink("enLocale"); // switch on ru locale setTextField("login", "user6"); setTextField("password", "12341234"); submit(); assertTitleEquals("Manager home page"); clickLink("showWorkers"); assertTitleEquals("Workers list"); }
/** change the element and make sure XPath has changed */ @Test public void testChanging() { { IElement element = getElementByXPath("//input[@id='test']"); assertNotNull(element); assertEquals(element.getName(), "input"); assertEquals(element.getAttribute("name"), "element_name"); assertEquals(element.getAttribute("id"), "test"); assertEquals(element.getAttribute("value"), "test3"); // the element should also be available through the normal method assertFormElementPresent("element_name"); } String testingText = new Date().toString(); setTextField("element_name", testingText); assertTextFieldEquals("element_name", testingText); // should still work { IElement element = getElementByXPath("//input[@id='test']"); assertNotNull(element); assertEquals(element.getName(), "input"); assertEquals(element.getAttribute("name"), "element_name"); assertEquals(element.getAttribute("id"), "test"); assertEquals(element.getAttribute("value"), testingText); // should have changed // the element should also be available through the normal method assertFormElementPresent("element_name"); } }
@Test public void testLogin() { beginAt("/default.jsp"); // Open the browser on // http://localhost:8080/test/home.xhtml assertTitleEquals("Movies"); assertElementPresent("janrainModal"); String element = getElementAttributeByXPath("//div[@id='janrainModal']", "style"); assertTrue(element.contains("display: none")); clickLink("login"); element = getElementAttributeByXPath("//div[@id='janrainModal']", "style"); assertTrue(element.contains("display: block")); assertElementPresent("janrain-yahoo"); clickElementByXPath("//li[@id='janrain-yahoo']"); assertWindowCountEquals(2); assertWindowPresentWithTitle("Sign in to Yahoo!"); gotoWindowByTitle("Sign in to Yahoo!"); setTextField("login", "*****@*****.**"); setTextField("passwd", "Test12345"); submit(".save"); try { Thread.sleep(20000); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } // beginAt("/default.jsp"); // gotoWindowByTitle("Movies"); assertTextPresent("Logout"); assertElementPresent("username"); IElement username = getElementById("username"); assertTrue(username.getTextContent().contains("movie hunter")); assertElementNotPresent("login"); assertElementPresent("logout"); clickLink("logout"); assertElementPresent("login"); }