How to fetch the mobile number programmatically from the Android device

I need to fetch the Android mobile number pro-grammatically, later i need to compare with the number which is displayed in my application

Any please help on this

I launch the test from an own-scripted bash file which takes it from ADB and executes the test passing this (and other) info to appium

Hi Thanks for the information, is it possible to share or how to implement the same??

in bash script:

function get_android_devices {
   adb devices | awk '{print$1}' | sed 1d`

device=$(get_android_devices) #Here you have all android pluged. If you iterate over each line you can launch 1 test per device.
bundle exec cucumber "DEVICE=$(device)" "VAR=something"

And launching in this way you can take those variables (in ruby client) as:

@slipy12, that gets the device id, not the phone number, or am I missing something.

You can grab the phone number using the following method as well as some additional parsing:

True, I got it wrong.
Sorry if someone lost his time trying to catch the phone’s number :disappointed_relieved:

1 Like