View Javadoc

1   package com.atlassian.webdriver.jira.component.dashboard;
2   
3   import com.atlassian.webdriver.AtlassianWebDriver;
4   import com.atlassian.webdriver.jira.JiraTestedProduct;
5   import org.openqa.selenium.*;
6   
7   import javax.inject.Inject;
8   import java.util.List;
9   
10  /**
11   * GadgetView is an implentation of the internal view for a gadget and just extends a
12   * WebElement so all the normal methods that WebDriver exposes on web elements is available.
13   */
14  public class GadgetView implements WebElement
15  {
16      @Inject
17      AtlassianWebDriver driver;
18  
19      private final WebElement view;
20  
21      public GadgetView(WebElement view)
22      {
23          this.view = view;
24      }
25  
26      /**
27       * Closes the Gadget view and returns the WebDriver context back to the default content
28       * Which is usually the Dashboard content.
29       */
30      public void close()
31      {
32          driver.switchTo().defaultContent();
33      }
34  
35      public void click()
36      {
37          view.click();
38      }
39  
40      public void submit()
41      {
42          view.submit();
43      }
44  
45      /**
46       * getValue has been removed from WebElement
47       * @deprecated Use {@link WebElement#getAttribute(String)}
48       */
49      @Deprecated
50      public String getValue()
51      {
52          return view.getAttribute("value");
53      }
54  
55      public void sendKeys(final CharSequence... charSequences)
56      {
57          view.sendKeys();
58      }
59  
60      public void clear()
61      {
62          view.clear();
63      }
64  
65      public String getTagName()
66      {
67          return view.getTagName();
68      }
69  
70      public String getAttribute(final String s)
71      {
72          return view.getAttribute(s);
73      }
74  
75      /**
76       * This has been removed from WebElement.
77       * @deprecated Use {@link WebElement#click()}
78       */
79      @Deprecated
80      public boolean toggle()
81      {
82          view.click();
83          return view.isSelected();
84      }
85  
86      public boolean isSelected()
87      {
88          return view.isSelected();
89      }
90  
91      /**
92       * setSelected has been removed from WebElement
93       * @deprecated Use {@link WebElement#click()}
94       */
95      @Deprecated
96      public void setSelected()
97      {
98          if (!view.isSelected()) {
99              view.click();
100         }
101     }
102 
103     public boolean isEnabled()
104     {
105         return view.isEnabled();
106     }
107 
108     public String getText()
109     {
110         return view.getText();
111     }
112 
113     public List<WebElement> findElements(final By by)
114     {
115         return view.findElements(by);
116     }
117 
118     public WebElement findElement(final By by)
119     {
120         return view.findElement(by);
121     }
122 
123     public boolean isDisplayed()
124     {
125         return view.isDisplayed();
126     }
127 
128     public Point getLocation()
129     {
130         return view.getLocation();
131     }
132 
133     public Dimension getSize()
134     {
135         return view.getSize();
136     }
137 
138     public String getCssValue(String propertyName)
139     {
140         return view.getCssValue(propertyName);
141     }
142 }