View Javadoc

1   package com.atlassian.pageobjects.elements;
2   
3   import com.atlassian.webdriver.AtlassianWebDriver;
4   import org.openqa.selenium.By;
5   import org.openqa.selenium.NoSuchElementException;
6   import org.openqa.selenium.SearchContext;
7   
8   /**
9    * <p/>
10   * A SearchContext that can be located by WebDriver, capable of re-locating. A locatable consists of locator used to
11   * locate itself, and the parent locatable that forms a search context, in which we locate this locatable.
12   *
13   * <p/>
14   * Locatables form a list representing the parent-child relationship of SearchContexts. The root locatable
15   * is always the locatable for WebDriver itself (think of it as a global search context).
16   * To locate a SearchContext, first the parent is located then the locator is applied to it.
17   *
18   * @since 2.0
19   */
20  public interface WebDriverLocatable
21  {
22      /**
23       * Gets the WebDriver locator for this SearchContext.
24       *
25       * @return Locator, null if root.
26       */
27      By getLocator();
28  
29      /**
30       * The parent of this SearchContext.
31       *
32       * @return The locatable for the parent, null if root.
33       */
34      WebDriverLocatable getParent();
35  
36      /**
37       * Wait until this SearchContext represented by this locatable is located.
38       *
39       * @param driver AtlassianWebDriver
40       * @param timeoutInSeconds Timeout to wait until located, may be 0.
41       * @return SearchContext
42       * @throws NoSuchElementException if context could not be located before timeout expired
43       */
44      SearchContext waitUntilLocated(AtlassianWebDriver driver, int timeoutInSeconds) throws NoSuchElementException;
45  
46      /**
47       * Whether this SearchContext is present by given <tt>timeout</tt>.
48       *
49       * @param driver the AtlassianWebDriver instance
50       * @param timeoutForParentInSeconds Timout to wait until parent is located
51       * @return <code>true</code> if SearchContext is located before the timeout expires, <code>false</code> otherwise.
52       */
53      boolean isPresent(AtlassianWebDriver driver, int timeoutForParentInSeconds);
54  }