@@ -226,10 +226,7 @@ private static void takeAndroidScreenshot(String screenShotFilePath) throws IOEx
226
226
}
227
227
228
228
private static void takeIDeviceScreenshot (String screenShotFilePath ) throws Exception {
229
- String udid = System .getenv ("UDID" );
230
- if (udid ==null ){
231
- throw new Exception ("$UDID was null, set UDID environment variable and try again" );
232
- }
229
+ String udid = getIosUdid ();
233
230
String [] cmd = new String []{"idevicescreenshot" , "-u" , udid , screenShotFilePath };
234
231
Process p = Runtime .getRuntime ().exec (cmd );
235
232
BufferedReader in = new BufferedReader (new InputStreamReader (p .getInputStream ()));
@@ -258,10 +255,13 @@ private static Dimension getScreenSize(PlatformType platform) throws Exception {
258
255
}
259
256
260
257
private static Dimension getIosScreenSize () throws Exception {
261
- String udid = System .getenv ("UDID" );
262
- if (udid ==null ){
263
- throw new Exception ("$UDID was null, set UDID environment variable and try again" );
264
- }
258
+ String udid = getIosUdid ();
259
+ String productType = getIosProductType (udid );
260
+ Dimension screenSize = getIosScreenSizePointsFromPropertiesFile (productType );
261
+ return screenSize ;
262
+ }
263
+
264
+ private static String getIosProductType (String udid ) throws IOException , InterruptedException , Exception {
265
265
String [] cmd = new String []{"ideviceinfo" , "-u" , udid , "--key" , "ProductType" };
266
266
Process p = Runtime .getRuntime ().exec (cmd );
267
267
BufferedReader in = new BufferedReader (new InputStreamReader (p .getInputStream ()));
@@ -271,7 +271,18 @@ private static Dimension getIosScreenSize() throws Exception {
271
271
throw new Exception ("ideviceinfo process exited with value: " + exitVal );
272
272
}
273
273
String productType = in .readLine ();
274
-
274
+ return productType ;
275
+ }
276
+
277
+ private static String getIosUdid () throws Exception {
278
+ String udid = System .getenv ("UDID" );
279
+ if (udid ==null ){
280
+ throw new Exception ("$UDID was null, set UDID environment variable and try again" );
281
+ }
282
+ return udid ;
283
+ }
284
+
285
+ private static Dimension getIosScreenSizePointsFromPropertiesFile (String productType ) throws Exception {
275
286
Properties screenSizeProperties = fetchProperties ();
276
287
String screenDimensionString = (String ) screenSizeProperties .get (productType );
277
288
if (screenDimensionString == null ){
0 commit comments