@@ -58,7 +58,7 @@ public static ImageLocation findImage(String searchedImageFilePath, String scene
58
58
ImageLocation imgLocation = imageFinder .findImage (searchedImageFilePath , sceneImageFilePath , settings .getTolerance ());
59
59
60
60
if (imgLocation != null ) {
61
- Dimension screenSize = getScreenSize (platform );
61
+ Dimension screenSize = getScreenSize (platform , sceneImageFilePath );
62
62
if (platform .equals (PlatformType .IOS )) {
63
63
imgLocation = scaleImageRectangleForIos (screenSize , imgLocation , sceneImageFilePath );
64
64
}
@@ -280,19 +280,28 @@ private static void takeIDeviceScreenshot(String screenShotFilePath) throws Exce
280
280
}
281
281
}
282
282
283
- private static Dimension getScreenSize (PlatformType platform ) throws Exception {
283
+ private static Dimension getScreenSize (PlatformType platform , String sceneImageFilePath ) throws Exception {
284
284
if (platform .equals (PlatformType .IOS )) {
285
- return getIosScreenSize ();
285
+ return getIosScreenSize (sceneImageFilePath );
286
286
} else {
287
287
return getAndroidScreenSize ();
288
288
}
289
289
}
290
290
291
- private static Dimension getIosScreenSize () throws Exception {
291
+ private static Dimension getIosScreenSize (String sceneImageFilePath ) throws Exception {
292
292
String udid = getIosUdid ();
293
293
String productType = getIosProductType (udid );
294
- Dimension screenSize = getIosScreenSizePointsFromPropertiesFile (productType );
295
- return screenSize ;
294
+ try {
295
+ Dimension screenSize = getIosScreenSizePointsFromPropertiesFile (productType );
296
+ return screenSize ;
297
+ } catch (UnsupportedOperationException e ){
298
+ logger .warn ("Current device not included in the ios-screen-size.properties-file. Assuming x3 Retina display." );
299
+ logger .warn ("Add the devices screen size information to the ios-screen-size.properties-file" );
300
+ int screenHeight = (int ) (imageFinder .getSceneHeight (sceneImageFilePath )/3 );
301
+ int screenWidth = (int ) (imageFinder .getSceneWidth (sceneImageFilePath )/3 );
302
+ Dimension screenSize = new Dimension (screenWidth , screenHeight );
303
+ return screenSize ;
304
+ }
296
305
}
297
306
298
307
private static String getIosProductType (String udid ) throws IOException , InterruptedException , Exception {
@@ -316,11 +325,11 @@ private static String getIosUdid() throws Exception {
316
325
return udid ;
317
326
}
318
327
319
- private static Dimension getIosScreenSizePointsFromPropertiesFile (String productType ) throws Exception {
328
+ private static Dimension getIosScreenSizePointsFromPropertiesFile (String productType ) throws UnsupportedOperationException , Exception {
320
329
Properties screenSizeProperties = fetchProperties ();
321
330
String screenDimensionString = (String ) screenSizeProperties .get (productType );
322
331
if (screenDimensionString == null ){
323
- throw new Exception ("ios-screen-size.properties is missing entry for: " + productType );
332
+ throw new UnsupportedOperationException ("ios-screen-size.properties is missing entry for: " + productType );
324
333
}
325
334
String screenDimensions [] = screenDimensionString .split (" x " );
326
335
if (screenDimensions .length !=2 ){
0 commit comments