Ruby: Screenshot in Android appium

Is there any method in ruby, that i can use to take a screenshot in appium?

I am creating a framework in ruby with cucumber, for android automation using appium. Currently I am creating a screenshot using adb
system(‘adb shell screencap -p /sdcard/screencap.png’)
system(‘adb pull /sdcard/screencap.png’)

This appears amateur and doesnt work, when i run all the TC’s as the screenshot is created with the name screencap that keeps getting replaced.

I am using appium_lib.

Any help on how to get screenshot in dynamic name or preferably with the scenario name tagged in it?

You’ll want to use appium_driver.driver.save_screenshot(local_filename)

1 Like

Thanks for getting back. Should i fill a value in the (local_filename)?
I dont want to hardcode the file name. Since during multiple tests, I will want to have all the screenshots for various failed scenarios.
On hardcoding, the file names are replaced one after the other, and I would be left with the screenshot for the scenario that last failed.

I set local_filename based on a combination of a time stamp and the test id to avoid just such problems

1 Like

Willoser! Okay, I will try this and get back to you tomorrow.

On a side note? Have you integrated the ruby cucumber tests to jenkins?

Because we need to test on physical devices, we can not integrate our tests into Jenkins directly.

Jenkins has the capability to test on real device too right? with appium? cant we connect the real device to ur slave where the jenkins run?

I am using cucumber framework and currently want to integrate my cucucmber tests with ruby using appium to jenkins, but jenkins would say cucumber command not found . Any idea about this? I have followed a lot of steps suggested in the internet but nothing appears to work

We don’t have devices attached to our servers – we have too many of those. If you can do that, it should work.

You need to include cucumber in your gemset and add it to your server before you start up your test