-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feature/support logging of element property getters (#103)
* Add DEBUG logging of capabilities, start arguments and options Disable logging of setScriptTimeout if the value wasn't changed Support logging of ElementStateProvider methods * Reworked BrowserFactory, enhance retrying/logging of driver start Add logging of current URL * Renamed local variables in DriverSettings to fix sonar code smell * Add logging of Browser's waitForPageToLoad() * Add logging of Browser's handle alert methods * Enhanced logging for CheckBox and RadioButton elements * Added logging of element property getters Enhanced logging for ComboBox methods * Add logging of JsActions getters: isElementOnScreen and getXPath Removed redundant localization values unused in the current lib * Add retry for driver creation in case of timeout exception * Updated access modificator of getDriver to protected in LocalBrowserFactory Refactored DriverSettings getMapOrEmpty * Add retry to custom BrowserFactory in tests * Corrected values in localization and settings files * Deprecated Form's isDisplayed() method, add state() instead
- Loading branch information
Showing
36 changed files
with
386 additions
and
266 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 29 additions & 29 deletions
58
src/main/java/aquality/selenium/browser/BrowserFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,42 @@ | ||
package aquality.selenium.browser; | ||
|
||
import aquality.selenium.core.localization.ILocalizationManager; | ||
import aquality.selenium.core.logging.Logger; | ||
import aquality.selenium.configuration.IBrowserProfile; | ||
import aquality.selenium.core.localization.ILocalizedLogger; | ||
import aquality.selenium.core.utilities.IActionRetrier; | ||
import org.openqa.selenium.Capabilities; | ||
import org.openqa.selenium.remote.CommandExecutor; | ||
import org.openqa.selenium.SessionNotCreatedException; | ||
import org.openqa.selenium.TimeoutException; | ||
import org.openqa.selenium.WebDriverException; | ||
import org.openqa.selenium.remote.RemoteWebDriver; | ||
import org.openqa.selenium.remote.UnreachableBrowserException; | ||
|
||
import java.util.Collections; | ||
import java.util.Arrays; | ||
|
||
interface BrowserFactory extends IBrowserFactory { | ||
public abstract class BrowserFactory implements IBrowserFactory { | ||
|
||
default IllegalArgumentException getLoggedWrongBrowserNameException() { | ||
String message = AqualityServices.get(ILocalizationManager.class).getLocalizedMessage("loc.browser.name.wrong"); | ||
IllegalArgumentException exception = new IllegalArgumentException(message); | ||
Logger.getInstance().fatal(message, exception); | ||
return exception; | ||
} | ||
private final IActionRetrier actionRetrier; | ||
private final IBrowserProfile browserProfile; | ||
private final ILocalizedLogger localizedLogger; | ||
|
||
default void logBrowserIsReady(BrowserName browserName) { | ||
AqualityServices.getLocalizedLogger().info("loc.browser.ready", browserName.toString()); | ||
} | ||
protected BrowserFactory(IActionRetrier actionRetrier, IBrowserProfile browserProfile, ILocalizedLogger localizedLogger) { | ||
|
||
default <T extends RemoteWebDriver> T getDriver(Class<T> driverClass, Capabilities capabilities) { | ||
return getDriver(driverClass, null, capabilities); | ||
this.actionRetrier = actionRetrier; | ||
this.browserProfile = browserProfile; | ||
this.localizedLogger = localizedLogger; | ||
} | ||
|
||
default <T extends RemoteWebDriver> T getDriver(Class<T> driverClass, CommandExecutor commandExecutor, Capabilities capabilities) { | ||
return AqualityServices.get(IActionRetrier.class).doWithRetry(() -> { | ||
try { | ||
if (commandExecutor != null) { | ||
return driverClass.getDeclaredConstructor(CommandExecutor.class, Capabilities.class).newInstance(commandExecutor, capabilities); | ||
} | ||
|
||
return driverClass.getDeclaredConstructor(Capabilities.class).newInstance(capabilities); | ||
} catch (ReflectiveOperationException e) { | ||
throw new UnsupportedOperationException(String.format("Cannot instantiate driver with type '%1$s'.", driverClass), e); | ||
} | ||
}, Collections.emptyList()); | ||
protected abstract RemoteWebDriver getDriver(); | ||
|
||
@Override | ||
public Browser getBrowser() { | ||
RemoteWebDriver driver = actionRetrier.doWithRetry( | ||
this::getDriver, | ||
Arrays.asList( | ||
SessionNotCreatedException.class, | ||
UnreachableBrowserException.class, | ||
WebDriverException.class, | ||
TimeoutException.class)); | ||
Browser browser = new Browser(driver); | ||
localizedLogger.info("loc.browser.ready", browserProfile.getBrowserName().toString()); | ||
return browser; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.