Skip to content

Commit 616ffb1

Browse files
authored
Add method getLogs to Browser (#98)
* Add method getLogs to Browser * Increase version * Update aquality-selenium-core
1 parent dbcc815 commit 616ffb1

File tree

3 files changed

+19
-8
lines changed

3 files changed

+19
-8
lines changed

pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<groupId>com.github.aquality-automation</groupId>
88
<artifactId>aquality-selenium</artifactId>
9-
<version>2.2.0</version>
9+
<version>2.3.0</version>
1010

1111
<packaging>jar</packaging>
1212
<name>Aquality Selenium</name>
@@ -74,7 +74,7 @@
7474
<dependency>
7575
<groupId>com.github.aquality-automation</groupId>
7676
<artifactId>aquality-selenium-core</artifactId>
77-
<version>1.0.1</version>
77+
<version>1.0.2</version>
7878
</dependency>
7979

8080
<dependency>

src/main/java/aquality/selenium/browser/Browser.java

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import org.openqa.selenium.NoAlertPresentException;
1313
import org.openqa.selenium.OutputType;
1414
import org.openqa.selenium.WebDriver.Navigation;
15+
import org.openqa.selenium.logging.LogEntries;
1516
import org.openqa.selenium.remote.RemoteWebDriver;
1617
import org.openqa.selenium.support.ui.ExpectedCondition;
1718

@@ -23,14 +24,15 @@
2324
import java.util.function.Supplier;
2425

2526
public class Browser implements IApplication {
27+
2628
private final RemoteWebDriver webDriver;
2729
private final ITimeoutConfiguration timeouts;
28-
private Duration timeoutImpl;
2930
private final IBrowserProfile browserProfile;
3031
private final IConditionalWait conditionalWait;
3132
private final ILocalizationManager localizationManager;
3233
private final ILocalizedLogger localizedLogger;
3334

35+
private Duration implicitTimeout;
3436

3537
public Browser(RemoteWebDriver remoteWebDriver) {
3638
conditionalWait = AqualityServices.getConditionalWait();
@@ -39,8 +41,8 @@ public Browser(RemoteWebDriver remoteWebDriver) {
3941
this.browserProfile = AqualityServices.getBrowserProfile();
4042
this.timeouts = AqualityServices.get(ITimeoutConfiguration.class);
4143
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);
4446
setPageLoadTimeout(timeouts.getPageLoad());
4547
setScriptTimeout(timeouts.getScript());
4648
}
@@ -161,7 +163,7 @@ public void setImplicitWaitTimeout(Duration timeout) {
161163
localizedLogger.debug("loc.browser.implicit.timeout", timeout.getSeconds());
162164
if (!timeout.equals(getImplicitWaitTimeout())) {
163165
getDriver().manage().timeouts().implicitlyWait(timeout.getSeconds(), TimeUnit.SECONDS);
164-
timeoutImpl = timeout;
166+
implicitTimeout = timeout;
165167
}
166168
}
167169

@@ -201,6 +203,15 @@ public byte[] getScreenshot() {
201203
return getDriver().getScreenshotAs(OutputType.BYTES);
202204
}
203205

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+
204215
/**
205216
* Executes JS (jQuery) script asynchronous.
206217
*
@@ -350,6 +361,6 @@ public final BrowserName getBrowserName() {
350361
}
351362

352363
private Duration getImplicitWaitTimeout() {
353-
return timeoutImpl;
364+
return implicitTimeout;
354365
}
355366
}

src/main/java/aquality/selenium/configuration/BrowserProfile.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public boolean isElementHighlightEnabled() {
3636
@Override
3737
public IDriverSettings getDriverSettings() {
3838
IDriverSettings driverSettings;
39-
switch (getBrowserName()){
39+
switch (getBrowserName()) {
4040
case CHROME:
4141
driverSettings = new ChromeSettings(settingsFile);
4242
break;

0 commit comments

Comments
 (0)