コード例 #1
0
  @Test(expected = UnableToInvokeWhenPageOpensMethods.class)
  public void annotated_OnOpenPage_methods_cannot_have_parameters() {
    PageObject page = new PageObjectWithOnOpenPageMethodWithParameters(webdriver);
    PageUrls pageUrls = new PageUrls(page, configuration);
    page.setPageUrls(pageUrls);

    environmentVariables.setProperty("webdriver.base.url", "http://staging.myapp.org");
    page.open();
  }
コード例 #2
0
  @Test
  public void the_webdriver_base_url_should_conserve_trailing_slashes() {
    PageObject page = new PageObjectWithAURrlWithATrainingSlash(webdriver);
    PageUrls pageUrls = new PageUrls(page, configuration);
    page.setPageUrls(pageUrls);
    page.open();

    verify(webdriver).get("http://test.myapp.org/somepage/");
  }
コード例 #3
0
  @Test
  public void the_url_annotation_should_determine_where_the_page_will_open_to() {
    PageObject page = new PageObjectWithFullUrlDefinition(webdriver);
    PageUrls pageUrls = new PageUrls(page, configuration);
    page.setPageUrls(pageUrls);

    page.open();

    verify(webdriver).get("http://www.apache.org");
  }
コード例 #4
0
  @Test
  public void the_url_annotation_should_let_you_define_a_named_parameterized_url() {
    PageObject page = new PageObjectWithNamedParameterizedUrlDefinition(webdriver);
    PageUrls pageUrls = new PageUrls(page, configuration);
    page.setPageUrls(pageUrls);

    page.open("open.issue", withParameters("ISSUE-1"));

    verify(webdriver).get("http://jira.mycompany.org/issues/ISSUE-1");
  }
コード例 #5
0
  @Test(expected = IllegalArgumentException.class)
  public void the_url_annotation_should_throw_an_exception_if_no_named_url_is_found() {
    PageObject page = new PageObjectWithMultipleNamedUrlDefinitions(webdriver);
    PageUrls pageUrls = new PageUrls(page, configuration);
    page.setPageUrls(pageUrls);

    configuration.setDefaultBaseUrl("http://myapp.mycompany.com");

    page.open("no.such.template", withParameters("ISSUE-1"));
  }
コード例 #6
0
  @Test
  public void the_base_url_should_be_used_if_no_url_annotation_is_present() {
    PageObject page = new PageObjectWithNoUrlDefinition(webdriver);
    configuration.setDefaultBaseUrl("http://www.google.com");
    PageUrls pageUrls = new PageUrls(page, configuration);
    page.setPageUrls(pageUrls);

    page.open();

    verify(webdriver).get("http://www.google.com");
  }
コード例 #7
0
  @Test
  public void the_base_url_is_overrided_by_the_webdriver_base_url_system_property() {
    PageObject page = new PageObjectWithFullUrlDefinition(webdriver);
    PageUrls pageUrls = new PageUrls(page, configuration);
    page.setPageUrls(pageUrls);

    environmentVariables.setProperty("webdriver.base.url", "http://www.wikipedia.org");
    page.open();

    verify(webdriver).get("http://www.wikipedia.org");
  }
コード例 #8
0
  @Test
  public void the_webdriver_base_url_system_property_should_override_ports() {
    PageObject page = new PageObjectWithFullUrlAndPageAndPortDefinition(webdriver);
    PageUrls pageUrls = new PageUrls(page, configuration);
    page.setPageUrls(pageUrls);

    environmentVariables.setProperty("webdriver.base.url", "https://staging.myapp.org:8888");
    page.open();

    verify(webdriver).get("https://staging.myapp.org:8888/somepage");
  }
コード例 #9
0
  @Test
  public void the_url_should_use_the_annotation_url_if_the_base_url_is_empty() {
    PageObject page = new PageObjectWithHashNotation(webdriver);
    PageUrls pageUrls = new PageUrls(page, configuration);
    page.setPageUrls(pageUrls);

    environmentVariables.setProperty("webdriver.base.url", "");
    page.open();

    verify(webdriver).get("http://some.user.application.com/#Showcase");
  }
コード例 #10
0
  @Test
  public void the_url_should_use_the_annotation_url_if_the_base_url_is_not_defined() {
    PageObject page = new PageObjectWithHashNotation(webdriver);
    PageUrls pageUrls = new PageUrls(page, configuration);
    page.setPageUrls(pageUrls);

    System.clearProperty("webdriver.base.url");
    page.open();

    verify(webdriver).get("http://some.user.application.com/#Showcase");
  }
コード例 #11
0
  @Test
  public void the_url_notation_should_work_with_hashes() {
    PageObject page = new PageObjectWithHashNotation(webdriver);
    PageUrls pageUrls = new PageUrls(page, configuration);
    page.setPageUrls(pageUrls);

    environmentVariables.setProperty("webdriver.base.url", "http://my.application.com");
    page.open();

    verify(webdriver).get("http://my.application.com/#Showcase");
  }
コード例 #12
0
  @Test
  public void should_not_override_base_url_if_empty_string() {
    PageObject page = new PageObjectWithLongDefaultUrl(webdriver);
    PageUrls pageUrls = new PageUrls(page, configuration);
    page.setPageUrls(pageUrls);

    environmentVariables.setProperty("webdriver.base.url", "");
    page.open();

    verify(webdriver).get("http://localhost:8080/myapp/somepage");
  }
コード例 #13
0
  @Test
  public void overriding_base_urls_should_allow_for_trailing_slashes() {
    PageObject page = new PageObjectWithLongDefaultUrl(webdriver);
    PageUrls pageUrls = new PageUrls(page, configuration);
    page.setPageUrls(pageUrls);

    environmentVariables.setProperty("webdriver.base.url", "http://prod.server/");
    page.open();

    verify(webdriver).get("http://prod.server/myapp/somepage");
  }
コード例 #14
0
  @Test
  public void the_webdriver_base_url_system_property_should_not_override_pages_with_parameters() {
    PageObject page =
        new PageObjectWithDefaultUrlAndNamedParameterizedRelativeUrlDefinition(webdriver);
    PageUrls pageUrls = new PageUrls(page, configuration);
    page.setPageUrls(pageUrls);

    environmentVariables.setProperty("webdriver.base.url", "http://staging.mycompany.org");
    page.open("open.issue", withParameters("ISSUE-1"));

    verify(webdriver).get("http://staging.mycompany.org/issues/ISSUE-1");
  }
コード例 #15
0
  @Test
  public void the_webdriver_base_url_system_property_should_include_full_path() {
    PageObject page = new PageObjectWithFullUrlAndPageDefinition(webdriver);
    PageUrls pageUrls = new PageUrls(page, configuration);
    page.setPageUrls(pageUrls);

    environmentVariables.setProperty(
        "webdriver.base.url", "http://staging.myapp.org/myapp-staging");
    page.open();

    verify(webdriver).get("http://staging.myapp.org/myapp-staging/somepage");
  }
コード例 #16
0
  @Test
  public void the_url_annotation_can_be_relative_to_the_base_url_with_a_trailing_slash() {
    PageObject page = new PageObjectWithRelativeUrlDefinitionAndATrailingSlash(webdriver);
    PageUrls pageUrls = new PageUrls(page, configuration);
    page.setPageUrls(pageUrls);

    configuration.setDefaultBaseUrl("http://myapp.mycompany.com");

    page.open();

    verify(webdriver).get("http://myapp.mycompany.com/clients/");
  }
コード例 #17
0
  @Test
  public void the_url_annotation_should_let_you_define_several_named_parameterized_urls() {
    PageObject page = new PageObjectWithMultipleNamedUrlDefinitions(webdriver);
    PageUrls pageUrls = new PageUrls(page, configuration);
    page.setPageUrls(pageUrls);

    configuration.setDefaultBaseUrl("http://myapp.mycompany.com");

    page.open("close.issue", withParameters("ISSUE-1"));

    verify(webdriver).get("http://myapp.mycompany.com/issues/close/ISSUE-1");
  }