org.specrunner.webdriver.assertions
Class PluginCompareUtils

java.lang.Object
  extended by org.specrunner.webdriver.assertions.PluginCompareUtils

public final class PluginCompareUtils
extends Object

Comparison utilities.

Author:
Thiago Santos

Method Summary
protected static void addError(String expected, String received, IBlock block, IContext context, IResultSet result, org.openqa.selenium.WebDriver client)
          Add error to result.
static boolean compare(String expected, String received, IBlock block, IContext context, IResultSet result, org.openqa.selenium.WebDriver client)
          Compare two strings.
static boolean compareDate(PluginCompareDate compare, String expected, String received, IBlock block, IContext context, IResultSet result, org.openqa.selenium.WebDriver client)
          Perform date comparisons.
protected static int compareElements(PluginCompareNode compare, IContext context, IResultSet result, nu.xom.Element e, org.openqa.selenium.WebElement we, int errors)
          Compare two elements and return the number of errors in comparison.
static boolean compareNode(PluginCompareNode compare, nu.xom.Element expected, org.openqa.selenium.WebElement received, IBlock block, IContext context, IResultSet result, org.openqa.selenium.WebDriver client)
          Compare two nodes.
protected static int compareTexts(PluginCompareNode compare, IContext context, IResultSet result, nu.xom.Element expected, org.openqa.selenium.WebElement received, int errors)
          Compare two nodes by theirs texts.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

compare

public static boolean compare(String expected,
                              String received,
                              IBlock block,
                              IContext context,
                              IResultSet result,
                              org.openqa.selenium.WebDriver client)
                       throws PluginException
Compare two strings.

Parameters:
expected - The expected value.
received - The received value.
block - The block.
context - The context.
result - The result set.
client - The web driver.
Returns:
true, if equals, false, otherwise.
Throws:
PluginException - On comparison errors.

addError

protected static void addError(String expected,
                               String received,
                               IBlock block,
                               IContext context,
                               IResultSet result,
                               org.openqa.selenium.WebDriver client)
                        throws PluginException
Add error to result.

Parameters:
expected - The expected value.
received - The received value.
block - The block.
context - The context.
result - The result set.
client - The web driver.
Throws:
PluginException - On errors.

compareDate

public static boolean compareDate(PluginCompareDate compare,
                                  String expected,
                                  String received,
                                  IBlock block,
                                  IContext context,
                                  IResultSet result,
                                  org.openqa.selenium.WebDriver client)
                           throws PluginException
Perform date comparisons.

Parameters:
compare - The plugin which hold format and tolerance information.
expected - The expected value.
received - The received value.
block - The block.
context - The context.
result - The result set.
client - The web driver.
Returns:
true, of equals considering tolerance, false, otherwise.
Throws:
PluginException - On comparison errors.

compareNode

public static boolean compareNode(PluginCompareNode compare,
                                  nu.xom.Element expected,
                                  org.openqa.selenium.WebElement received,
                                  IBlock block,
                                  IContext context,
                                  IResultSet result,
                                  org.openqa.selenium.WebDriver client)
Compare two nodes. The expected node can have less attributes than received content, this is due to WebDriver API which does not provide much reflection on WebElements.

Parameters:
compare - The compare plugin.
expected - The expected content.
received - The received content.
block - The context block.
context - The context.
result - The result information.
client - The WebDriver client.
Returns:
true, if can be considered equals, false, otherwise.

compareTexts

protected static int compareTexts(PluginCompareNode compare,
                                  IContext context,
                                  IResultSet result,
                                  nu.xom.Element expected,
                                  org.openqa.selenium.WebElement received,
                                  int errors)
Compare two nodes by theirs texts.

Parameters:
compare - The plugin.
context - The context.
result - The result set.
expected - The expected content.
received - The received content.
errors - The errors count.
Returns:
The errors count adjusted.

compareElements

protected static int compareElements(PluginCompareNode compare,
                                     IContext context,
                                     IResultSet result,
                                     nu.xom.Element e,
                                     org.openqa.selenium.WebElement we,
                                     int errors)
Compare two elements and return the number of errors in comparison.

Parameters:
compare - The compare plugin.
context - The context.
result - The result.
e - The expected content.
we - The received content.
errors - The errors count.
Returns:
The errors count adjusted.


Copyright © 2013. All rights reserved.