1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package io.wcm.qa.glnm.galen.util;
21
22 import static io.wcm.qa.glnm.configuration.GaleniumConfiguration.getMediaQueryHeight;
23 import static io.wcm.qa.glnm.webdriver.WebDriverManagement.getCurrentDriver;
24
25 import org.openqa.selenium.Dimension;
26
27 import com.galenframework.browser.Browser;
28 import com.galenframework.browser.SeleniumBrowser;
29 import com.galenframework.config.GalenConfig;
30 import com.galenframework.config.GalenProperty;
31 import com.galenframework.utils.GalenUtils;
32
33 import io.wcm.qa.glnm.context.GaleniumContext;
34
35
36
37
38
39
40 public final class GalenHelperUtil {
41
42 private GalenHelperUtil() {
43
44 }
45
46
47
48
49
50
51
52 public static void adjustViewport(boolean adjustBrowserViewportSize) {
53 GalenConfig.getConfig().setProperty(
54 GalenProperty.GALEN_BROWSER_VIEWPORT_ADJUSTSIZE,
55 Boolean.toString(adjustBrowserViewportSize));
56 }
57
58
59
60
61
62
63
64 public static Browser getBrowser() {
65 return new SeleniumBrowser(GaleniumContext.getDriver());
66 }
67
68
69
70
71
72
73
74
75 public static Dimension getDimension(String size) {
76 java.awt.Dimension parsedSize = GalenUtils.readSize(size);
77 return new Dimension(parsedSize.width, parsedSize.height);
78 }
79
80
81
82
83
84
85
86 public static void resizeViewport(Dimension size) {
87 GalenUtils.resizeDriver(getCurrentDriver(), size.getWidth(), size.getHeight());
88 }
89
90
91
92
93
94
95
96 public static void resizeViewport(int width) {
97 resizeViewport(new Dimension(width, getMediaQueryHeight()));
98 ;
99 }
100
101 }