.

Java code to launch Genymotion virtual device

Use of Emulators/Simulators is very common now a days for device automation. There are couple of options available which provide you these virtual devices. And you need not purchase a real device to run your test.


Steps:

1. Right click on My Computer > Properties > Advanced System Settings > Environment Variables
Update Path variable with the path of Genymotion directory.

C:\Program Files\Genymobile\Genymotion










2. Now open command prompt, type genymotion and hit ENTER. It should open genymotion. This is just to make sure that Path variable is correct.

3. To launch a virual device type


player --vm-name SamsungNote3

This should launch your virtual device. Create a batch file and save this command in that file.

4. To achieve this using Java code, simply execute this batch file using Runtime.getRuntime.exec().

try {
    String[] command = {"cmd.exe", "/C", "Start", "C:\\Users\\Kamal\\Desktop\\a.bat"};
    Process p =  Runtime.getRuntime().exec(command);           
    }
catch (IOException ex){
    }
   


No comments :

Post a Comment

Recent Posts