2import java.net.URL;3import java.util.List;4import java.util.Set;5import java.util.concurrent.TimeUnit;6import org.openqa.selenium.By;7import org.openqa.selenium.JavascriptExecutor;8import org.openqa.selenium.OutputType;9import org.openqa.selenium.Platform;10import org.openqa.selenium.TakesScreenshot;11import org.openqa.selenium.WebDriver;12import org.openqa.selenium.WebDriverException;13import org.openqa.selenium.WebElement;14import org.openqa.selenium.chrome.ChromeDriver;15import org.openqa.selenium.edge.EdgeDriver;16import org.openqa.selenium.firefox.FirefoxDriver;17import org.openqa.selenium.htmlunit.HtmlUnitDriver;18import org.openqa.selenium.ie.InternetExplorerDriver;19import org.openqa.selenium.remote.DesiredCapabilities;20import org.openqa.selenium.remote.RemoteExecuteMethod;21import org.openqa.selenium.remote.RemoteKeyboard;22import org.openqa.selenium.remote.RemoteWebDriver;23import org.openqa.selenium.safari.SafariDriver;24import com.gargoylesoftware.htmlunit.WebWindow;25import com.gargoylesoftware.htmlunit.javascript.background.DefaultJavaScriptExecutor;26import com.gargoylesoftware.htmlunit.javascript.background.JavaScriptExecutor;27import com.orasi.core.by.angular.ByNG;28import com.orasi.core.by.angular.ByNG.ByNGButton;29import com.orasi.core.by.angular.ByNG.ByNGController;30import com.orasi.core.by.angular.ByNG.ByNGModel;31import com.orasi.core.by.angular.ByNG.ByNGRepeater;32import com.orasi.core.by.angular.ByNG.ByNGShow;33import com.orasi.core.by.angular.internal.ByAngular;34import com.orasi.core.interfaces.Button;35import com.orasi.core.interfaces.Checkbox;36import com.orasi.core.interfaces.Element;37import com.orasi.core.interfaces.Label;38import com.orasi.core.interfaces.Link;39import com.orasi.core.interfaces.Listbox;40import com.orasi.core.interfaces.RadioGroup;41import com.orasi.core.interfaces.Textbox;42import com.orasi.core.interfaces.Webtable;43import com.orasi.core.interfaces.impl.ButtonImpl;44import com.orasi.core.interfaces.impl.CheckboxImpl;45import com.orasi.core.interfaces.impl.ElementImpl;46import com.orasi.core.interfaces.impl.LabelImpl;47import com.orasi.core.interfaces.impl.LinkImpl;48import com.orasi.core.interfaces.impl.ListboxImpl;49import com.orasi.core.interfaces.impl.RadioGroupImpl;50import com.orasi.core.interfaces.impl.TextboxImpl;51import com.orasi.core.interfaces.impl.WebtableImpl;52import com.orasi.utils.dataHelpers.DataWarehouse;53import com.orasi.utils.debugging.Colors;54import com.orasi.utils.debugging.Highlight;55public class OrasiDriver implements WebDriver, JavaScriptExecutor, TakesScreenshot {56 /*57 * Define fields to be used by an OrasiDriver58 */59 private static final long serialVersionUID = -657563735440878909L;60 private WebDriver driver;61 private DataWarehouse dataWarehouse;62 private int currentPageTimeout = Constants.PAGE_TIMEOUT;63 private int currentElementTimeout = Constants.ELEMENT_TIMEOUT;64 private int currentScriptTimeout = Constants.DEFAULT_GLOBAL_DRIVER_TIMEOUT;65 public OrasiDriver() {}66 /**67 * Constructor for OrasiDriver68 * Example usage: OrasiDriver oDriver = new OrasiDriver(caps);69 * @param caps - Selenium desired capabilities, used to configure the OrasiDriver70 */71 public OrasiDriver(DesiredCapabilities caps) {72 setDriverWithCapabilties(caps);73 }74 /**75 * Constructor for OrasiDriver, specifically used to generate a remote WebDriver76 * Example usage: OrasiDriver oDriver = new OrasiDriver(caps, url);77 * @param caps - Selenium desired capabilities, used to configure the OrasiDriver78 * @param url - 79 */80 public OrasiDriver(DesiredCapabilities caps, URL url) {81 driver = new RemoteWebDriver(url, caps);82 }83 /**84 * Method to return the current OrasiDriver85 * Example usage: getDriver().getDriver();86 * @return - current OrasiDriver87 */88 public WebDriver getWebDriver() {89 return driver;90 }91 public void setDriver(WebDriver driver) {92 this.driver = driver;93 }94 /**95 * Method to navigate to a user-defined URL96 * Example usage: getDriver().get(url);97 * @param url - URL to which to navigate98 * @see http://selenium.googlecode.com/git/docs/api/java/org/openqa/selenium/WebDriver.html#get-java.lang.String-99 */100 @Override101 public void get(String url) {102 driver.get(url);103 }104 /**105 * Method to return the current URL106 * Example usage: getDriver().getCurrentUrl();107 * @return - current URL108 * @see http://selenium.googlecode.com/git/docs/api/java/org/openqa/selenium/WebDriver.html#getCurrentUrl--109 */110 @Override111 public String getCurrentUrl() {112 return driver.getCurrentUrl();113 }114 /**115 * Method to return the title of the current page116 * Example usage: getDriver().getTitle();117 * @return - title of the current page118 * @see http://selenium.googlecode.com/git/docs/api/java/org/openqa/selenium/WebDriver.html#getTitle--119 */120 @Override121 public String getTitle() {122 return driver.getTitle();123 }124 /**125 * Method to set the script timeout126 * @param timeout - timeout with which to set the script timeout127 * @see http://selenium.googlecode.com/git/docs/api/java/org/openqa/selenium/WebDriver.Timeouts.html#setScriptTimeout-long-java.util.concurrent.TimeUnit-128 */129 public void setScriptTimeout(int timeout) {130 setScriptTimeout(timeout, TimeUnit.SECONDS);131 }132 /**133 * Method to set the script timeout134 * @param timeout - timeout with which to set the script timeout135 * @param timeUnit -Java TimeUnit, used to determine the unit of time to be associated with the timeout136 * @see http://docs.oracle.com/javase/8/docs/api/java/util/concurrent/TimeUnit.html137 * @see http://selenium.googlecode.com/git/docs/api/java/org/openqa/selenium/WebDriver.Timeouts.html#setScriptTimeout-long-java.util.concurrent.TimeUnit-138 */139 public void setScriptTimeout(int timeout, TimeUnit timeUnit) {140 this.currentScriptTimeout = timeout;141 driver.manage().timeouts().setScriptTimeout(timeout, timeUnit);142 }143 /**144 * Method to return the script timeout145 * @return - script timeout146 */147 public int getScriptTimeout() {148 return currentScriptTimeout;149 }150 /**151 * Method to set the page timeout152 * @param timeout - timeout with which to set the page timeout153 * @see http://selenium.googlecode.com/git/docs/api/java/org/openqa/selenium/WebDriver.Timeouts.html#pageLoadTimeout-long-java.util.concurrent.TimeUnit-154 */155 public void setPageTimeout(int timeout) {156 setPageTimeout(timeout, TimeUnit.SECONDS);157 }158 /**159 * Method to set the page timeout160 * @param timeout - timeout with which to set the page timeout161 * @param timeUnit -Java TimeUnit, used to determine the unit of time to be associated with the timeout162 * @see http://docs.oracle.com/javase/8/docs/api/java/util/concurrent/TimeUnit.html163 * @see http://selenium.googlecode.com/git/docs/api/java/org/openqa/selenium/WebDriver.Timeouts.html#pageLoadTimeout-long-java.util.concurrent.TimeUnit-164 */165 public void setPageTimeout(int timeout, TimeUnit timeUnit) {166 if (driver instanceof SafariDriver || driver.toString().contains("safari")) {167 System.out.println("SafariDriver does not support pageLoadTimeout");168 } else {169 this.currentPageTimeout = timeout;170 driver.manage().timeouts().pageLoadTimeout(timeout, timeUnit);171 }172 }173 /**174 * Method to return the page timeout175 * @return - page timeout176 */177 public int getPageTimeout() {178 return currentPageTimeout;179 }180 /**181 * Method to set element timeout182 * @param timeout - timeout with which to set the element timeout183 * @see http://selenium.googlecode.com/git/docs/api/java/org/openqa/selenium/WebDriver.Timeouts.html#implicitlyWait-long-java.util.concurrent.TimeUnit-184 */185 public void setElementTimeout(int timeout) {186 setElementTimeout(timeout, TimeUnit.SECONDS);187 }188 /**189 * Method to set the element timeout190 * @param timeout - timeout with which to set the element timeout191 * @param timeUnit192 * @see http://docs.oracle.com/javase/8/docs/api/java/util/concurrent/TimeUnit.html193 * @see http://selenium.googlecode.com/git/docs/api/java/org/openqa/selenium/WebDriver.Timeouts.html#implicitlyWait-long-java.util.concurrent.TimeUnit-194 */195 public void setElementTimeout(int timeout, TimeUnit timeUnit) {196 this.currentElementTimeout = timeout;197 driver.manage().timeouts().implicitlyWait(timeout, timeUnit);198 }199 /**200 * Method to return the element timeout201 * @return - element timeout202 */203 public int getElementTimeout() {204 return currentElementTimeout;205 }206 /*207 * public List<Element> findElements(By by) { List<WebElement> webElements =208 * driver.findElements(by); List test = webElements; List<Element> elements=209 * (List<Element>)test; return elements; }210 */211 /**212 * Method to find all WebElements for a given page, using a Selenium <b><i>By</i></b> locator213 * @param by - Selenium <b><i>By</i></b> locator with which to locate WebElements214 * @return - List of WebElements, if any, found by using the Selenium <b><i>By</i></b> locator215 * @see http://docs.oracle.com/javase/8/docs/api/java/util/List.html216 * @see http://selenium.googlecode.com/svn/trunk/docs/api/java/org/openqa/selenium/By.html217 * @see http://selenium.googlecode.com/git/docs/api/java/org/openqa/selenium/WebDriver.html#findElements-org.openqa.selenium.By-218 */219 @Override220 public List<WebElement> findElements(By by) {221 return findWebElements(by);222 }223 /**224 * Method to find all WebElements for a given page, using a Selenium <b><i>By</i></b> locator225 * @param by - Selenium <b><i>By</i></b> locator with which to locate WebElements226 * @return - List of WebElements, if any, found by using the Selenium <b><i>By</i></b> locator227 * @see http://docs.oracle.com/javase/8/docs/api/java/util/List.html228 * @see http://selenium.googlecode.com/svn/trunk/docs/api/java/org/openqa/selenium/By.html229 * @see http://selenium.googlecode.com/git/docs/api/java/org/openqa/selenium/WebDriver.html#findElements-org.openqa.selenium.By-230 */231 public List<WebElement> findWebElements(By by) {232 return driver.findElements(by);233 }234 /**235 * Method to find a single Element for a given page, using a Selenium <b><i>By</i></b> locator236 * @param by - Selenium <b><i>By</i></b> locator with which to locate the Element237 * @return Element, if any, found by using the Selenium <b><i>By</i></b> locator 238 * @see http://selenium.googlecode.com/svn/trunk/docs/api/java/org/openqa/selenium/By.html239 * @see http://selenium.googlecode.com/git/docs/api/java/org/openqa/selenium/WebDriver.html#findElement-org.openqa.selenium.By-240 * @see http://github.com/Orasi/Selenium-Java-Core/blob/master/src/main/java/com/orasi/core/interfaces/impl/ElementImpl.java241 */242 @Override243 public Element findElement(By by) {244 return new ElementImpl(this, by);245 }246 /**247 * Method to find a single Element for a given page, using an Orasi <b><i>ByNG</i></b> locator248 * @param by - Orasi <b><i>ByNG</i></b> locator with which to locate the Element249 * @return Element, if any, found by using the Orasi <b><i>ByNG</i></b> locator250 * @see http://selenium.googlecode.com/git/docs/api/java/org/openqa/selenium/WebDriver.html#findElement-org.openqa.selenium.By-251 * @see http://github.com/Orasi/Selenium-Java-Core/blob/master/src/main/java/com/orasi/core/interfaces/impl/ElementImpl.java252 * @see http://github.com/Orasi/Selenium-Java-Core/blob/master/src/main/java/com/orasi/core/by/angular/ByNG.java253 */254 public Element findElement(ByNG by) {255 return new ElementImpl(this, getByNGType(by));256 }257 /**258 * Method to find a single Textbox for a given page, using a Selenium <b><i>By</i></b> locator259 * @param by - Selenium <b><i>By</i></b> locator with which to locate the Textbox260 * @return Textbox, if any, found by using the Selenium <b><i>By</i></b> locator261 * @see http://selenium.googlecode.com/svn/trunk/docs/api/java/org/openqa/selenium/By.html262 * @see http://selenium.googlecode.com/git/docs/api/java/org/openqa/selenium/WebDriver.html#findElement-org.openqa.selenium.By-263 * @see http://github.com/Orasi/Selenium-Java-Core/blob/master/src/main/java/com/orasi/core/interfaces/impl/TextboxImpl.java264 */265 public Textbox findTextbox(By by) {266 return new TextboxImpl(this, by);267 }268 /**269 * Method to find a single Textbox for a given page, using an Orasi <b><i>ByNG</i></b> locator270 * @param by - Orasi <b><i>ByNG</i></b> locator with which to locate the Textbox271 * @return Textbox, if any, found by using the Orasi <b><i>ByNG</i></b> locator272 * @see http://selenium.googlecode.com/git/docs/api/java/org/openqa/selenium/WebDriver.html#findElement-org.openqa.selenium.By-273 * @see http://github.com/Orasi/Selenium-Java-Core/blob/master/src/main/java/com/orasi/core/interfaces/impl/TextboxImpl.java274 * @see http://github.com/Orasi/Selenium-Java-Core/blob/master/src/main/java/com/orasi/core/by/angular/ByNG.java275 */276 public Textbox findTextbox(ByNG by) {277 return new TextboxImpl(this, getByNGType(by));278 }279 /**280 * Method to find a single Button for a given page, using a Selenium <b><i>By</i></b> locator281 * @param by - Selenium <b><i>By</i></b> locator with which to locate the Button282 * @return Button, if any, found by using the Selenium <b><i>By</i></b> locator283 * @see http://selenium.googlecode.com/svn/trunk/docs/api/java/org/openqa/selenium/By.html284 * @see http://selenium.googlecode.com/git/docs/api/java/org/openqa/selenium/WebDriver.html#findElement-org.openqa.selenium.By-285 * @see http://github.com/Orasi/Selenium-Java-Core/blob/master/src/main/java/com/orasi/core/interfaces/impl/ButtonImpl.java286 */287 public Button findButton(By by) {288 return new ButtonImpl(this, by);289 }290 /**291 * Method to find a single Button for a given page, using an Orasi <b><i>ByNG</i></b> locator292 * @param by - Orasi <b><i>ByNG</i></b> locator with which to locate the Button293 * @return Button, if any, found by using the Orasi <b><i>ByNG</i></b> locator294 * @see http://selenium.googlecode.com/git/docs/api/java/org/openqa/selenium/WebDriver.html#findElement-org.openqa.selenium.By-295 * @see http://github.com/Orasi/Selenium-Java-Core/blob/master/src/main/java/com/orasi/core/interfaces/impl/ButtonImpl.java296 * @see http://github.com/Orasi/Selenium-Java-Core/blob/master/src/main/java/com/orasi/core/by/angular/ByNG.java297 */298 public Button findButton(ByNG by) {299 return new ButtonImpl(this, getByNGType(by));300 }301 /**302 * Method to find a single Checkbox for a given page, using a Selenium <b><i>By</i></b> locator303 * @param by - Selenium <b><i>By</i></b> locator with which to locate the Checkbox304 * @return Checkbox, if any, found by using the Selenium <b><i>By</i></b> locator305 * @see http://selenium.googlecode.com/svn/trunk/docs/api/java/org/openqa/selenium/By.html306 * @see http://selenium.googlecode.com/git/docs/api/java/org/openqa/selenium/WebDriver.html#findElement-org.openqa.selenium.By-307 * @see http://github.com/Orasi/Selenium-Java-Core/blob/master/src/main/java/com/orasi/core/interfaces/impl/CheckboxImpl.java308 */309 public Checkbox findCheckbox(By by) {310 return new CheckboxImpl(this, by);311 }312 /**313 * Method to find a single Checkbox for a given page, using an Orasi <b><i>ByNG</i></b> locator314 * @param by - Orasi <b><i>ByNG</i></b> locator with which to locate the Checkbox315 * @return Checkbox, if any, found by using the Orasi <b><i>ByNG</i></b> locator316 * @see http://selenium.googlecode.com/git/docs/api/java/org/openqa/selenium/WebDriver.html#findElement-org.openqa.selenium.By-317 * @see http://github.com/Orasi/Selenium-Java-Core/blob/master/src/main/java/com/orasi/core/interfaces/impl/CheckboxImpl.java318 * @see http://github.com/Orasi/Selenium-Java-Core/blob/master/src/main/java/com/orasi/core/by/angular/ByNG.java319 */320 public Checkbox findCheckbox(ByNG by) {321 return new CheckboxImpl(this, getByNGType(by));322 }323 /**324 * Method to find a single Label for a given page, using a Selenium <b><i>By</i></b> locator325 * @param by - Selenium <b><i>By</i></b> locator with which to locate the Checkbox326 * @return Label, if any, found by using the Selenium <b><i>By</i></b> locator327 * @see http://selenium.googlecode.com/svn/trunk/docs/api/java/org/openqa/selenium/By.html328 * @see http://selenium.googlecode.com/git/docs/api/java/org/openqa/selenium/WebDriver.html#findElement-org.openqa.selenium.By-329 * @see http://github.com/Orasi/Selenium-Java-Core/blob/master/src/main/java/com/orasi/core/interfaces/impl/LabelImpl.java330 */331 public Label findLabel(By by) {332 return new LabelImpl(this, by);333 }334 /**335 * Method to find a single Label for a given page, using an Orasi <b><i>ByNG</i></b> locator336 * @param by - Orasi <b><i>ByNG</i></b> locator with which to locate the Label337 * @return Label, if any, found by using the Orasi <b><i>ByNG</i></b> locator338 * @see http://selenium.googlecode.com/git/docs/api/java/org/openqa/selenium/WebDriver.html#findElement-org.openqa.selenium.By-339 * @see http://github.com/Orasi/Selenium-Java-Core/blob/master/src/main/java/com/orasi/core/interfaces/impl/LabelImpl.java340 * @see http://github.com/Orasi/Selenium-Java-Core/blob/master/src/main/java/com/orasi/core/by/angular/ByNG.java341 */342 public Label findLabel(ByNG by) {343 return new LabelImpl(this, getByNGType(by));344 }345 /**346 * Method to find a single Link for a given page, using a Selenium <b><i>By</i></b> locator347 * @param by - Selenium <b><i>By</i></b> locator with which to locate the Link348 * @return Link, if any, found by using the Selenium <b><i>By</i></b> locator349 * @see http://selenium.googlecode.com/svn/trunk/docs/api/java/org/openqa/selenium/By.html350 * @see http://selenium.googlecode.com/git/docs/api/java/org/openqa/selenium/WebDriver.html#findElement-org.openqa.selenium.By-351 * @see http://github.com/Orasi/Selenium-Java-Core/blob/master/src/main/java/com/orasi/core/interfaces/impl/LinkImpl.java352 */353 public Link findLink(By by) {354 return new LinkImpl(this, by);355 }356 /**357 * Method to find a single Link for a given page, using an Orasi <b><i>ByNG</i></b> locator358 * @param by - Orasi <b><i>ByNG</i></b> locator with which to locate the Link359 * @return Link, if any, found by using the Orasi <b><i>ByNG</i></b> locator360 * @see http://selenium.googlecode.com/git/docs/api/java/org/openqa/selenium/WebDriver.html#findElement-org.openqa.selenium.By-361 * @see http://github.com/Orasi/Selenium-Java-Core/blob/master/src/main/java/com/orasi/core/interfaces/impl/LinkImpl.java362 * @see http://github.com/Orasi/Selenium-Java-Core/blob/master/src/main/java/com/orasi/core/by/angular/ByNG.java363 */364 public Link findLink(ByNG by) {365 return new LinkImpl(this, getByNGType(by));366 }367 /**368 * Method to find a single Listbox for a given page, using a Selenium <b><i>By</i></b> locator369 * @param by - Selenium <b><i>By</i></b> locator with which to locate the Listbox370 * @return Listbox, if any, found by using the Selenium <b><i>By</i></b> locator371 * @see http://selenium.googlecode.com/svn/trunk/docs/api/java/org/openqa/selenium/By.html372 * @see http://selenium.googlecode.com/git/docs/api/java/org/openqa/selenium/WebDriver.html#findElement-org.openqa.selenium.By-373 * @see http://github.com/Orasi/Selenium-Java-Core/blob/master/src/main/java/com/orasi/core/interfaces/impl/ListboxImpl.java374 */375 public Listbox findListbox(By by) {376 return new ListboxImpl(this, by);377 }378 /**379 * Method to find a single Listbox for a given page, using an Orasi <b><i>ByNG</i></b> locator380 * @param by - Orasi <b><i>ByNG</i></b> locator with which to locate the Listbox381 * @return Listbox, if any, found by using the Orasi <b><i>ByNG</i></b> locator382 * @see http://selenium.googlecode.com/git/docs/api/java/org/openqa/selenium/WebDriver.html#findElement-org.openqa.selenium.By-383 * @see http://github.com/Orasi/Selenium-Java-Core/blob/master/src/main/java/com/orasi/core/interfaces/impl/ListboxImpl.java384 * @see http://github.com/Orasi/Selenium-Java-Core/blob/master/src/main/java/com/orasi/core/by/angular/ByNG.java385 */386 public Listbox findListbox(ByNG by) {387 return new ListboxImpl(this, getByNGType(by));388 }389 /**390 * Method to find a single RadioGroup for a given page, using a Selenium <b><i>By</i></b> locator391 * @param by - Selenium <b><i>By</i></b> locator with which to locate the RadioGroup392 * @return RadioGroup, if any, found by using the Selenium <b><i>By</i></b> locator393 * @see http://selenium.googlecode.com/svn/trunk/docs/api/java/org/openqa/selenium/By.html394 * @see http://selenium.googlecode.com/git/docs/api/java/org/openqa/selenium/WebDriver.html#findElement-org.openqa.selenium.By-395 * @see http://github.com/Orasi/Selenium-Java-Core/blob/master/src/main/java/com/orasi/core/interfaces/impl/RadioGroupImpl.java396 */397 public RadioGroup findRadioGroup(By by) {398 return new RadioGroupImpl(this, by);399 }400 /**401 * Method to find a single RadioGroup for a given page, using an Orasi <b><i>ByNG</i></b> locator402 * @param by - Orasi <b><i>ByNG</i></b> locator with which to locate the RadioGroup403 * @return RadioGroup, if any, found by using the Orasi <b><i>ByNG</i></b> locator404 * @see http://selenium.googlecode.com/git/docs/api/java/org/openqa/selenium/WebDriver.html#findElement-org.openqa.selenium.By-405 * @see http://github.com/Orasi/Selenium-Java-Core/blob/master/src/main/java/com/orasi/core/interfaces/impl/RadioGroupImpl.java406 * @see http://github.com/Orasi/Selenium-Java-Core/blob/master/src/main/java/com/orasi/core/by/angular/ByNG.java407 */408 public RadioGroup findRadioGroup(ByNG by) {409 return new RadioGroupImpl(this, getByNGType(by));410 }411 /**412 * Method to find a single Webtable for a given page, using a Selenium <b><i>By</i></b> locator413 * @param by - Selenium <b><i>By</i></b> locator with which to locate the Webtable414 * @return Webtable, if any, found by using the Selenium <b><i>By</i></b> locator415 * @see http://selenium.googlecode.com/svn/trunk/docs/api/java/org/openqa/selenium/By.html416 * @see http://selenium.googlecode.com/git/docs/api/java/org/openqa/selenium/WebDriver.html#findElement-org.openqa.selenium.By-417 * @see http://github.com/Orasi/Selenium-Java-Core/blob/master/src/main/java/com/orasi/core/interfaces/impl/WebtableImpl.java418 */419 public Webtable findWebtable(By by) {420 return new WebtableImpl(this, by);421 }422 /**423 * Method to find a single Webtable for a given page, using an Orasi <b><i>ByNG</i></b> locator424 * @param by - Orasi <b><i>ByNG</i></b> locator with which to locate the Webtable425 * @return Webtable, if any, found by using the Orasi <b><i>ByNG</i></b> locator426 * @see http://selenium.googlecode.com/git/docs/api/java/org/openqa/selenium/WebDriver.html#findElement-org.openqa.selenium.By-427 * @see http://github.com/Orasi/Selenium-Java-Core/blob/master/src/main/java/com/orasi/core/interfaces/impl/WebtableImpl.java428 * @see http://github.com/Orasi/Selenium-Java-Core/blob/master/src/main/java/com/orasi/core/by/angular/ByNG.java429 */430 public Webtable findWebtable(ByNG by) {431 return new WebtableImpl(this, getByNGType(by));432 }433 /**434 * Method to find a single WebElement for a given page, using a Selenium <b><i>By</i></b> locator435 * @param by - Selenium <b><i>By</i></b> locator with which to locate the WebElement436 * @return WebElement, if any, found by using the Orasi <b><i>ByNG</i></b> locator437 * @see http://selenium.googlecode.com/git/docs/api/java/org/openqa/selenium/WebDriver.html#findElement-org.openqa.selenium.By-438 * @see http://selenium.googlecode.com/svn/trunk/docs/api/java/org/openqa/selenium/By.html439 * @see http://selenium.googlecode.com/svn/trunk/docs/api/java/org/openqa/selenium/WebElement.html440 */441 public WebElement findWebElement(By by) {442 return driver.findElement(by);443 }444 /**445 * Method to find a single WebElement for a given page, using an Orasi <b><i>ByNG</i></b> locator446 * @param by - Orasi <b><i>ByNG</i></b> locator with which to locate the WebElement447 * @return WebElement, if any, found by using the Orasi <b><i>ByNG</i></b> locator448 * @see http://selenium.googlecode.com/git/docs/api/java/org/openqa/selenium/WebDriver.html#findElement-org.openqa.selenium.By449 * @see http://github.com/Orasi/Selenium-Java-Core/blob/master/src/main/java/com/orasi/core/by/angular/ByNG.java450 * @see http://selenium.googlecode.com/svn/trunk/docs/api/java/org/openqa/selenium/WebElement.html451 */452 public WebElement findWebElement(ByNG by) {453 return driver.findElement(getByNGType(by));454 }455 /**456 * Method to return the page source of a given current page457 * @return page source of the given current page458 * @see http://selenium.googlecode.com/git/docs/api/java/org/openqa/selenium/WebDriver.html#getPageSource--459 */460 @Override461 public String getPageSource() {462 return driver.getPageSource();463 }464 465 /**466 * Method to close the current window467 * @see http://selenium.googlecode.com/git/docs/api/java/org/openqa/selenium/WebDriver.html#close--468 */469 @Override470 public void close() {471 driver.close();472 }473 /**474 * Method to quit the driver, closing every associated window475 * @see http://selenium.googlecode.com/git/docs/api/java/org/openqa/selenium/WebDriver.html#quit--476 */477 @Override478 public void quit() {479 driver.quit();480 }481 /**482 * Method to return all window handles contained within a given current driver483 * @return Set of string window handles484 * @see http://selenium.googlecode.com/git/docs/api/java/org/openqa/selenium/WebDriver.html#getWindowHandles--485 */486 @Override487 public Set<String> getWindowHandles() {488 return driver.getWindowHandles();489 }490 /**491 * Method to return the current window handle for a given currnet driver492 * @return Current window handle as a String493 * @see http://selenium.googlecode.com/git/docs/api/java/org/openqa/selenium/WebDriver.html#getWindowHandle--494 */495 @Override496 public String getWindowHandle() {497 return driver.getWindowHandle();498 }499 /**500 * Method to switch to another frame or window501 * @return TargetLocator that can be used to select a frame or window502 * @see http://selenium.googlecode.com/git/docs/api/java/org/openqa/selenium/WebDriver.html#switchTo--503 */504 @Override505 public TargetLocator switchTo() {506 return driver.switchTo();507 }508 /**509 * Method to navigate to a pre-defined URL510 * @return Navigation object that allows the selection of what to do next511 * @see http://selenium.googlecode.com/git/docs/api/java/org/openqa/selenium/WebDriver.html#navigate--512 */513 @Override514 public Navigation navigate() {515 return driver.navigate();516 }517 /**518 * Method to facilitate the management of the driver (e.g. timeouts, cookies, etc)519 * @return Options interface520 * @see http://selenium.googlecode.com/git/docs/api/java/org/openqa/selenium/WebDriver.html#manage--521 */522 @Override523 public Options manage() {524 return driver.manage();525 }526 /**527 * Method to clone this class528 * @return Object clone of the current state of this class529 * @throws CloneNotSupportedException530 * @see http://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#clone()531 */532 @Override533 protected Object clone() throws CloneNotSupportedException {534 return super.clone();535 }536 /**537 * Method to determine if an object is equal to an instance of this class538 * @param obj - object with which to compare539 * @return -boolean true if the two objects are equal, false otherwise540 * @see http://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#equals(java.lang.Object)541 */542 @Override543 public boolean equals(Object obj) {544 return super.equals(obj);545 }546 /**547 * Method to dispose of system resources548 * @throws Throwable549 * @see http://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#finalize()550 */551 @Override552 protected void finalize() throws Throwable {553 super.finalize();554 }555 /**556 * Method to return the hascode for an instance of this class557 * @return hashcode for an instance of this class as an integer558 * @see http://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#hashCode--559 */560 @Override561 public int hashCode() {562 return super.hashCode();563 }564 /**565 * Method to return a current instance of this class as a String566 * @return - current instance of this class as a String567 * @see http://docs.oracle.com/javase/8/docs/api/java/lang/String.html#toString--568 */569 @Override570 public String toString() {571 return super.toString();572 }573 /**574 * Method to execute a user-defined JavaScript575 * @param script script to be executed576 * @param parameters any parameters that may need to be referenced by the script577 * @return Return value types vary based on the return type of the script578 * @see http://selenium.googlecode.com/svn/trunk/docs/api/java/org/openqa/selenium/JavascriptExecutor.html579 */580 public Object executeJavaScript(String script, Object... parameters) {581 return ((JavascriptExecutor) driver).executeScript(script, parameters);582 }583 /**584 * Method to execute a user-defined JavaScript585 * @param script script to be executed586 * @param parameters any parameters that may need to be referenced by the script587 * @return Return value types vary based on the return type of the script588 * @see http://selenium.googlecode.com/svn/trunk/docs/api/java/org/openqa/selenium/JavascriptExecutor.html589 */590 public Object executeAsyncJavaScript(String script, Object... parameters) {591 return ((JavascriptExecutor) driver).executeAsyncScript(script, parameters);592 }593 @Override594 public void run() {595 ((DefaultJavaScriptExecutor) driver).run();596 }597 @Override598 public void addWindow(WebWindow newWindow) {599 ((DefaultJavaScriptExecutor) driver).addWindow(newWindow);600 }601 @Override602 public void shutdown() {603 ((DefaultJavaScriptExecutor) driver).shutdown();604 }605 @Override606 public int pumpEventLoop(long timeoutMillis) {607 return ((DefaultJavaScriptExecutor) driver).pumpEventLoop(timeoutMillis);608 }609 /**610 * Method to return the RemoteWebDriver session ID611 * @return RemotWebDriver session ID as a String612 * @see https://github.com/SeleniumHQ/selenium/blob/master/java/client/src/org/openqa/selenium/remote/SessionId.java613 */614 public String getSessionId() {615 return getRemoteWebDriver().getSessionId().toString();616 }617 /**618 * Method to return the RemoteWebDriver 619 * @return RemotWebDriver 620 * @see https://github.com/SeleniumHQ/selenium/blob/master/java/client/src/org/openqa/selenium/remote/RemoteKeyboard.java621 */622 public RemoteKeyboard getKeyboard(){623 return new RemoteKeyboard(new RemoteExecuteMethod(getRemoteWebDriver()));624 }625 626 /**627 * Method to set the capabilities for a driver, based on the browser type628 * @param caps - Selenium DesiredCapabilities to be used to generate a WebDriver629 * @see http://selenium.googlecode.com/svn/trunk/docs/api/java/org/openqa/selenium/firefox/FirefoxDriver.html630 * @see http://selenium.googlecode.com/svn/trunk/docs/api/java/org/openqa/selenium/ie/InternetExplorerDriver.html631 * @see http://selenium.googlecode.com/svn/trunk/docs/api/java/org/openqa/selenium/chrome/ChromeDriver.html632 * @see http://selenium.googlecode.com/svn/trunk/docs/api/java/org/openqa/selenium/safari/SafariDriver.html633 * @see http://selenium.googlecode.com/svn/trunk/docs/api/java/org/openqa/selenium/htmlunit/HtmlUnitDriver.html634 * @see http://msdn.microsoft.com/en-us/library/mt188085(v=vs.85).aspx635 */636 private void setDriverWithCapabilties(DesiredCapabilities caps) {637 switch (caps.getBrowserName().toLowerCase()) {638 case "firefox":639 driver = new FirefoxDriver(caps); 640 break;641 case "internet explorer":642 case "iexplore":643 case "ie":644 driver = new InternetExplorerDriver(caps);645 //driver = new SynchronizedInternetExplorerDriver(caps); 646 break;647 case "chrome":648 driver = new ChromeDriver(caps);649 break;650 case "safari":651 driver = new SafariDriver(caps);652 break;653 case "htmlunit":654 case "html":655 driver = new HtmlUnitDriver(true);656 break;657 case "edge":658 case "microsoftedge":659 driver = new EdgeDriver(caps);660 break;661 default:662 break;663 }664 }665 /**666 * Method to return the Selenium DesiredCapabilities667 * @return Selenium DesiredCapabilitie668 */669 public Capabilities getDriverCapability() {670 return new Capabilities();671 }672 /**673 * Method to take a screen shot674 * @param target - image type to capture the screenshot675 * @return Object which si stored information about the screenshot676 * @see http://selenium.googlecode.com/git/docs/api/java/org/openqa/selenium/TakesScreenshot.html#getScreenshotAs-org.openqa.selenium.OutputType-677 */678 @Override679 public <X> X getScreenshotAs(OutputType<X> target) throws WebDriverException {680 return ((TakesScreenshot) driver).getScreenshotAs(target);681 }682 /**683 * Subclass to assist with interacting with a RemoteWebDriver684 * @author Justin Phlegar685 * @see http://selenium.googlecode.com/svn/trunk/docs/api/java/org/openqa/selenium/remote/RemoteWebDriver.html#getCapabilities()686 * @see http://selenium.googlecode.com/svn/trunk/docs/api/java/org/openqa/selenium/Capabilities.html687 */688 public class Capabilities {689 public String browserName() {690 if(driver instanceof HtmlUnitDriver) return ((HtmlUnitDriver) driver).getCapabilities().getBrowserName();691 return getRemoteWebDriver().getCapabilities().getBrowserName();692 }693 public String browserVersion() {694 if(driver instanceof HtmlUnitDriver) return ((HtmlUnitDriver) driver).getCapabilities().getVersion();695 return getRemoteWebDriver().getCapabilities().getVersion();696 }697 public String platformOS() {698 if(driver instanceof HtmlUnitDriver) {699 return ((HtmlUnitDriver) driver).getCapabilities().getPlatform().name() + " "700 + ((HtmlUnitDriver) driver).getCapabilities().getPlatform().getMajorVersion() + "."701 + ((HtmlUnitDriver) driver).getCapabilities().getPlatform().getMinorVersion();702 }703 return getRemoteWebDriver().getCapabilities().getPlatform().name() + " "704 + getRemoteWebDriver().getCapabilities().getPlatform().getMajorVersion() + "."705 + getRemoteWebDriver().getCapabilities().getPlatform().getMinorVersion();706 }707 public Platform platform() {708 if(driver instanceof HtmlUnitDriver) return ((HtmlUnitDriver) driver).getCapabilities().getPlatform();709 710 return getRemoteWebDriver().getCapabilities().getPlatform() ;711 }712 }713 /**714 * Method to return an Orasi <b><i>ByAngular.BaseBy</i></b> locator for a given Orasi <b><i>ByNG</i></b> locator715 * @param by - Orasi <b><i>ByNG</i></b> locator716 * @return Orasi <b><i>ByAngular.BaseBy</i></b> locator717 * @see http://github.com/Orasi/Selenium-Java-Core/blob/master/src/main/java/com/orasi/core/by/angular/ByNG.java718 * @see http://github.com/Orasi/Selenium-Java-Core/blob/master/src/main/java/com/orasi/core/by/angular/internal/ByAngular.java719 */720 @SuppressWarnings("static-access")721 private ByAngular.BaseBy getByNGType(ByNG by) {722 String text = by.toString().replace("By.buttonText:", "").trim();723 if (by instanceof ByNGButton)724 return new ByAngular(getWebDriver()).buttonText(text);725 if (by instanceof ByNGController)726 return new ByAngular(getWebDriver()).controller(text);727 if (by instanceof ByNGModel)728 return new ByAngular(getWebDriver()).model(text);729 if (by instanceof ByNGRepeater)730 return new ByAngular(getWebDriver()).repeater(text);731 if (by instanceof ByNGShow)732 return new ByAngular(getWebDriver()).show(text);733 return null;734 }735 /**736 * Method that return the <b><i>Page</i></b> class737 * @return <b><i>Page</i></b> class738 */739 public Page page() {740 return new Page();741 }742 743 /*744 * Method that returns the instance of the DataWarehouse745 */746 public DataWarehouse data() {...