How to configure the Genymotion emulator to the appium? - eclipse

Through eclipse I have configured the Genymotion path & also I have downloaded the virtual devices in the Genymotion.
In Appium, those downloaded virtual devices are visible in the"Launch Device" dropdown menu. Then I set the apk path & try to start the Appium 1.3.4.1.
By that time I am getting an error message like
Starting Node Server
usage: main.js [-h] [-v] [--shell]
main.js: error: Unrecognized arguments: Nexus 5 - 4.4.4 - API 19 - 1080x1920.
[--localizable-strings-dir LOCALIZABLESTRINGSDIR] [--app APP]
[--ipa IPA] [-U UDID] [-a ADDRESS] [-p PORT]
[-ca CALLBACKADDRESS] [-cp CALLBACKPORT] [-bp BOOTSTRAPPORT]
[-k] [-r BACKENDRETRIES] [--session-override] [--full-reset]
[--no-reset] [-l] [-lt LAUNCHTIMEOUT] [-g LOG]
[--log-level {info,info:debug,info:info,info:warn,info:error,warn,warn:debug,warn:info,warn:warn,warn:error,error,error:debug,error:info,error:warn,error:error,debug,debug:debug,debug:info,debug:warn,debug:error}]
[--log-timestamp] [--local-timezone] [--log-no-colors]
[-G WEBHOOK] [--native-instruments-lib]
[--app-pkg ANDROIDPACKAGE] [--app-activity ANDROIDACTIVITY]
[--app-wait-package ANDROIDWAITPACKAGE]
[--app-wait-activity ANDROIDWAITACTIVITY]
[--android-coverage ANDROIDCOVERAGE] [--avd AVD]
[--avd-args AVDARGS]
[--device-ready-timeout ANDROIDDEVICEREADYTIMEOUT] [--safari]
[--device-name DEVICENAME] [--platform-name PLATFORMNAME]
[--platform-version PLATFORMVERSION]
[--automation-name AUTOMATIONNAME] [--browser-name BROWSERNAME]
[--default-device] [--force-iphone] [--force-ipad]
[--language LANGUAGE] [--locale LOCALE]
[--calendar-format CALENDARFORMAT] [--orientation ORIENTATION]
[--tracetemplate AUTOMATIONTRACETEMPLATEPATH] [--show-sim-log]
[--show-ios-log] [--nodeconfig NODECONFIG] [-ra ROBOTADDRESS]
[-rp ROBOTPORT] [--selendroid-port SELENDROIDPORT]
[--chromedriver-port CHROMEDRIVERPORT]
[--chromedriver-executable CHROMEDRIVEREXECUTABLE]
[--use-keystore] [--keystore-path KEYSTOREPATH]
[--keystore-password KEYSTOREPASSWORD] [--key-alias KEYALIAS]
[--key-password KEYPASSWORD] [--show-config] [--no-perms-check]
[--command-timeout DEFAULTCOMMANDTIMEOUT] [--keep-keychains]
[--strict-caps] [--isolate-sim-device] [--tmp TMPDIR]
[--trace-dir TRACEDIR] [--intent-action INTENTACTION]
[--intent-category INTENTCATEGORY] [--intent-flags INTENTFLAGS]
[--intent-args OPTIONALINTENTARGUMENTS]
Node Server Process Ended
When I try to run with normal emulator in Android SDK it works well.
But I want to run it with Genymotion emulator. How to do? I'm stuck up here.
My questions are:
Whether the additional emulator will work in appium windows or not?
What I need to give in the "Argument" field under appium?

The following code works for the above question.
static String deviceName = "Google Nexus 5 - 4.4.4 - API 19 - 1080x1920";
public static void main(String[] args) throws InterruptedException, ExecuteException, IOException {
DesiredCapabilities capabilities = new DesiredCapabilities();
DefaultExecutor executor = new DefaultExecutor();
DefaultExecuteResultHandler resultHandler = new DefaultExecuteResultHandler();
CommandLine launchEmul = new CommandLine("C:/Program Files/Genymobile/Genymotion/player");
launchEmul.addArgument("--vm-name");
launchEmul.addArgument("\""+deviceName+"\"");
executor.setExitValue(1);
executor.execute(launchEmul, resultHandler);
Thread.sleep(40);
capabilities.setCapability("deviceName","Google Nexus 5 - 4.4.4 API 19 - 1080x1920");
capabilities.setCapability("platformVersion", "4.3");
capabilities.setCapability("platformName", "Android");
capabilities.setCapability("app","D:/SOFTWARES/Apks/GOA.apk");
driver = new AppiumDriver(new URL("http://127.0.0.1:4723/wd/hub"),capabilities);
System.out.println("SetUp is successful and Appium Driver is launched successfully");
}

Recently i i've used genymotion and appium and worked fine
1-i've installed appium(i've tried windows and console version succesfully)
2-i've installed genymotion and created a virtual device in it
3-launched virtual device from genymotion
4-in my test, when i defined driver capabilities, i didnt identified a specific virtual device, so, appium try to identify any active device(virtual or not)
try that and let me know if worked to help in anything i could

Related

How can I get android id using ADB and within Unity application?

I need to get the AndroidID using ADB and inside the unity application check if it's the same device using the AndroidID.
With this command, using ADB I have the AndroidID:
adb shell settings get secure android_id
>> a9822db857e4****
And inside the unity application, I'm using this code:
AndroidJavaClass clsUnity = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
AndroidJavaObject objActivity = clsUnity.GetStatic<AndroidJavaObject>("currentActivity");
AndroidJavaObject objResolver = objActivity.Call<AndroidJavaObject>("getContentResolver");
AndroidJavaClass clsSecure = new AndroidJavaClass("android.provider.Settings$Secure");
string android_id = clsSecure.CallStatic<string>("getString", objResolver, "android_id");
>> android_id = 98ff3a034b16****
You may notice that the IDs are different.
Does anyone have a solution for this?
How can I get that same identifier using ADB and in unity ?
If your device runs Android version > Android 8.0 (API level 26), the ANDROID_ID string is unique to each app (more precisely, to each app-signing key - so more like unique to all your apps you signed with the same key). You can check out all the changes related to ANDROID_ID here.
If you are running Android version < 8.0, you might have multiple users and they will have separate ids - maybe you are getting root users' id via ADB and the whatever-user-launched-your-app id from code? (See here).

Not able to create first program in Eclipse with Selenium using Appium

I am not able to do automation testing with Appium server by using Eclipse with Selenium. I have shared below Eclipse error and Appium server logs also. I have shared Eclipse error also as below:
Error: You need the android.permission.INSTALL_GRANT_RUNTIME_PERMISSIONS permission to use the PackageManager.INSTALL_GRANT_RUNTIME_PERMISSIONS flag
Please check below code in Eclipse:
package tests;
import java.net.MalformedURLException;
import java.net.URL;
import org.openqa.selenium.remote.DesiredCapabilities;
import io.appium.java_client.AppiumDriver;
import io.appium.java_client.MobileElement;
import io.appium.java_client.android.AndroidDriver;
public class StartChrome {
public static void main(String[] args) {
// Set the Desired Capabilities
DesiredCapabilities caps = new DesiredCapabilities();
caps.setCapability("deviceName", "My Phone");
caps.setCapability("udid", "7970dc54"); // Give Device ID of your mobile phone
caps.setCapability("platformName", "Android");
caps.setCapability("platformVersion", "9 PKQ1.180904.001");
caps.setCapability("appPackage", "com.android.vending");
caps.setCapability("appActivity", "com.google.android.finsky.activities.MainActivity");
caps.setCapability("noReset", "true");
// Instantiate Appium Driver
try {
AppiumDriver<MobileElement> Driver = new AndroidDriver<MobileElement>(
new URL("http://0.0.0.0:4723/wd/hub"), caps);
} catch (MalformedURLException e) {
System.out.println(e.getMessage());
}
}
}
It looks like you haven't actually started your Appium server yet. You can't instantiate a new AndroidDriver without starting the Appium server.
Above the line // Set the Desired Capabilities, add this:
// start appium service
AppiumServiceBuilder builder = new AppiumServiceBuilder();
AppiumLocalService _appiumLocalService = builder.UsingAnyFreePort().Build();
_appiumLocalService.Start();
You'll also need to update the line
AppiumDriver<MobileElement> Driver = new AndroidDriver<MobileElement>(new URL("http://0.0.0.0:4723/wd/hub"), caps);
to
AppiumDriver<MobileElement> Driver = new AndroidDriver<MobileElement>(_appiumLocalService.ServiceUrl, caps);
That way, you are using the correct service URL that you Appium service was started on.
Additionally, you should also make sure the following settings on your Android device are also enabled:
Developer mode ON -- tap build number 7 times
USB Debugging ENABLED
Select USB configuration -- change from Charging to Picture Transfer Protocol or MIDI
Make sure your device is appearing when you run adb devices command. I only needed to enable the first two options -- developer mode & USB debugging -- to get mine working.

It is impossible to create a new session because 'createSession' which takes HttpClient,

org.openqa.selenium.WebDriverException: It is impossible to create a new session because 'createSession' which takes HttpClient, InputStream and long was not found or it is not accessible
Build info: version: '3.12.0', revision: '7c6e0b3', time: '2018-05-08T14:04:26.12Z'
I am getting this error randomly i want to know the route cause for this issue in IOS
There are multiple reason behind this issue. There are multiple ways to resolve this issues, depending upon, where these issues are coming from.
1)One issue which occur to me was DesireCapabilities.setCapability() key/value was not correct type. I have resolved this issue by just
DesiredCapabilities.setCapability("capabilities_variable","capabilities_value");
setCapability("appWaitDuration", "600000"); here 600000 was String instead of long or int
Check your setCapability type whether it String/int/long.
2) Check USB Connection is Laptop or Computer, if not connected than same issue.
3) ADB Server might be problem. So adb kill-server and adb start-server
4) Try to change USB and try it out.
5) Sometimes, it might be a proxy issue(Laptop/Desktop may have some proxy setup
in organization, since for Desktop/Laptops are connected with Mobile via TCP/IP Connection).
6) Sometimes, there might be permission required to access PORT (sudo ufw allow portnumber (UBUNTU SYSTEM))
7) Environment variable required Android_SDK_Home and Android Platform Tools path
**> Solution 1st**
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability("deviceName", "xyz");
capabilities.setCapability("platformVersion", "6.0");
capabilities.setCapability("platformName", Platform.ANDROID);
capabilities.setCapability("appPackage", "com.hp.HPSupportAssistant");
capabilities.setCapability("appActivity", "com.hp.HPSupportAssistant.MainActivity");
capabilities.setCapability(MobileCapabilityType.NEW_COMMAND_TIMEOUT, 6000); capabilities.setCapability(AndroidMobileCapabilityType.AUTO_GRANT_PERMISSIONS,true);
//desiredCap.setCapability(MobileCapabilityType.AUTOMATION_NAME, AutomationName.ANDROID_UIAUTOMATOR2);
**Here comment below line and then run it will work**
desiredCap.setCapability(MobileCapabilityType.AUTOMATION_NAME, AutomationName.ANDROID_UIAUTOMATOR2);
**solution 2nd Or keep above line in desired capabilities but before that do
run 3 cmd on cmd promt**
adb shell pm list packages -f > D://t.txt
adb uninstall io.appium.uiautomator2.server
adb uninstall io.appium.uiautomator2.server
desiredCap.setCapability(MobileCapabilityType.AUTOMATION_NAME, AutomationName.ANDROID_UIAUTOMATOR2);

Parameters were incorrect when running Selenium?

I'm testing my app on mac with real ios device. When i run the scripts it says following error in Eclipse IDE,
org.openqa.selenium.SessionNotCreatedException: Unable to create new
remote session. desired capabilities = Capabilities
[{app=/Users//Downloads/XXX.ipa,
platformVersion=10.2.1, platformName=iOS, deviceName=Mr.x'S iPod touch,
UDID=*****}], required capabilities =
Capabilities [{}]
Then i checked the logs in appium it shows,
[debug] [MJSONWP] Bad parameters: BadParametersError: Parameters were
incorrect. We wanted {"required":["desiredCapabilities"],"optional":
["requiredCapabilities","sessionId","id"]} and you sent [
"desiredCapabilities" , "requiredCapabilities", "capabilities",
"alwaysMatch","firstMatch"]
What should i do to fix this, Can anyone help me to resolve this.
Yes, you need xcode to access iOS native app.
Desired capabilities to be used:
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability("platformName", "iOS");
capabilities.setCapability("platformVersion", "9.3");
capabilities.setCapability("deviceOrientation", "portrait");
capabilities.setCapability("browserName", "Safari");
capabilities.setCapability("autoWebview", "true");
capabilities.setCapability("automationName", "XCUITest");
capabilities.setCapability("deviceName", "iphone");
capabilities.setCapability("autoAcceptAlerts",true);
capabilities.setCapability("udid", UDID);
capabilities.setCapability("xcodeConfigFile", "/usr/local/lib/node_modules/appium/node_modules/appium-xcuitest-driver/WebDriverAgent/Config.xcconfig");
capabilities.setCapability("realDeviceLogger","/usr/local/lib/node_modules/deviceconsole");

Appium - setting Desired Capabilities in both terminal and test code

I am trying to set some appium desired capabilities in the terminal window so that I can, for example, run my tests against different simulator devices:
Terminal: $ appium --device-name 'iPhone 6'
However, I am have to setup desired capabilities in my actual code, so I have a valid instance of IOSDriver. I use this code:
capabilities.setCapability("platformName", "iOS");
capabilities.setCapability("platformVersion", "8.3");
capabilities.setCapability("app","../Build/Products/Debug-iphonesimulator/LightAlarm.app");
driver = new IOSDriver(new URL("http://0.0.0.0:4723/wd/hub"),capabilities);
When I run my tests I get an error that deviceName is not being set:
The following desired capabilities are required, but were not provided: deviceName
However, my terminal appium server is all setup correctly:
info: Welcome to Appium v1.4.0 (REV dc30dae9e8fe8c85eeea707dbdbd60350fdff55b)
info: Appium REST http interface listener started on 0.0.0.0:4723
info: [debug] Non-default server args: {"deviceName":"iPhone 6"}
info: Console LogLevel: debug
Any ideas what might be going wrong?