12
12
import org .openqa .selenium .NoAlertPresentException ;
13
13
import org .openqa .selenium .OutputType ;
14
14
import org .openqa .selenium .WebDriver .Navigation ;
15
+ import org .openqa .selenium .logging .LogEntries ;
15
16
import org .openqa .selenium .remote .RemoteWebDriver ;
16
17
import org .openqa .selenium .support .ui .ExpectedCondition ;
17
18
23
24
import java .util .function .Supplier ;
24
25
25
26
public class Browser implements IApplication {
27
+
26
28
private final RemoteWebDriver webDriver ;
27
29
private final ITimeoutConfiguration timeouts ;
28
- private Duration timeoutImpl ;
29
30
private final IBrowserProfile browserProfile ;
30
31
private final IConditionalWait conditionalWait ;
31
32
private final ILocalizationManager localizationManager ;
32
33
private final ILocalizedLogger localizedLogger ;
33
34
35
+ private Duration implicitTimeout ;
34
36
35
37
public Browser (RemoteWebDriver remoteWebDriver ) {
36
38
conditionalWait = AqualityServices .getConditionalWait ();
@@ -39,8 +41,8 @@ public Browser(RemoteWebDriver remoteWebDriver) {
39
41
this .browserProfile = AqualityServices .getBrowserProfile ();
40
42
this .timeouts = AqualityServices .get (ITimeoutConfiguration .class );
41
43
webDriver = remoteWebDriver ;
42
- this .timeoutImpl = timeouts .getImplicit ();
43
- getDriver ().manage ().timeouts ().implicitlyWait (timeoutImpl .getSeconds (), TimeUnit .SECONDS );
44
+ this .implicitTimeout = timeouts .getImplicit ();
45
+ getDriver ().manage ().timeouts ().implicitlyWait (implicitTimeout .getSeconds (), TimeUnit .SECONDS );
44
46
setPageLoadTimeout (timeouts .getPageLoad ());
45
47
setScriptTimeout (timeouts .getScript ());
46
48
}
@@ -161,7 +163,7 @@ public void setImplicitWaitTimeout(Duration timeout) {
161
163
localizedLogger .debug ("loc.browser.implicit.timeout" , timeout .getSeconds ());
162
164
if (!timeout .equals (getImplicitWaitTimeout ())) {
163
165
getDriver ().manage ().timeouts ().implicitlyWait (timeout .getSeconds (), TimeUnit .SECONDS );
164
- timeoutImpl = timeout ;
166
+ implicitTimeout = timeout ;
165
167
}
166
168
}
167
169
@@ -201,6 +203,15 @@ public byte[] getScreenshot() {
201
203
return getDriver ().getScreenshotAs (OutputType .BYTES );
202
204
}
203
205
206
+ /**
207
+ * Gets logs from WebDriver.
208
+ * @param logKind Type of logs {@link org.openqa.selenium.logging.LogType}
209
+ * @return Storage of LogEntries.
210
+ */
211
+ public LogEntries getLogs (final String logKind ) {
212
+ return getDriver ().manage ().logs ().get (logKind );
213
+ }
214
+
204
215
/**
205
216
* Executes JS (jQuery) script asynchronous.
206
217
*
@@ -350,6 +361,6 @@ public final BrowserName getBrowserName() {
350
361
}
351
362
352
363
private Duration getImplicitWaitTimeout () {
353
- return timeoutImpl ;
364
+ return implicitTimeout ;
354
365
}
355
366
}
0 commit comments