-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feature/38 enhance element property getters logging (#54)
* Added logPageSource parameter to settings * Added logging of values for getAttribute() and getText() of Element * Enhanced LocalizationManager to get value from core if the key is missed in passed assembly * Added logging to ElementStateProviders' waiting functions
- Loading branch information
Showing
26 changed files
with
352 additions
and
52 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
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
18 changes: 15 additions & 3 deletions
18
src/main/java/aquality/selenium/core/elements/ElementStateProvider.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,27 +1,39 @@ | ||
package aquality.selenium.core.elements; | ||
|
||
import aquality.selenium.core.elements.interfaces.IElementStateProvider; | ||
import aquality.selenium.core.elements.interfaces.ILogElementState; | ||
import org.openqa.selenium.WebElement; | ||
|
||
public abstract class ElementStateProvider implements IElementStateProvider { | ||
|
||
private final ILogElementState logger; | ||
|
||
protected ElementStateProvider(ILogElementState logger) { | ||
this.logger = logger; | ||
} | ||
|
||
protected void logElementState(String messageKey, String conditionKeyPart) { | ||
String conditionKey = "loc.el.state.".concat(conditionKeyPart); | ||
logger.logElementState(messageKey, conditionKey); | ||
} | ||
|
||
protected boolean isElementEnabled(WebElement element) { | ||
return element.isEnabled(); | ||
} | ||
|
||
protected DesiredState elementEnabled() { | ||
return new DesiredState(this::isElementEnabled, "ENABLED") | ||
return new DesiredState(this::isElementEnabled, "enabled") | ||
.withCatchingTimeoutException() | ||
.withThrowingNoSuchElementException(); | ||
} | ||
|
||
protected DesiredState elementNotEnabled() { | ||
return new DesiredState(element -> !isElementEnabled(element), "NOT ENABLED") | ||
return new DesiredState(element -> !isElementEnabled(element), "not.enabled") | ||
.withCatchingTimeoutException() | ||
.withThrowingNoSuchElementException(); | ||
} | ||
|
||
protected DesiredState elementClickable() { | ||
return new DesiredState(webElement -> webElement.isDisplayed() && webElement.isEnabled(), "CLICKABLE"); | ||
return new DesiredState(webElement -> webElement.isDisplayed() && webElement.isEnabled(), "clickable"); | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
src/main/java/aquality/selenium/core/elements/interfaces/ILogElementState.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 |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package aquality.selenium.core.elements.interfaces; | ||
|
||
/** | ||
* Describes interface that can log element state. | ||
*/ | ||
public interface ILogElementState { | ||
/** | ||
* Logs element state. | ||
* @param messageKey key of localized message to log. | ||
* @param stateKey key of localized state to log. | ||
*/ | ||
void logElementState(String messageKey, String stateKey); | ||
} |
Oops, something went wrong.