1 package com.atlassian.pageobjects.elements;
2
3 import com.atlassian.pageobjects.elements.query.TimedCondition;
4 import com.atlassian.pageobjects.elements.query.TimedQuery;
5
6 import static com.google.common.base.Preconditions.checkNotNull;
7
8
9
10
11
12
13 public final class DataAttributeFinder
14 {
15 private static final String DATA_PREFIX = "data-";
16
17 public static DataAttributeFinder query(PageElement element)
18 {
19 return new DataAttributeFinder(element);
20 }
21
22 private final PageElement pageElement;
23 private final Timed timed;
24
25 private DataAttributeFinder(PageElement pageElement)
26 {
27 this.pageElement = checkNotNull(pageElement);
28 this.timed = new Timed();
29 }
30
31 public String getDataAttribute(String dataAttributeName)
32 {
33 return pageElement.getAttribute(DATA_PREFIX + dataAttributeName);
34 }
35
36 public boolean hasDataAttribute(String dataAttributeName, String value)
37 {
38 return pageElement.hasAttribute(DATA_PREFIX + dataAttributeName, value);
39 }
40
41 public Timed timed()
42 {
43 return timed;
44 }
45
46
47
48 public class Timed
49 {
50 private final TimedElement timedElement;
51
52 private Timed()
53 {
54 this.timedElement = pageElement.timed();
55 }
56
57 public TimedQuery<String> getDataAttribute(String dataAttrName)
58 {
59 return timedElement.getAttribute(DATA_PREFIX + dataAttrName);
60 }
61
62 public TimedCondition hasDataAttribute(String dataAttrName, String dataAttrValue)
63 {
64 return timedElement.hasAttribute(DATA_PREFIX + dataAttrName, dataAttrValue);
65 }
66 }
67
68 }