com.vaadin.testbench.commands.
Class TestBenchCommandExecutor
All Implemented Interfaces:
Provides actual implementation of TestBenchCommands
-
Constructor Summary
ConstructorsConstructorDescriptionTestBenchCommandExecutor
(ImageComparison imageComparison, ReferenceNameGenerator referenceNameGenerator) -
Method Summary
Modifier and TypeMethodDescriptionboolean
compareScreen
(BufferedImage reference, String referenceName) Tests that a screen shot is equal to the specified reference image.
boolean
compareScreen
(File reference) Tests that a screen shot is equal to the specified reference image.
boolean
compareScreen
(String referenceId) Tests that a screen shot is equal to the specified reference image.
void
Disables implicit waiting for Vaadin to finish processing requests.
void
Enables implicit waiting for Vaadin to finish processing requests.
protected Object
executeAsyncScript
(String script, Object... args) executeScript
(String script, Object... args) void
focusElement
(TestBenchElement testBenchElement) Return a reference to the
WebDriver
instance associated with thisTestBenchCommandExecutor
Gets the image comparison implementation used for screenshots.
Gets the name generator used for screenshot references.
Finds the canonical host name of the remotely executing node where the test is being run.
boolean
Whether or not the elements should be scrolled into the visible area of the browser window before interacting with them
void
resizeViewPortTo
(int desiredWidth, int desiredHeight) Tries to resize the browsers window so that the space available for actual web content (aka viewport) is of given size.
void
setAutoScrollIntoView
(boolean autoScrollIntoView) Sets if the elements should be scrolled into the visible area of the browser window before interacting with them
void
setDriver
(TestBenchDriverProxy driver) long
This method provides performance information of the client-side rendering for the last operation performed.
long
This method provides performance information of the server-side processing for the last request.
long
This method provides performance information of the client-side rendering for the entire session.
long
This method provides performance information of the server-side processing for the entire session.
void
Block until Vaadin reports it has finished processing server messages.
-
Constructor Details
-
TestBenchCommandExecutor
public TestBenchCommandExecutor(ImageComparison imageComparison, ReferenceNameGenerator referenceNameGenerator)
-
-
Method Details
-
setDriver
-
getRemoteControlName
Description copied from interface:
TestBenchCommands
Finds the canonical host name of the remotely executing node where the test is being run. This is useful for failure reporting when running on large grids where one machine may start having problems and you need to find out which of the machines it is.
Specified by:
getRemoteControlName
in interfaceTestBenchCommands
Returns:
the canonical host name along with it's IP as a string.
-
waitForVaadin
public void waitForVaadin()Block until Vaadin reports it has finished processing server messages.
-
compareScreen
Description copied from interface:
CanCompareScreenshots
Tests that a screen shot is equal to the specified reference image. The comparison tolerance can be specified by setting the com.vaadin.testbench.block.error system property to a value between 0 and 1, where 0 == no changes are accepted and 1 == big changes are accepted. Note that specifying 1 doesn't mean that any reference image is accepted.
Specified by:
compareScreen
in interfaceCanCompareScreenshots
Parameters:
referenceId
- the ID of the reference imageReturns:
true if the screenshot is considered equal to the reference image, false otherwise.
Throws:
IOException
- if there was a problem accessing the reference image -
compareScreen
Description copied from interface:
CanCompareScreenshots
Tests that a screen shot is equal to the specified reference image. The comparison tolerance can be specified by setting the com.vaadin.testbench.block.error system property to a value between 0 and 1, where 0 == no changes are accepted and 1 == all changes are accepted.
Specified by:
compareScreen
in interfaceCanCompareScreenshots
Parameters:
reference
- the reference image fileReturns:
true if the screenshot is considered equal to the reference image, false otherwise.
Throws:
IOException
- if there was a problem accessing the reference image -
compareScreen
Description copied from interface:
CanCompareScreenshots
Tests that a screen shot is equal to the specified reference image. The comparison tolerance can be specified by setting the com.vaadin.testbench.block.error system property to a value between 0 and 1, where 0 == no changes are accepted and 1 == all changes are accepted.
Specified by:
compareScreen
in interfaceCanCompareScreenshots
Parameters:
reference
- the reference imagereferenceName
- the filename of the reference image. Used when writing the error files.Returns:
true if the screenshot is considered equal to the reference image, false otherwise.
Throws:
IOException
- if there was a problem accessing the reference image -
timeSpentRenderingLastRequest
public long timeSpentRenderingLastRequest()Description copied from interface:
TestBenchCommands
This method provides performance information of the client-side rendering for the last operation performed. You can use this information to make sure that some operation is executed in a timely fashion. If more than one application is running at the same URL, e.g. a portal environment with many portlets on the same page, the value returned will be the sum for all applications. Note! This method needs to be called before
TestBenchCommands.timeSpentRenderingLastRequest()
orTestBenchCommands.totalTimeSpentServicingRequests()
, since they will perform an extra request, causing the value returned from this method to be that for an empty request/response.Specified by:
timeSpentRenderingLastRequest
in interfaceTestBenchCommands
Returns:
the time spent rendering the last request.
-
totalTimeSpentRendering
public long totalTimeSpentRendering()Description copied from interface:
TestBenchCommands
This method provides performance information of the client-side rendering for the entire session. The session starts when you navigate to an application and this method returns the amount of time spent rendering up to the point of the call. If more than one application is running at the same URL, e.g. a portal environment with many portlets on the same page, the value returned will be the sum for all applications.
Specified by:
totalTimeSpentRendering
in interfaceTestBenchCommands
Returns:
the total time spent rendering in this session.
-
timeSpentServicingLastRequest
public long timeSpentServicingLastRequest()Description copied from interface:
TestBenchCommands
This method provides performance information of the server-side processing for the last request. You can use this information to ensure that an operation is processed in a timely fashion. If more than one application is running at the same URL, e.g. a portal environment with many portlets on the same page, the value returned will be the sum for all applications. Note! If you are interested in the client-side performance for the last request, you must call
TestBenchCommands.timeSpentRenderingLastRequest()
before calling this method. This is due to the fact that this method causes an extra server round-trip, which will cause an empty response to be rendered.Specified by:
timeSpentServicingLastRequest
in interfaceTestBenchCommands
Returns:
the time spent servicing the last request on the server.
-
totalTimeSpentServicingRequests
public long totalTimeSpentServicingRequests()Description copied from interface:
TestBenchCommands
This method provides performance information of the server-side processing for the entire session. The session starts when you navigate to an application and this method returns the amount of time spent processing requests up to the point of the call. If more than one application is running at the same URL, e.g. a portal environment with many portlets on the same page, the value returned will be the sum for all applications. Note! If you are interested in the client-side performance for the last request, you must call
TestBenchCommands.timeSpentRenderingLastRequest()
before calling this method. This is due to the fact that this method causes an extra server round-trip, which will cause an empty response to be rendered.Specified by:
totalTimeSpentServicingRequests
in interfaceTestBenchCommands
Returns:
the total time spent servicing requests in this session.
-
disableWaitForVaadin
public void disableWaitForVaadin()Description copied from interface:
TestBenchCommands
Disables implicit waiting for Vaadin to finish processing requests. This is useful if you need to test bombarding an application with events. Implicit waiting is enabled by default.
Specified by:
disableWaitForVaadin
in interfaceTestBenchCommands
-
enableWaitForVaadin
public void enableWaitForVaadin()Description copied from interface:
TestBenchCommands
Enables implicit waiting for Vaadin to finish processing requests. Implicit waiting is enabled by default.
Specified by:
enableWaitForVaadin
in interfaceTestBenchCommands
-
isAutoScrollIntoView
public boolean isAutoScrollIntoView()Whether or not the elements should be scrolled into the visible area of the browser window before interacting with them. The default is
true
Specified by:
isAutoScrollIntoView
in interfaceTestBenchCommands
Returns:
true if elements should be scrolled, otherwise false
-
setAutoScrollIntoView
public void setAutoScrollIntoView(boolean autoScrollIntoView) Sets if the elements should be scrolled into the visible area of the browser window before interacting with them
Specified by:
setAutoScrollIntoView
in interfaceTestBenchCommands
Parameters:
autoScrollIntoView
-true
if elements should be scrolled -
executeScript
-
executeAsyncScript
-
getDriver
Return a reference to the
WebDriver
instance associated with thisTestBenchCommandExecutor
-
resizeViewPortTo
public void resizeViewPortTo(int desiredWidth, int desiredHeight) throws UnsupportedOperationException Description copied from interface:
TestBenchCommands
Tries to resize the browsers window so that the space available for actual web content (aka viewport) is of given size.
Note, that the result cannot be guaranteed on all platforms. For example browsers in mobile devices are most often always fullscreen and their viewport can be "simultated". Also browsers might not allow resizing the window or limit size of window to minimum or maximum (often limited by screen size). Currently most common desktop browsers support this.
Specified by:
resizeViewPortTo
in interfaceTestBenchCommands
Parameters:
desiredWidth
- the desired width of the viewportdesiredHeight
- the desired height of the viewportThrows:
-
focusElement
-
getReferenceNameGenerator
Gets the name generator used for screenshot references.
Returns:
the name generator for screenshot references
-
getImageComparison
Gets the image comparison implementation used for screenshots.
Returns:
the image comparison implementation
-