studentInput.type('w');studentInput.type('i');Assert.assertEquals(client.getCurrentWindow().getEnclosedPage(),page);// Here the suggestionBox is still hidden
// Here suggestionBox is visibleAssert.assertEquals(client.getCurrentWindow().getEnclosedPage(),page);Map<String,HtmlTableCell>suggestions=WebClientUtils.getSuggestions(page.getElementById("searchClass:sS"),0);Assert.assertEquals(1,suggestions.size());System.out.println(suggestions);HtmlTableCellcell=suggestions.get("Willis Bruce");Assert.assertNotNull(cell);cell.click();
WebClientUtils.waitForJSJob(client,0,30000);Assert.assertEquals("Willis Bruce",((HtmlElement)page.getByXPath("//*[@id='searchClass:searchStudent']").get(0)).asText());System.out.println("Success!");// page = (HtmlPage) client.getPage("http://localhost:8080/schoolmanager/view/class/current.seam?networkId=salsafactory");WebClientUtils.waitForJSJob(client,0,30000);Assert.assertEquals(client.getCurrentWindow().getEnclosedPage(),page);studentInput=(HtmlInput)page.getElementById("searchClass:student_i");studentInput.setValueAttribute("");studentInput.type('l');studentInput.type('i');Assert.assertEquals(client.getCurrentWindow().getEnclosedPage(),page);// WebClientUtils.forceWait(2000);// Here the suggestionBox is still hiddenWebClientUtils.waitForJSJob(client,0,30000);// Here suggestionBox is visibleAssert.assertEquals(client.getCurrentWindow().getEnclosedPage(),page);suggestions=WebClientUtils.getSuggestions(page.getElementById("searchClass:sS"),0);Assert.assertEquals(1,suggestions.size());System.out.println(suggestions);cell=suggestions.get("Linda Bogusław");Assert.assertNotNull(cell);cell.click();WebClientUtils.waitForJSJob(client,0,30000);Assert.assertEquals("Linda Bogusław",((HtmlElement)page.getByXPath("//*[@id='searchClass:searchStudent']").get(0)).asText());System.out.println("Success2!");}@TestpublicvoidswitchBetwenScheduleAndTableMode()throwsIOException{WebClientclient=newWebClient(BrowserVersion.FIREFOX_3_6);HtmlPagepage=login(client);page.getElementById("j_id2118:j_id2119:0").click();page.getElementById("j_id2118:j_id2119:0").blur();WebClientUtils.waitForJSJob(client,0,30000);// System.out.println(page.getElementById("results").asXml());Assert.assertNotNull(page.getElementById("results:table"));page.getElementById("j_id2118:j_id2119:1").click();page.getElementById("j_id2118:j_id2119:1").blur();WebClientUtils.waitForJSJob(client,0,30000);// System.out.println(page.getElementById("results").asXml());Assert.assertNotNull(page.getElementById("results:schedule"));page.getElementById("j_id2118:j_id2119:0").click();page.getElementById("j_id2118:j_id2119:0").blur();WebClientUtils.waitForJSJob(client,0,30000);// System.out.println(page.getElementById("results").asXml());Assert.assertNotNull(page.getElementById("results:table"));}@TestpublicvoidselectStudentSuggestionByTab()throwsIOException{finalWebClientclient=newWebClient(BrowserVersion.FIREFOX_3_6);finalRequestResponseLoggerrequestResponseLogger=newRequestResponseLogger(client);requestResponseLogger.off();HtmlPagepage=login(client);finalHtmlInputstudentInput=(HtmlInput)page.getElementById("searchClass:student_i");studentInput.type('w');studentInput.type('i');Assert.assertEquals(client.getCurrentWindow().getEnclosedPage(),page);// Here the suggestionBox is still hiddenWebClientUtils.waitForJSJob(client,0,30000);// Here suggestionBox is visibleMap<String,HtmlTableCell>suggestions=WebClientUtils.getSuggestions(page.getElementById("searchClass:sS"),0);Assert.assertEquals(1,suggestions.size());// System.out.println(suggestions);HtmlTableCellcell=suggestions.get("Willis Bruce");Assert.assertNotNull(cell);studentInput.type('\t');WebClientUtils.waitForJSJob(client,0,30000);Assert.assertEquals("Willis Bruce",page.getElementById("searchClass:searchStudent").asText());// requestResponseLogger.on();// client.setAlertHandler(new AlertLogger());// page.addDomChangeListener(new DomChangeLogger());finalHtmlElementelement=page.getElementById("searchClass:searchStudent").getElementsByTagName("img").get(0);element.click();WebClientUtils.waitForJSJob(client,0,30000);Assert.assertEquals(client.getCurrentWindow().getEnclosedPage(),page);Assert.assertEquals("",page.getElementById("searchClass:searchStudent").asText());}privateHtmlPagelogin(WebClientclient)throwsIOException{HtmlPagepage=(HtmlPage)client.getPage("http://localhost:8080/schoolmanager/view/class/current.seam?networkId=salsafactory");((HtmlInput)page.getElementById("loginForm:email")).setValueAttribute("s4237@pjwstk.edu.pl");((HtmlInput)page.getElementById("loginForm:password")).setValueAttribute("aaaaa");HtmlPageoldPage=page;page=page.getElementById("loginForm:submit").click();// This assert would fail (when page redidrects than you need to obtain new page)// Assert.assertEquals(page,oldPage);Assert.assertEquals(client.getCurrentWindow().getEnclosedPage(),page);returnpage;