org.openqa.selenium.android.library
Class AndroidWebDriver

java.lang.Object
  extended by org.openqa.selenium.android.library.AndroidWebDriver
All Implemented Interfaces:
HasTouchScreen, BrowserConnection, LocationContext, WebStorage, JavascriptExecutor, Rotatable, SearchContext, TakesScreenshot, WebDriver

public class AndroidWebDriver
extends java.lang.Object
implements WebDriver, SearchContext, JavascriptExecutor, TakesScreenshot, Rotatable, BrowserConnection, HasTouchScreen, WebStorage, LocationContext


Nested Class Summary
 
Nested classes/interfaces inherited from interface org.openqa.selenium.WebDriver
WebDriver.ImeHandler, WebDriver.Navigation, WebDriver.Options, WebDriver.TargetLocator, WebDriver.Timeouts, WebDriver.Window
 
Constructor Summary
AndroidWebDriver(android.app.Activity activity)
          Use this contructor to use WebDriver with a WebView that has the same settings as the Android browser.
AndroidWebDriver(android.app.Activity activity, WebViewFactory viewFactory, android.webkit.WebViewClient viewClient, android.webkit.WebChromeClient chromeClient)
          Use this constructor to use WebDriver with a custom WebView.
AndroidWebDriver(android.app.Activity activity, WebViewFactory viewFactory, android.webkit.WebViewClient viewClient, android.webkit.WebChromeClient chromeClient, android.view.View.OnFocusChangeListener focusListener)
          Use this constructor to use WebDriver with a custom WebView and a custom View.OnFocusChangeListener for that WebView..
 
Method Summary
 void close()
           
 java.lang.Object executeAsyncScript(java.lang.String script, java.lang.Object... args)
           
 java.lang.Object executeScript(java.lang.String script, java.lang.Object... args)
           
 WebElement findElement(By by)
           
 java.util.List<WebElement> findElements(By by)
           
 void get(java.lang.String url)
           
 boolean getAcceptSslCerts()
           
 android.app.Activity getActivity()
           
 java.lang.String getCurrentUrl()
           
 LocalStorage getLocalStorage()
           
 ScreenOrientation getOrientation()
           
 java.lang.String getPageSource()
           
<X> X
getScreenshotAs(OutputType<X> target)
           
 SessionStorage getSessionStorage()
           
 java.lang.String getTitle()
           
 TouchScreen getTouch()
           
 android.webkit.WebView getWebView()
           
 java.lang.String getWindowHandle()
           
 java.util.Set<java.lang.String> getWindowHandles()
           
 boolean isJavascriptEnabled()
           
 boolean isOnline()
           
 Location location()
           
 WebDriver.Options manage()
           
 WebDriver.Navigation navigate()
           
protected  java.lang.Object processJsonObject(java.lang.Object res)
           
 void quit()
           
 void rotate(ScreenOrientation orientation)
           
 void setAcceptSslCerts(boolean accept)
           
 void setLocation(Location loc)
           
 void setOnline(boolean online)
           
 void setProxy(java.lang.String host, int port)
           
 WebDriver.TargetLocator switchTo()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AndroidWebDriver

public AndroidWebDriver(android.app.Activity activity)
Use this contructor to use WebDriver with a WebView that has the same settings as the Android browser.

Parameters:
activity - the activity context where the WebView will be created.

AndroidWebDriver

public AndroidWebDriver(android.app.Activity activity,
                        WebViewFactory viewFactory,
                        android.webkit.WebViewClient viewClient,
                        android.webkit.WebChromeClient chromeClient)
Use this constructor to use WebDriver with a custom WebView.

Parameters:
activity - the activity context where the WebView will be created.
viewFactory - a implementation of the WebViewFactory interface. WebDriver will use this creation mechanism to create WebViews when needed (when clicking on a link that opens a new window for instance).
viewClient - the WebViewClient used by the custom WebView. WebDriver will instrument the WebViewClient used by the custom WebView to detect certain events.
chromeClient - the WebChromeClient used by the custom WebView. WebDriver will instrument WebChromeClient used by the custom WebView to detect certain events. Notably WebDriver will take care of the Window creation and destruction, so it is not advised to override onCloseWindow and onCreateWindow to do window management.

AndroidWebDriver

public AndroidWebDriver(android.app.Activity activity,
                        WebViewFactory viewFactory,
                        android.webkit.WebViewClient viewClient,
                        android.webkit.WebChromeClient chromeClient,
                        android.view.View.OnFocusChangeListener focusListener)
Use this constructor to use WebDriver with a custom WebView and a custom View.OnFocusChangeListener for that WebView..

Parameters:
activity - the activity context where the WebView will be created.
viewFactory - a implementation of the WebViewFactory interface. WebDriver will use this creation mechanism to create WebViews when needed (when clicking on a link that opens a new window for instance).
viewClient - the WebViewClient used by the custom WebView. WebDriver will instrument the WebViewClient used by the custom WebView to detect certain events.
chromeClient - the WebChromeClient used by the custom WebView. WebDriver will instrument WebChromeClient used by the custom WebView to detect certain events. Notably WebDriver will take care of the Window creation and destruction, so it is not advised to override onCloseWindow and onCreateWindow to do window management.
focusListener - the listener used by the WebView that will be created by the viewFactory.
Method Detail

setAcceptSslCerts

public void setAcceptSslCerts(boolean accept)

getAcceptSslCerts

public boolean getAcceptSslCerts()

getWebView

public android.webkit.WebView getWebView()

getActivity

public android.app.Activity getActivity()

getCurrentUrl

public java.lang.String getCurrentUrl()
Specified by:
getCurrentUrl in interface WebDriver

getTitle

public java.lang.String getTitle()
Specified by:
getTitle in interface WebDriver

get

public void get(java.lang.String url)
Specified by:
get in interface WebDriver

getPageSource

public java.lang.String getPageSource()
Specified by:
getPageSource in interface WebDriver

close

public void close()
Specified by:
close in interface WebDriver

quit

public void quit()
Specified by:
quit in interface WebDriver

findElement

public WebElement findElement(By by)
Specified by:
findElement in interface SearchContext
Specified by:
findElement in interface WebDriver

findElements

public java.util.List<WebElement> findElements(By by)
Specified by:
findElements in interface SearchContext
Specified by:
findElements in interface WebDriver

getWindowHandles

public java.util.Set<java.lang.String> getWindowHandles()
Specified by:
getWindowHandles in interface WebDriver

getWindowHandle

public java.lang.String getWindowHandle()
Specified by:
getWindowHandle in interface WebDriver

switchTo

public WebDriver.TargetLocator switchTo()
Specified by:
switchTo in interface WebDriver

getLocalStorage

public LocalStorage getLocalStorage()
Specified by:
getLocalStorage in interface WebStorage

getSessionStorage

public SessionStorage getSessionStorage()
Specified by:
getSessionStorage in interface WebStorage

navigate

public WebDriver.Navigation navigate()
Specified by:
navigate in interface WebDriver

isJavascriptEnabled

public boolean isJavascriptEnabled()

executeScript

public java.lang.Object executeScript(java.lang.String script,
                                      java.lang.Object... args)
Specified by:
executeScript in interface JavascriptExecutor

executeAsyncScript

public java.lang.Object executeAsyncScript(java.lang.String script,
                                           java.lang.Object... args)
Specified by:
executeAsyncScript in interface JavascriptExecutor

processJsonObject

protected java.lang.Object processJsonObject(java.lang.Object res)
                                      throws org.json.JSONException
Throws:
org.json.JSONException

setProxy

public void setProxy(java.lang.String host,
                     int port)

manage

public WebDriver.Options manage()
Specified by:
manage in interface WebDriver

location

public Location location()
Specified by:
location in interface LocationContext

setLocation

public void setLocation(Location loc)
Specified by:
setLocation in interface LocationContext

getScreenshotAs

public <X> X getScreenshotAs(OutputType<X> target)
                  throws WebDriverException
Specified by:
getScreenshotAs in interface TakesScreenshot
Throws:
WebDriverException

getOrientation

public ScreenOrientation getOrientation()
Specified by:
getOrientation in interface Rotatable

rotate

public void rotate(ScreenOrientation orientation)
Specified by:
rotate in interface Rotatable

isOnline

public boolean isOnline()
Specified by:
isOnline in interface BrowserConnection

setOnline

public void setOnline(boolean online)
               throws WebDriverException
Specified by:
setOnline in interface BrowserConnection
Throws:
WebDriverException

getTouch

public TouchScreen getTouch()
Specified by:
getTouch in interface HasTouchScreen


Copyright © 2012. All Rights Reserved.