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 org.apache.wiki.its.environment.Env; 022 023import com.codeborne.selenide.Configuration; 024import com.codeborne.selenide.Selenide; 025 026 027/** 028 * Builder for {@link Page} Objects. 029 */ 030public class PageBuilder { 031 032 String url; 033 Page page; 034 035 PageBuilder( final String url, final Page page ) { 036 this.url = url; 037 this.page = page; 038 } 039 040 /** 041 * Sets up Selenide and opens the requested URL, allowing chaining additional operations over the given {@link Page} instance. 042 * 043 * @param cls {@link Page} instance, in order to allow chaining operations. 044 * @return {@link Page} instance given on the {@link PageBuilder} constructor. 045 */ 046 public < T extends Page > T openAs( final T page ) { 047 Configuration.headless = Env.TESTS_CONFIG_HEADLESS; 048 Configuration.reportsFolder = Env.TESTS_CONFIG_REPORTS_FOLDER; 049 Configuration.startMaximized = Env.TESTS_CONFIG_START_MAXIMIZED; 050 System.setProperty( "wdm.targetPath", Env.TESTS_CONFIG_WDM_TARGET_PATH ); 051 052 Selenide.open( url ); 053 return page; 054 } 055 056}