Testinium / MobileDeviceInfo

Apache License 2.0
36 stars 20 forks source link

For iOS devices getting all the values as NULL #5

Closed SaravanaQA closed 4 years ago

SaravanaQA commented 4 years ago

DeviceInfo deviceInfo = new DeviceInfoImpl(DeviceType.IOS); if (deviceInfo.anyDeviceConnected()) { device = deviceInfo.getFirstDevice(); System.out.println("Device Name - " + device.getDeviceProductName()); System.out.println("Device id - " + device.getUniqueDeviceID()); }

mjordanBetBright commented 4 years ago

Are they real devices? Not simulators? Can you build apps on them using appium, without using MobileDeviceInfo?

SaravanaQA commented 4 years ago

@mjordanBetBright I'm trying with both real devices as well as with emulators. Actually I'm trying to achieve parallel execution.For that I need to get all devices info.

Using MobileDeviceInfo, I'm able to get info about android devices but particularly for iOS getting Null.

Do I need to install any extra plugins ?

bahadirustun commented 4 years ago

@SaravanaQA In order to use ios, you must meet the requirements.

brew install --HEAD libimobiledevice

You should run " ideviceinfo " command on the terminal and get results related to the device.

SaravanaQA commented 4 years ago

@bahadirustun Thanks for the solution.. Actually I have installed libimobiledevice without --HEAD. now uninstalled existing one and installed new one.

ideviceinfo command only displaying real device details, Emulator details are not displaying

bahadirustun commented 4 years ago

@SaravanaQA For android you need to install android sdk and you need to run " adb " as global value on the terminal.

simple method :

ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" brew cask install android-platform-tools

install.

You should run " adb shell getprop " command on the terminal and get results related to the device.

mjordanBetBright commented 4 years ago

For simulators do you need to use IOSSIMULATOR or ALLANDIOSSIMULATOR instead of IOS? I don't think the maven package is up to date with these options.

SaravanaQA commented 4 years ago

@bahadirustun Thanks for the info. I'm not facing any issue with android.

@mjordanBetBright Yes you are right, I'm not getting IOSSIMULATOR or ALLANDIOSSIMULATOR. I'm getting only Android, iOS and All

Can I know the solution to get simulator options ?

bahadirustun commented 4 years ago

emulator word accidentally thought android. Yes the package is out of date. We didn't have time to update it. I recommend compiling in a local environment.

mjordanBetBright commented 4 years ago

Yes, I compile it into my env instead of using the maven package. Simulator works there using IOSSIMULATOR and ALLANDIOSSIMULATOR. Maybe the readme could be updated with this info?

SaravanaQA commented 4 years ago

@mjordanBetBright Thanks for the update. Can I know how we can compile into our environment ?

mjordanBetBright commented 4 years ago

Just clone it into your project. You'll need to change some things around. When you build there'll be some fails, just need to fix them.

SaravanaQA commented 4 years ago

@mjordanBetBright Sure :) Thanks for your time buddy.

SaravanaQA commented 4 years ago

@mjordanBetBright As suggested by you, Cloned project and did basic setup. Now I'm getting iOS device details perfectly. But for android getting NullPointException. Please find the exception details below,

FAILED: launch java.lang.NullPointerException at deviceinformation.device.AndroidDeviceFinder.readDeviceInfo(AndroidDeviceFinder.java:69) at deviceinformation.device.AndroidDeviceFinder.findDevices(AndroidDeviceFinder.java:26) at deviceinformation.device.AllDeviceFinder.findDevices(AllDeviceFinder.java:30) at deviceinformation.device.DeviceFinder.findDevices(DeviceFinder.java:14) at deviceinformation.DeviceInfoImpl.getDevices(DeviceInfoImpl.java:43) at deviceinformation.DeviceInfo.anyDeviceConnected(DeviceInfo.java:14) at pyt.mobileWeb.base.baseTest.launch(baseTest.java:77) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:124) at org.testng.internal.Invoker.invokeMethod(Invoker.java:583) at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:719) at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:989) at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:125) at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:109) at org.testng.TestRunner.privateRun(TestRunner.java:648) at org.testng.TestRunner.run(TestRunner.java:505) at org.testng.SuiteRunner.runTest(SuiteRunner.java:455) at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:450) at org.testng.SuiteRunner.privateRun(SuiteRunner.java:415) at org.testng.SuiteRunner.run(SuiteRunner.java:364) at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52) at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:84) at org.testng.TestNG.runSuitesSequentially(TestNG.java:1208) at org.testng.TestNG.runSuitesLocally(TestNG.java:1137) at org.testng.TestNG.runSuites(TestNG.java:1049) at org.testng.TestNG.run(TestNG.java:1017) at org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:132) at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:230) at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:76)

@bahadirustun It would be helpful, If you are able to help on this .

mjordanBetBright commented 4 years ago

I don't know to be honest. I'm only using this package for IOS devices at the moment. Sorry I can't be of any help.

SaravanaQA commented 4 years ago

@mjordanBetBright Thanks for your reply..

@bahadirustun Would you help me on this ? FAILED: launch java.lang.NullPointerException at deviceinformation.device.AndroidDeviceFinder.readDeviceInfo(AndroidDeviceFinder.java:69) at deviceinformation.device.AndroidDeviceFinder.findDevices(AndroidDeviceFinder.java:26) at deviceinformation.device.AllDeviceFinder.findDevices(AllDeviceFinder.java:30) at deviceinformation.device.DeviceFinder.findDevices(DeviceFinder.java:14) at deviceinformation.DeviceInfoImpl.getDevices(DeviceInfoImpl.java:43) at deviceinformation.DeviceInfo.anyDeviceConnected(DeviceInfo.java:14) at pyt.mobileWeb.base.baseTest.launch(baseTest.java:77)

bahadirustun commented 4 years ago

@SaravanaQA
re-download and compile the project, I'm waiting for the problem to be solved. I made arrangements.

SaravanaQA commented 4 years ago

@bahadirustun Resolved that null pointer exception. Removed following code from AndriodDeviceFinder.java

// Process deviceListProcessOnlyCard = ProcessHelper.runTimeExec( // String.format("%s%s", localPath, ADB_INTEGRATED_CIRCUIT_CARD_IDENTITY_SHELL_COMMAND) // .replace("serialNumber", serialNumberArray[0].trim())); // BufferedReader readerOnlyCard = new BufferedReader( // new InputStreamReader(deviceListProcessOnlyCard.getInputStream())); // // String[] mIccidsim = readerOnlyCard.readLine().replaceAll(" ", "").split("="); // parentMap.put(mIccidsim[0], mIccidsim[1]);

// readerOnlyCard.close();