I am looking for a way in Selendroid to get the current view dump of an app running on real device. Now I know, that you can get the whole page source with
driver.getPageSource()
That is, what I am currently using. This method gives me an XML-formatted hierarchy of all visible view elements, that can be parsed with XPath. The output looks like this:
<?xml version="1.0" encoding="UTF-8"?>
<views>
<DecorView name="" label="" value="" ref="97bc5edf-6001-0c8a-3550-92822dfe3d55" id="" shown="true">
<rect x="0" y="0" height="1920" width="1080" />
<LinearLayout name="" label="" value="" ref="da84259b-f404-d100-7eb6-ed006469d60e" id="" shown="true">
<rect x="0" y="0" height="1920" width="1080" />
<ViewStub name="" label="" value="" ref="beb2dd1c-4a0e-25ef-26ff-30fa1eb628d0" id="action_mode_bar_stub" shown="false">
<rect x="0" y="0" height="0" width="0" />
</ViewStub>
(...)
Unfortunately I need just the elements, which can be clicked. In Android SDK one can use isClickable on a View, to check, whether there is a click listener registered for it.
Is it possible to get to the isClickable attribute of an element with Selendroid? Alternativel is there any other way to get the current view dump of an app with Selendroid, which will give me the element's isClickable attribute value?
One last thing: what I am working on is a generic test for apps, of which I don't have the source code. Because of this I cannot define the view elements before runtime. This has to happen dynamically.
You should use a tool like a uiautomatorviewer [located in SDK tools folder] for manually checking process. Selendroid doesnt offer functionality like a "isClickable" but you can chceck "isEnabled" or just :
WebElement element = driver.findElement(/* ... */);
try{
element.click();
}catch(SelendroidException ex){
/* your listener for output */
}
or!
element = WebDriverWait(driver, 10).until(
ExpectedConditions.elementToBeClickable(/* way to identity element */));
And yes.. its really hard to find proper way to do this.