001/* 002 Licensed to the Apache Software Foundation (ASF) under one 003 or more contributor license agreements. See the NOTICE file 004 distributed with this work for additional information 005 regarding copyright ownership. The ASF licenses this file 006 to you under the Apache License, Version 2.0 (the 007 "License"); you may not use this file except in compliance 008 with the License. You may obtain a copy of the License at 009 010 http://www.apache.org/licenses/LICENSE-2.0 011 012 Unless required by applicable law or agreed to in writing, 013 software distributed under the License is distributed on an 014 "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 015 KIND, either express or implied. See the License for the 016 specific language governing permissions and limitations 017 under the License. 018 */ 019package org.apache.wiki.pages; 020 021import java.io.File; 022import java.io.IOException; 023 024import org.apache.wiki.its.environment.Env; 025 026import com.codeborne.selenide.Selenide; 027import com.codeborne.selenide.WebDriverRunner; 028 029 030/** 031 * Common operations for Page Objects. 032 * 033 * @see https://selenide.gitbooks.io/user-guide/content/en/pageobjects.html 034 */ 035public interface Page { 036 037 /** 038 * Creates a new {@link PageBuilder} in order to customize page creation. 039 * 040 * @param url url to open in the browser. 041 * @return {@link PageBuilder} instance to allow page creation customization. 042 */ 043 static PageBuilder withUrl( final String url ) { 044 return new PageBuilder( url, null ); 045 } 046 047 /** 048 * returns the base URL on which the tests are run. 049 * 050 * @return the base URL on which the tests are run. 051 */ 052 static String baseUrl() { 053 return Env.TESTS_BASE_URL; 054 } 055 056 static File download( String url ) throws IOException { 057 return Selenide.download( url ); 058 } 059 060 /** 061 * returns the actual page title. 062 * 063 * @return the actual page title. 064 */ 065 default String title() { 066 return Selenide.title(); 067 } 068 069 /** 070 * returns the actual URL. 071 * 072 * @return the actual URL. 073 */ 074 default String url() { 075 return WebDriverRunner.url(); 076 } 077 078 /** 079 * returns page's wiki title. 080 * 081 * @return page's wiki title. 082 */ 083 String wikiTitle(); 084 085 /** 086 * returns page's wiki content. 087 * 088 * @return page's wiki content. 089 */ 090 String wikiPageContent(); 091 092}