@Test public void testUntitled() throws Exception { selenium.open("/"); selenium.type("id=typeaheadBox", "91367"); selenium.click("css=div.wx-searchButton"); selenium.waitForPageToLoad("30000"); verifyTrue(selenium.isTextPresent("Woodland Hills, CA (91367) Weather")); boolean vResult = selenium.isTextPresent("Woodland Hills, CA (91367) Weather"); if (vResult) { System.out.println("Pass"); } else { System.out.println("Fail"); fail("JUnit result is fail"); } }
@Test public void testFlightSearch() throws Exception { selenium.open("/"); selenium.click("id=search.type.air"); for (int second = 0; ; second++) { if (second >= 60) fail("timeout"); try { if (selenium.isElementPresent("name=ar.rt.leaveSlice.orig.key")) break; } catch (Exception e) { } Thread.sleep(1000); } selenium.click("css=div.button.needsclick"); selenium.type("name=ar.rt.leaveSlice.orig.key", "nyc"); selenium.type("name=ar.rt.leaveSlice.dest.key", "sfo"); selenium.type("name=ar.rt.leaveSlice.date", "07/18/15"); selenium.type("name=ar.rt.returnSlice.date", "07/20/15"); selenium.click("name=search"); selenium.waitForPageToLoad("30000"); for (int second = 0; ; second++) { if (second >= 60) fail("timeout"); try { if (selenium.isElementPresent("css=div.matchingResults > h2")) break; } catch (Exception e) { } Thread.sleep(1000); } verifyTrue(selenium.isTextPresent("Matching Results")); for (int second = 0; ; second++) { if (second >= 60) fail("timeout"); try { if (selenium.isElementPresent("xpath=//span[@class='price']")) break; } catch (Exception e) { } Thread.sleep(1000); } String price = selenium.getText("xpath=//span[@class='price']"); System.out.println("The lowest price is " + price); }