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 public interface WebDriverLocatable
19 {
20 /**
21 * Gets the WebDriver locator for this SearchContext.
22 *
23 * @return Locator, null if root.
24 */
25 By getLocator();
26
27 /**
28 * The parent of this SearchContext.
29 *
30 * @return The locatable for the parent, null if root.
31 */
32 WebDriverLocatable getParent();
33
34 /**
35 * Wait until this SearchContext represented by this locatable is located.
36 *
37 * @param driver AtlassianWebDriver
38 * @param timeoutInSeconds Timeout to wait until located.
39 * @return SearchContext
40 * @throws NoSuchElementException if context could not be located before timeout expired
41 */
42 SearchContext waitUntilLocated(AtlassianWebDriver driver, int timeoutInSeconds) throws NoSuchElementException;
43
44 /**
45 * Whether this SearchContext is present by given <tt>timeout</tt>.
46 *
47 * @param driver AtlassianWebDriver
48 * @param timeoutForParentInSeconds Timout to wait until parent is located
49 * @return True if SearchContext is located before the timeout expires, false otherwise.
50 */
51 boolean isPresent(AtlassianWebDriver driver, int timeoutForParentInSeconds);
52 }