How to take Screenshots(without the Statusbar) using Appium Android (python)

I only like to take screenshot of the App screenview and not along with Topbar.

Any help is greatly appreciated.

Current code:
directory = ‘%s/’ % os.getcwd()
file_name = ‘screenshot1.png’
self.driver.save_screenshot(directory + file_name)
self.driver.implicitly_wait(50000)

Take a look at ImageMagik:

It has libraries for most programming languages. You can take your screenshot(s?) and then process them after the testing is done, removing whatever you don’t need.

In my testing we remove the topbar for comparing and then deduping the screenshots. With the topbar the clock is always different so it makes comparisons difficult.

2 Likes

Hi @calmobileh,

If you want to compare this screenshot with a previous one, you can use Toolium, that implements methods to compare screenshots excluding some elements.

You can get the locator of status bar element and capture the screenshot excluding it:

self.assert_full_screenshot(‘example’, exclude_elements=[(By.ID, ‘status_bar_id’)])

Instead of exclude the bar element, you also can capture only the app content:

self.assert_screenshot((By.ID, ‘app_content_id’), ‘example’)

More info in Visual Testing — Toolium 3.1.4.dev0-50 documentation

1 Like

Thanks for your replies. I used PIL to process the screenshot to exclude the Status bar by cropping.