Skip to content

Commit 84f66ce

Browse files
committed
[1.4.2-minor fixes] - common fixes
1 parent a3a352c commit 84f66ce

File tree

1 file changed

+26
-22
lines changed

1 file changed

+26
-22
lines changed

src/main/java/util/validator/ResponsiveUIValidator.java

Lines changed: 26 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -263,33 +263,37 @@ public void generateReport(String name) {
263263
}
264264

265265
void drawScreenshot() {
266-
g = img.createGraphics();
266+
if (img != null) {
267+
g = img.createGraphics();
267268

268-
drawRoot(rootColor);
269+
drawRoot(rootColor);
269270

270-
for (Object obj : errorMessage) {
271-
JSONObject det = (JSONObject) obj;
272-
JSONObject details = (JSONObject) det.get(REASON);
273-
JSONObject numE = (JSONObject) details.get(ELEMENT);
271+
for (Object obj : errorMessage) {
272+
JSONObject det = (JSONObject) obj;
273+
JSONObject details = (JSONObject) det.get(REASON);
274+
JSONObject numE = (JSONObject) details.get(ELEMENT);
274275

275-
if (numE != null) {
276-
float x = (float) numE.get(X);
277-
float y = (float) numE.get(Y);
278-
float width = (float) numE.get(WIDTH);
279-
float height = (float) numE.get(HEIGHT);
276+
if (numE != null) {
277+
float x = (float) numE.get(X);
278+
float y = (float) numE.get(Y);
279+
float width = (float) numE.get(WIDTH);
280+
float height = (float) numE.get(HEIGHT);
280281

281-
g.setColor(highlightedElementsColor);
282-
g.setStroke(new BasicStroke(2));
283-
g.drawRect(retinaValue((int) x), retinaValue(mobileY((int) y)), retinaValue((int) width), retinaValue((int) height));
282+
g.setColor(highlightedElementsColor);
283+
g.setStroke(new BasicStroke(2));
284+
g.drawRect(retinaValue((int) x), retinaValue(mobileY((int) y)), retinaValue((int) width), retinaValue((int) height));
285+
}
284286
}
285-
}
286287

287-
try {
288-
ImageIO.write(img, "png", screenshot);
289-
File file = new File(TARGET_AUTOMOTION_IMG + rootElementReadableName.replace(" ", "") + "-" + screenshot.getName());
290-
FileUtils.copyFile(screenshot, file);
291-
} catch (IOException e) {
292-
e.printStackTrace();
288+
try {
289+
ImageIO.write(img, "png", screenshot);
290+
File file = new File(TARGET_AUTOMOTION_IMG + rootElementReadableName.replace(" ", "") + "-" + screenshot.getName());
291+
FileUtils.copyFile(screenshot, file);
292+
} catch (IOException e) {
293+
e.printStackTrace();
294+
}
295+
} else {
296+
LOG.error("Taking of screenshot was failed for some reason.");
293297
}
294298
}
295299

@@ -731,7 +735,7 @@ int retinaValue(int value) {
731735
}
732736

733737
int mobileY(int value) {
734-
if (isMobile()) {
738+
if (isMobile() && ((AppiumDriver)driver).getContext().startsWith("WEB")) {
735739
if (isIOS()) {
736740
if (isMobileTopBar) {
737741
return value + 20;

0 commit comments

Comments
 (0)