@Test public void should_not_open_initial_page_when_driver_opens_if_using_a_proxied_driver() { Pages pages = new Pages(driverProxy); pages.setDefaultBaseUrl("http://www.google.com"); pages.notifyWhenDriverOpens(); verify(driver, never()).get("http://www.google.com"); }
@Test public void should_open_initial_page_when_driver_opens() { Pages pages = new Pages(driver, configuration); pages.setDefaultBaseUrl("http://www.google.com"); pages.notifyWhenDriverOpens(); verify(driver).get("http://www.google.com"); }
@Test public void should_requery_driver_for_each_page_request() { when(driver.getCurrentUrl()).thenReturn("http://www.google.com"); Pages pages = new Pages(driver, configuration); pages.setDefaultBaseUrl("http://www.google.com"); GooglePage page1 = pages.get(GooglePage.class); GooglePage page2 = pages.get(GooglePage.class); assertThat(page2, is(not(page1))); }
@Test public void should_use_the_same_page_object_if_we_indicate_that_are_on_the_same_unchanged_page() { when(driver.getCurrentUrl()).thenReturn("http://www.google.com"); Pages pages = new Pages(driver, configuration); pages.setDefaultBaseUrl("http://www.google.com"); GooglePage page1 = pages.get(GooglePage.class); pages.onSamePage(); GooglePage page2 = pages.get(GooglePage.class); assertThat(page2, is(page1)); }
@Test public void the_pages_object_should_have_a_default_starting_point_url() { final String baseUrl = "http://www.google.com"; final Pages pages = new Pages(driver, configuration); pages.setDefaultBaseUrl(baseUrl); pages.start(); verify(driver).get(baseUrl); }
@Test public void the_default_starting_point_url_can_refer_to_a_file_on_the_classpath() { final String baseUrl = "classpath:static-site/index.html"; final Pages pages = new Pages(driver, configuration); pages.setDefaultBaseUrl(baseUrl); URL staticSiteUrl = Thread.currentThread().getContextClassLoader().getResource("static-site/index.html"); pages.start(); verify(driver).get(staticSiteUrl.toString()); }
@Test public void should_register_proxy_drivers_when_driver_opens() { Pages pages = new Pages(driverProxy) { @Override protected WebdriverProxyFactory getProxyFactory() { return proxyFactory; } }; pages.setDefaultBaseUrl("http://www.google.com"); pages.notifyWhenDriverOpens(); verify(proxyFactory).registerListener(any(PagesEventListener.class)); }