org.openqa.selenium.android.library
Class ViewAdapter

java.lang.Object
  extended by org.openqa.selenium.android.library.ViewAdapter

public class ViewAdapter
extends Object

Adapter class to allow WebDriver to work with any View that has the same API as WebView. This class implements the WebView methods used by WebDriver, with the same signature as WebView's. Calls to those methods delegate to the underlying view (which in turn must implement those methods). Note thae the underlying view must be part of the Android View hierarchy.


Constructor Summary
ViewAdapter(String className, Object view)
          Constructs an adapter for any View to work with WebDriver.
 
Method Summary
 void addJavascriptInterface(Object obj, String interfaceName)
           
 android.graphics.Picture capturePicture()
           
 void clearCache(boolean includeDiskFiles)
           
 void clearFormData()
           
 void clearHistory()
           
 void clearView()
           
 void destroy()
           
 void dispatchKeyEvent(android.view.KeyEvent event)
           
 void dispatchTouchEvent(android.view.MotionEvent ev)
           
 void flingScroll(int vx, int vy)
           
 float getScale()
           
 android.webkit.WebSettings getSettings()
           
 String getTitle()
           
 Object getUnderlyingView()
           
 String getUrl()
           
 void goBack()
           
 void goForward()
           
 void loadUrl(String url)
           
 void reload()
           
 void removeAllViews()
           
 boolean requestFocus(int direction)
           
 void scrollBy(int x, int y)
           
 void setFocusable(boolean focusable)
           
 void setFocusableInTouchMode(boolean focusableInTouchMode)
           
 void setNetworkAvailable(boolean networkUp)
           
 void setOnFocusChangeListener(android.view.View.OnFocusChangeListener l)
           
 void setWebChromeClient(ChromeClientWrapper client)
           
 void setWebViewClient(ViewClientWrapper client)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ViewAdapter

public ViewAdapter(String className,
                   Object view)
Constructs an adapter for any View to work with WebDriver. Note that the view must implement the same method as WebView's. Sample usage for custom WebViews: WebView view = new WebView(acivity); ViewAdapter adapter = new ViewAdapter("android.webkit.WebView", view); Sample usage for custom Views: MyCustomView view = new MyCustomView(); ViewAdapter adapter = new ViewAdapter("custom.view.package.MyCustomView", view);

Parameters:
className - the fully qualified class name of the View. For instance: For WebView use "android.webkit.WebView".
view - the view that will be used by the driver. The view must fullfill those two criterion : - the view must belong to Android's View hierarchy - the view must implement the same methods as WebView's. If the view is a WebView, this is always true.
Method Detail

scrollBy

public void scrollBy(int x,
                     int y)

flingScroll

public void flingScroll(int vx,
                        int vy)

dispatchTouchEvent

public void dispatchTouchEvent(android.view.MotionEvent ev)

getScale

public float getScale()

dispatchKeyEvent

public void dispatchKeyEvent(android.view.KeyEvent event)

getUrl

public String getUrl()

getTitle

public String getTitle()

capturePicture

public android.graphics.Picture capturePicture()

goBack

public void goBack()

goForward

public void goForward()

loadUrl

public void loadUrl(String url)

reload

public void reload()

setNetworkAvailable

public void setNetworkAvailable(boolean networkUp)

getSettings

public android.webkit.WebSettings getSettings()

setWebChromeClient

public void setWebChromeClient(ChromeClientWrapper client)

setWebViewClient

public void setWebViewClient(ViewClientWrapper client)

setOnFocusChangeListener

public void setOnFocusChangeListener(android.view.View.OnFocusChangeListener l)

addJavascriptInterface

public void addJavascriptInterface(Object obj,
                                   String interfaceName)

clearCache

public void clearCache(boolean includeDiskFiles)

clearFormData

public void clearFormData()

clearHistory

public void clearHistory()

clearView

public void clearView()

requestFocus

public boolean requestFocus(int direction)

setFocusable

public void setFocusable(boolean focusable)

setFocusableInTouchMode

public void setFocusableInTouchMode(boolean focusableInTouchMode)

getUnderlyingView

public Object getUnderlyingView()

removeAllViews

public void removeAllViews()

destroy

public void destroy()


Copyright © 2013. All Rights Reserved.