Skip to content

Commit

Permalink
Add method getLogs to Browser (#98)
Browse files Browse the repository at this point in the history
* Add method getLogs to Browser

* Increase version

* Update aquality-selenium-core
  • Loading branch information
paveliam authored May 21, 2020
1 parent dbcc815 commit 616ffb1
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 8 deletions.
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>com.github.aquality-automation</groupId>
<artifactId>aquality-selenium</artifactId>
<version>2.2.0</version>
<version>2.3.0</version>

<packaging>jar</packaging>
<name>Aquality Selenium</name>
Expand Down Expand Up @@ -74,7 +74,7 @@
<dependency>
<groupId>com.github.aquality-automation</groupId>
<artifactId>aquality-selenium-core</artifactId>
<version>1.0.1</version>
<version>1.0.2</version>
</dependency>

<dependency>
Expand Down
21 changes: 16 additions & 5 deletions src/main/java/aquality/selenium/browser/Browser.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import org.openqa.selenium.NoAlertPresentException;
import org.openqa.selenium.OutputType;
import org.openqa.selenium.WebDriver.Navigation;
import org.openqa.selenium.logging.LogEntries;
import org.openqa.selenium.remote.RemoteWebDriver;
import org.openqa.selenium.support.ui.ExpectedCondition;

Expand All @@ -23,14 +24,15 @@
import java.util.function.Supplier;

public class Browser implements IApplication {

private final RemoteWebDriver webDriver;
private final ITimeoutConfiguration timeouts;
private Duration timeoutImpl;
private final IBrowserProfile browserProfile;
private final IConditionalWait conditionalWait;
private final ILocalizationManager localizationManager;
private final ILocalizedLogger localizedLogger;

private Duration implicitTimeout;

public Browser(RemoteWebDriver remoteWebDriver) {
conditionalWait = AqualityServices.getConditionalWait();
Expand All @@ -39,8 +41,8 @@ public Browser(RemoteWebDriver remoteWebDriver) {
this.browserProfile = AqualityServices.getBrowserProfile();
this.timeouts = AqualityServices.get(ITimeoutConfiguration.class);
webDriver = remoteWebDriver;
this.timeoutImpl = timeouts.getImplicit();
getDriver().manage().timeouts().implicitlyWait(timeoutImpl.getSeconds(), TimeUnit.SECONDS);
this.implicitTimeout = timeouts.getImplicit();
getDriver().manage().timeouts().implicitlyWait(implicitTimeout.getSeconds(), TimeUnit.SECONDS);
setPageLoadTimeout(timeouts.getPageLoad());
setScriptTimeout(timeouts.getScript());
}
Expand Down Expand Up @@ -161,7 +163,7 @@ public void setImplicitWaitTimeout(Duration timeout) {
localizedLogger.debug("loc.browser.implicit.timeout", timeout.getSeconds());
if (!timeout.equals(getImplicitWaitTimeout())) {
getDriver().manage().timeouts().implicitlyWait(timeout.getSeconds(), TimeUnit.SECONDS);
timeoutImpl = timeout;
implicitTimeout = timeout;
}
}

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

/**
* Gets logs from WebDriver.
* @param logKind Type of logs {@link org.openqa.selenium.logging.LogType}
* @return Storage of LogEntries.
*/
public LogEntries getLogs(final String logKind) {
return getDriver().manage().logs().get(logKind);
}

/**
* Executes JS (jQuery) script asynchronous.
*
Expand Down Expand Up @@ -350,6 +361,6 @@ public final BrowserName getBrowserName() {
}

private Duration getImplicitWaitTimeout() {
return timeoutImpl;
return implicitTimeout;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public boolean isElementHighlightEnabled() {
@Override
public IDriverSettings getDriverSettings() {
IDriverSettings driverSettings;
switch (getBrowserName()){
switch (getBrowserName()) {
case CHROME:
driverSettings = new ChromeSettings(settingsFile);
break;
Expand Down

0 comments on commit 616ffb1

Please sign in to comment.