com.atlassian.selenium
Class SeleniumAssertions

java.lang.Object
  extended by com.atlassian.selenium.SeleniumAssertions

public class SeleniumAssertions
extends Object

This provides helper methods for selenium assertions. This mostly means waiting for events to occur (i.e. a dropdown to appear after a certain timeout, etc)


Constructor Summary
SeleniumAssertions(com.thoughtworks.selenium.Selenium client, SeleniumConfiguration config)
          Temporarily bring back the old constructor so that some older codes compile.
SeleniumAssertions(com.thoughtworks.selenium.Selenium client, SeleniumConfiguration config, TimeRecorder recorder)
           
 
Method Summary
 void attributeContainsValue(PageElement element, String attribute, String value)
           
 void attributeContainsValue(String locator, String attribute, String value)
          Asserts that the element given by the locator has an attribute which contains the required value.
 void attributeDoesntContainValue(PageElement element, String attribute, String value)
           
 void attributeDoesntContainValue(String locator, String attribute, String value)
          Asserts that the element given by the locator has an attribute which does not contain the given value.
 void byTimeout(ByTimeoutConfiguration config)
           
 void byTimeout(Condition condition)
           
 void byTimeout(Condition condition, long maxWaitTime)
           
 void elementContainsText(PageElement element, String text)
           
 void elementContainsText(String locator, String text)
          Asserts that an element contains the given text.
 void elementDoesNotContainText(PageElement element, String text)
           
 void elementDoesNotContainText(String locator, String text)
          Asserts that an element does not contain the given text.
 void elementDoesntHaveText(PageElement element, String text)
           
 void elementDoesntHaveText(String locator, String text)
          Asserts that the element specified by the locator does not contain the specified text
 void elementHasText(PageElement element, String text)
           
 void elementHasText(String locator, String text)
          Asserts that the element specified by the locator contains the specified text
 void elementNotPresent(PageElement element)
           
 void elementNotPresent(String locator)
          Asserts that a given element is not present on the current page
 void elementNotPresentByTimeout(PageElement element)
           
 void elementNotPresentByTimeout(PageElement element, long maxMillis)
           
 void elementNotPresentByTimeout(String locator)
           
 void elementNotPresentByTimeout(String locator, long maxMillis)
          This will wait until an element is not present.
 void elementNotPresentUntilTimeout(PageElement element)
           
 void elementNotPresentUntilTimeout(PageElement element, long maxMillis)
           
 void elementNotPresentUntilTimeout(String locator)
           
 void elementNotPresentUntilTimeout(String locator, long maxMillis)
           
 void elementNotVisible(PageElement element)
           
 void elementNotVisible(String locator)
          Asserts that a given element is not present and visible.
 void elementPresent(PageElement element)
           
 void elementPresent(String locator)
          Asserts that a given element is present
 void elementPresentByTimeout(PageElement element)
           
 void elementPresentByTimeout(PageElement element, long maxMillis)
           
 void elementPresentByTimeout(String locator)
           
 void elementPresentByTimeout(String locator, long maxMillis)
           
 void elementPresentUntilTimeout(PageElement element)
           
 void elementPresentUntilTimeout(PageElement element, long maxMillis)
           
 void elementPresentUntilTimeout(String locator)
           
 void elementPresentUntilTimeout(String locator, long maxMillis)
           
 void elementsSameHeight(PageElement element1, PageElement element2, int deltaPixels)
           
 void elementsSameHeight(String locator1, String locator2, int deltaPixels)
           
 void elementsVerticallyAligned(PageElement element1, PageElement element2, int deltaPixels)
           
 void elementsVerticallyAligned(String locator1, String locator2, int deltaPixels)
          Asserts that two elements (located by selenium syntax) are vertically within deltaPixels of each other.
 void elementVisible(PageElement element)
           
 void elementVisible(String locator)
          Asserts that a given element is present and is visible.
 void elementVisibleContainsText(PageElement element, String text)
           
 void elementVisibleContainsText(String locator, String text)
          Asserts that a given element is visible and also contains the given text.
 void formElementEquals(String locator, String value)
          Asserts that a given element has a specified value
 ByTimeoutConfiguration generateByTimeoutConfig(Condition condition, PageElement elem, long maxWait)
           
 ByTimeoutConfiguration generateByTimeoutConfig(Condition condition, String locator, long maxWait)
           
 void htmlNotPresent(String html)
          Asserts that a particular piece of HTML is not present in the HTML source.
 void htmlPresent(String html)
          Asserts that a particular piece of HTML is present in the HTML source.
 void linkNotPresentWithText(String text)
          Asserts that no link exists on the page containing the given text
 void linkPresentWithText(String text)
          Asserts that a link containing the given text appears on the page
 void linkVisibleWithText(String text)
          Asserts that a link containin the given text is present and visible.
 void notVisibleByTimeout(PageElement element)
           
 void notVisibleByTimeout(PageElement element, long maxMillis)
           
 void notVisibleByTimeout(String locator)
           
 void notVisibleByTimeout(String locator, long maxMillis)
           
 void textNotPresent(String text)
           
 void textNotPresentByTimeout(String text)
           
 void textNotPresentByTimeout(String text, long maxMillis)
           
 void textPresent(String text)
           
 void textPresentByTimeout(String text)
           
 void textPresentByTimeout(String text, long maxMillis)
           
 void untilTimeout(Condition condition)
           
 void untilTimeout(Condition condition, long maxWaitTime)
           
 void visibleByTimeout(PageElement element)
           
 void visibleByTimeout(PageElement element, long maxMillis)
           
 void visibleByTimeout(String locator)
           
 void visibleByTimeout(String locator, long maxMillis)
          This will wait until an element is visible.
 void windowClosed(String windowName)
           
 void windowOpen(String windowName)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SeleniumAssertions

public SeleniumAssertions(com.thoughtworks.selenium.Selenium client,
                          SeleniumConfiguration config,
                          TimeRecorder recorder)

SeleniumAssertions

public SeleniumAssertions(com.thoughtworks.selenium.Selenium client,
                          SeleniumConfiguration config)
Temporarily bring back the old constructor so that some older codes compile.

Method Detail

generateByTimeoutConfig

public ByTimeoutConfiguration generateByTimeoutConfig(Condition condition,
                                                      String locator,
                                                      long maxWait)

generateByTimeoutConfig

public ByTimeoutConfiguration generateByTimeoutConfig(Condition condition,
                                                      PageElement elem,
                                                      long maxWait)

visibleByTimeout

public void visibleByTimeout(String locator)

visibleByTimeout

public void visibleByTimeout(PageElement element)

visibleByTimeout

public void visibleByTimeout(String locator,
                             long maxMillis)
This will wait until an element is visible. If it doesnt become visible in maxMillis fail.

Parameters:
locator - the selenium element locator
maxMillis - how long to wait as most in milliseconds

visibleByTimeout

public void visibleByTimeout(PageElement element,
                             long maxMillis)

notVisibleByTimeout

public void notVisibleByTimeout(String locator)

notVisibleByTimeout

public void notVisibleByTimeout(PageElement element)

notVisibleByTimeout

public void notVisibleByTimeout(String locator,
                                long maxMillis)

notVisibleByTimeout

public void notVisibleByTimeout(PageElement element,
                                long maxMillis)

elementPresentByTimeout

public void elementPresentByTimeout(String locator)

elementPresentByTimeout

public void elementPresentByTimeout(PageElement element)

elementPresentByTimeout

public void elementPresentByTimeout(String locator,
                                    long maxMillis)

elementPresentByTimeout

public void elementPresentByTimeout(PageElement element,
                                    long maxMillis)

elementPresentUntilTimeout

public void elementPresentUntilTimeout(String locator)

elementPresentUntilTimeout

public void elementPresentUntilTimeout(PageElement element)

elementPresentUntilTimeout

public void elementPresentUntilTimeout(String locator,
                                       long maxMillis)

elementPresentUntilTimeout

public void elementPresentUntilTimeout(PageElement element,
                                       long maxMillis)

elementNotPresentByTimeout

public void elementNotPresentByTimeout(String locator)

elementNotPresentByTimeout

public void elementNotPresentByTimeout(PageElement element)

elementNotPresentUntilTimeout

public void elementNotPresentUntilTimeout(String locator)

elementNotPresentUntilTimeout

public void elementNotPresentUntilTimeout(PageElement element)

elementNotPresentUntilTimeout

public void elementNotPresentUntilTimeout(String locator,
                                          long maxMillis)

elementNotPresentUntilTimeout

public void elementNotPresentUntilTimeout(PageElement element,
                                          long maxMillis)

textPresentByTimeout

public void textPresentByTimeout(String text,
                                 long maxMillis)

textPresentByTimeout

public void textPresentByTimeout(String text)

textNotPresentByTimeout

public void textNotPresentByTimeout(String text,
                                    long maxMillis)

textNotPresentByTimeout

public void textNotPresentByTimeout(String text)

elementNotPresentByTimeout

public void elementNotPresentByTimeout(String locator,
                                       long maxMillis)
This will wait until an element is not present. If it doesnt become not present in maxMillis

Parameters:
locator - the selenium element locator
maxMillis - how long to wait as most in milliseconds

elementNotPresentByTimeout

public void elementNotPresentByTimeout(PageElement element,
                                       long maxMillis)

byTimeout

public void byTimeout(Condition condition)

byTimeout

public void byTimeout(Condition condition,
                      long maxWaitTime)

byTimeout

public void byTimeout(ByTimeoutConfiguration config)

untilTimeout

public void untilTimeout(Condition condition)

untilTimeout

public void untilTimeout(Condition condition,
                         long maxWaitTime)

textPresent

public void textPresent(String text)
Parameters:
text - Asserts that text is present in the current page

textNotPresent

public void textNotPresent(String text)
Parameters:
text - Asserts that text is not present in the current page

formElementEquals

public void formElementEquals(String locator,
                              String value)
Asserts that a given element has a specified value

Parameters:
locator - Locator for element using the standard selenium locator syntax
value - The value the element is expected to contain

elementPresent

public void elementPresent(String locator)
Asserts that a given element is present

Parameters:
locator - Locator for the element that should be present given using the standard selenium locator syntax

elementPresent

public void elementPresent(PageElement element)

elementNotPresent

public void elementNotPresent(String locator)
Asserts that a given element is not present on the current page

Parameters:
locator - Locator for the element that should not be present given using the standard selenium locator syntax

elementNotPresent

public void elementNotPresent(PageElement element)

elementVisible

public void elementVisible(String locator)
Asserts that a given element is present and is visible. Under some browsers just calling the seleinium.isVisible method on an element that doesn't exist causes selenium to throw an exception.

Parameters:
locator - Locator for the element that should be visible specified in the standard selenium syntax

elementVisible

public void elementVisible(PageElement element)

elementNotVisible

public void elementNotVisible(String locator)
Asserts that a given element is not present and visible. Calling selenium's native selenium.isVisible method on an element that doesn't exist causes selenium to throw an exception

Parameters:
locator - Locator for the element that should not be visible specified in the standard selenium syntax

elementNotVisible

public void elementNotVisible(PageElement element)

elementVisibleContainsText

public void elementVisibleContainsText(String locator,
                                       String text)
Asserts that a given element is visible and also contains the given text.

Parameters:
locator - Locator for the element that should be visible specified in the standard selenium syntax
text - the text that the element should contain

elementVisibleContainsText

public void elementVisibleContainsText(PageElement element,
                                       String text)

htmlPresent

public void htmlPresent(String html)
Asserts that a particular piece of HTML is present in the HTML source. It is recommended that the elementPresent, elementHasText or some other method be used because browsers idiosyncratically add white space to the HTML source

Parameters:
html - Lower case representation of HTML string that should not be present

htmlNotPresent

public void htmlNotPresent(String html)
Asserts that a particular piece of HTML is not present in the HTML source. It is recommended that the elementNotPresent, elementDoesntHaveText or some other method be used because browsers idiosyncratically add white space to the HTML source

Parameters:
html - Lower case representation of HTML string that should not be present

elementHasText

public void elementHasText(String locator,
                           String text)
Asserts that the element specified by the locator contains the specified text

Parameters:
locator - Locator given in standard selenium syntax
text - The text that the element designated by the locator should contain

elementHasText

public void elementHasText(PageElement element,
                           String text)

elementDoesntHaveText

public void elementDoesntHaveText(String locator,
                                  String text)
Asserts that the element specified by the locator does not contain the specified text

Parameters:
locator - Locator given in standard selenium syntax
text - The text that the element designated by the locator should not contain

elementDoesntHaveText

public void elementDoesntHaveText(PageElement element,
                                  String text)

attributeContainsValue

public void attributeContainsValue(String locator,
                                   String attribute,
                                   String value)
Asserts that the element given by the locator has an attribute which contains the required value.

Parameters:
locator - Locator given in standard selenium syntax
attribute - The element attribute
value - The value expected to be found in the element's attribute

attributeContainsValue

public void attributeContainsValue(PageElement element,
                                   String attribute,
                                   String value)

attributeDoesntContainValue

public void attributeDoesntContainValue(String locator,
                                        String attribute,
                                        String value)
Asserts that the element given by the locator has an attribute which does not contain the given value.

Parameters:
locator - Locator given in standard selenium syntax
attribute - The element attribute
value - The value expected to be found in the element's attribute

attributeDoesntContainValue

public void attributeDoesntContainValue(PageElement element,
                                        String attribute,
                                        String value)

linkPresentWithText

public void linkPresentWithText(String text)
Asserts that a link containing the given text appears on the page

Parameters:
text - The text that a link on the page should contain
See Also:
also

linkNotPresentWithText

public void linkNotPresentWithText(String text)
Asserts that no link exists on the page containing the given text

Parameters:
text - The text that no link on the page should contain

linkVisibleWithText

public void linkVisibleWithText(String text)
Asserts that a link containin the given text is present and visible.

Parameters:
text - The text that a link on the page should contain

elementsVerticallyAligned

public void elementsVerticallyAligned(String locator1,
                                      String locator2,
                                      int deltaPixels)
Asserts that two elements (located by selenium syntax) are vertically within deltaPixels of each other.

Parameters:
locator1 - Locator for element 1 given in standard selenium syntax
locator2 - Locator for element 2 given in standard selenium syntax
deltaPixels - The maximum allowable distance between the two element

elementsVerticallyAligned

public void elementsVerticallyAligned(PageElement element1,
                                      PageElement element2,
                                      int deltaPixels)

elementsSameHeight

public void elementsSameHeight(String locator1,
                               String locator2,
                               int deltaPixels)

elementsSameHeight

public void elementsSameHeight(PageElement element1,
                               PageElement element2,
                               int deltaPixels)

elementContainsText

public void elementContainsText(String locator,
                                String text)
Asserts that an element contains the given text.


elementContainsText

public void elementContainsText(PageElement element,
                                String text)

elementDoesNotContainText

public void elementDoesNotContainText(String locator,
                                      String text)
Asserts that an element does not contain the given text.


elementDoesNotContainText

public void elementDoesNotContainText(PageElement element,
                                      String text)

windowClosed

public void windowClosed(String windowName)

windowOpen

public void windowOpen(String windowName)


Copyright © 2014 Atlassian. All rights reserved.