Class PageObject
- java.lang.Object
-
- org.jenkinsci.test.acceptance.po.CapybaraPortingLayerImpl
-
- org.jenkinsci.test.acceptance.po.PageObject
-
- All Implemented Interfaces:
CapybaraPortingLayer
- Direct Known Subclasses:
Action
,Artifact
,BuildHistory
,BuildWithParameters
,Changes
,ConfigFileProvider
,ConfigurablePageObject
,DiskUsage
,GerritTriggerJob
,GerritTriggerNewServer
,GerritTriggerServer
,JcascManage
,JenkinsDatabaseSecurityRealm.Signup
,JenkinsLogger
,JobConfigHistory.Change
,Login
,Logout
,LogParserOutputPage
,ProvidedFile
,ScriptApproval
,SecurityDisabler
,SubversionSvmAdvanced
,SvnRepositoryBrowser
,WizardCreateAdminUser
,WizardCustomizeJenkins
,WizardLogin
,Workspace
public abstract class PageObject extends CapybaraPortingLayerImpl
Encapsulates a model in Jenkins and wraps interactions with it.See ...
Most non-trivial page objects should derive from
ContainerPageObject
.- Author:
- Kohsuke Kawaguchi
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.jenkinsci.test.acceptance.po.CapybaraPortingLayerImpl
CapybaraPortingLayerImpl.Finder<R>, CapybaraPortingLayerImpl.Resolver
-
-
Field Summary
Fields Modifier and Type Field Description protected com.fasterxml.jackson.databind.ObjectMapper
jsonParser
URL
url
Full URL of the object that this page object represents.-
Fields inherited from class org.jenkinsci.test.acceptance.po.CapybaraPortingLayerImpl
driver, injector, LABEL_TO_INPUT_XPATH, time
-
Fields inherited from interface org.jenkinsci.test.acceptance.po.CapybaraPortingLayer
by
-
-
Constructor Summary
Constructors Modifier Constructor Description PageObject(com.google.inject.Injector injector, URL url)
protected
PageObject(PageObject context, URL url)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Control
control(String... relativePaths)
Create a control object that wraps access to the specific INPUT element in this page area.Control
control(org.openqa.selenium.By selector)
String
createPageArea(String pathPrefix, Runnable action)
Capture path attribute of newly created form chunk upon invoking action.static String
createRandomName()
protected PageObject
getContext()
Jenkins
getJenkins()
org.openqa.selenium.WebDriver
open()
Visits the top page of this object.String
toString()
URL
url(String rel)
Resolves relative path againsturl
and treats any exception a a fatal problem.URL
url(String format, Object... args)
void
visit(String relativePath)
Given the path relative tourl
, visit that page-
Methods inherited from class org.jenkinsci.test.acceptance.po.CapybaraPortingLayerImpl
all, blur, check, check, check, choose, clickButton, clickLink, confirmAlert, elasticSleep, executeScript, fillIn, find, findCaption, findCaption, findIfNotVisible, getCurrentUrl, getCurrentUrlWithFragment, getElement, getPageContent, getPageSource, getPageSource, getPath, handleAlert, isStale, last, lastIfNotVisible, newInstance, resource, runThenConfirmAlert, runThenConfirmAlert, runThenHandleAlert, runThenHandleAlert, sleep, visit, waitFor, waitFor, waitFor, waitFor, waitFor, waitForCond, waitForCond
-
-
-
-
Field Detail
-
jsonParser
@Inject protected com.fasterxml.jackson.databind.ObjectMapper jsonParser
-
url
public final URL url
Full URL of the object that this page object represents. Ends with '/', like "http://localhost:8080/job/foo/"
-
-
Constructor Detail
-
PageObject
public PageObject(com.google.inject.Injector injector, URL url)
-
PageObject
protected PageObject(PageObject context, URL url)
-
-
Method Detail
-
createRandomName
public static String createRandomName()
-
getJenkins
public Jenkins getJenkins()
-
open
public org.openqa.selenium.WebDriver open()
Visits the top page of this object.
-
url
public URL url(String rel)
Resolves relative path againsturl
and treats any exception a a fatal problem.
-
control
public Control control(String... relativePaths)
Create a control object that wraps access to the specific INPUT element in this page area.The
Control
object itself can be created early as the actual element resolution happens lazily. This meansPageAreaImpl
implementations can put these in their fields.Several paths can be provided to find the first matching element. Useful when element path changed between versions.
-
control
public Control control(org.openqa.selenium.By selector)
-
createPageArea
@NonNull public String createPageArea(String pathPrefix, Runnable action) throws org.openqa.selenium.TimeoutException
Capture path attribute of newly created form chunk upon invoking action.Consider "Add" button in page area with path "/foo" that is supposed to create new page area with path "/foo/bar" or "/foo/bar[n]". There are several problems with the straightforward approach: - Created area may or may not be the first one of its kind so figuring the "path" is nontrivial. - The area may can take a while to render so waiting is needed. - Even after the markup appears, it can take a while for "path" attribute is added.
This method properly wait until the new path is known. To be used as:
String barPath = fooArea.createPageArea("/bar", () -> control("add-button").click()); new FooBarArea(fooArea, barPath);
- Parameters:
pathPrefix
- Prefix of the expected path. The path is always absolute.action
- An action that triggers the page area creation. Clicking the button, etc.- Returns:
- The surrounding path of the area, exception thrown when not able to find out.
- Throws:
org.openqa.selenium.TimeoutException
-
getContext
protected PageObject getContext()
-
-