Skip to content

Commit

Permalink
Added docs for public methods (#64)
Browse files Browse the repository at this point in the history
* added documentation to some public methods

* #63 small fixes in docs

* #63 try to fix testSetFocus

* #63 updated doc for isRemote and getLanguage
updated version in pom and readme
  • Loading branch information
knysh authored and DmitryBogatko committed Oct 17, 2019
1 parent 40a4f3c commit 34b1995
Show file tree
Hide file tree
Showing 13 changed files with 303 additions and 3 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ We use interfaces where is possible, so you can implement your own version of ta
<dependency>
<groupId>com.github.aquality-automation</groupId>
<artifactId>aquality-selenium</artifactId>
<version>1.1.2</version>
<version>1.1.3</version>
</dependency>
```

Expand Down
2 changes: 1 addition & 1 deletion 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>1.1.2</version>
<version>1.1.3</version>
<packaging>jar</packaging>

<name>Aquality Selenium</name>
Expand Down
18 changes: 18 additions & 0 deletions src/main/java/aquality/selenium/browser/BrowserManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,41 @@
import aquality.selenium.configuration.Configuration;
import aquality.selenium.configuration.IConfiguration;

/**
* Controls browser instance creation.
*/
public class BrowserManager {
private static final ThreadLocal<Browser> browserContainer = new ThreadLocal<>();
private static final ThreadLocal<IBrowserFactory> factoryContainer = new ThreadLocal<>();

private BrowserManager(){
}

/**
* Gets instance of browser.
* @return Instance of desired browser.
*/
public static Browser getBrowser(){
if(browserContainer.get() == null || browserContainer.get().getDriver().getSessionId() == null) {
setDefaultBrowser();
}
return browserContainer.get();
}

/**
* Sets default(local {@link LocalBrowserFactory} or remote {@link RemoteBrowserFactory}) browser factory.
*/
public static void setDefaultFactory(){
IConfiguration configuration = Configuration.getInstance();
IBrowserFactory browserFactory = Configuration.getInstance().getBrowserProfile().isRemote()
? new RemoteBrowserFactory(configuration) : new LocalBrowserFactory(configuration);
setFactory(browserFactory);
}

/**
* Sets custom browser factory.
* @param browserFactory Custom implementation of {@link IBrowserFactory}
*/
public static void setFactory(IBrowserFactory browserFactory){
remove(factoryContainer);
BrowserManager.factoryContainer.set(browserFactory);
Expand All @@ -36,6 +50,10 @@ private static void setDefaultBrowser(){
setBrowser(factoryContainer.get().getBrowser());
}

/**
* Sets instance of browser.
* @param browser Instance of desired browser.
*/
public static void setBrowser(Browser browser){
remove(browserContainer);
BrowserManager.browserContainer.set(browser);
Expand Down
7 changes: 7 additions & 0 deletions src/main/java/aquality/selenium/browser/IBrowserFactory.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
package aquality.selenium.browser;

/**
* Factory that creates instance of desired Browser based on {@link aquality.selenium.configuration.IConfiguration}
*/
public interface IBrowserFactory {

/**
* Gets instance of Browser.
* @return Instance of desired Browser.
*/
Browser getBrowser();
}
23 changes: 23 additions & 0 deletions src/main/java/aquality/selenium/configuration/IBrowserProfile.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,38 @@

import java.net.URL;

/**
* Describes browser settings.
*/
public interface IBrowserProfile {

/**
* Gets name of target browser.
* @return Browser name.
*/
BrowserName getBrowserName();

/**
* Checks if is remote browser or not.
* @return true if remote browser and false if local.
*/
boolean isRemote();

/**
* Is element hightlight enabled or not.
* @return true if element highlight is enabled and false otherwise.
*/
boolean isElementHighlightEnabled();

/**
* Gets driver settings for target browser.
* @return Driver settings.
*/
IDriverSettings getDriverSettings();

/**
* Gets remote connection URI is case of remote browser.
* @return Remote connection URI.
*/
URL getRemoteConnectionUrl();
}
19 changes: 19 additions & 0 deletions src/main/java/aquality/selenium/configuration/IConfiguration.java
Original file line number Diff line number Diff line change
@@ -1,12 +1,31 @@
package aquality.selenium.configuration;

/**
* Describes tool configuration.
*/
public interface IConfiguration {

/**
* Gets desired browser profile.
* @return Profile of browser.
*/
IBrowserProfile getBrowserProfile();

/**
* Gets configuration of timeouts.
* @return Configuration of timeouts.
*/
ITimeoutConfiguration getTimeoutConfiguration();

/**
* Gets configuration of retries.
* @return Configuration of retries.
*/
IRetryConfiguration getRetryConfiguration();

/**
* Gets configuration of logger.
* @return Configuration of logger.
*/
ILoggerConfiguration getLoggerConfiguration();
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,14 @@

import aquality.selenium.localization.SupportedLanguage;

/**
* Describes logger configuration.
*/
public interface ILoggerConfiguration {

/**
* Gets language which will be used for framework logger.
* @return Supported language.
*/
SupportedLanguage getLanguage();
}
Original file line number Diff line number Diff line change
@@ -1,16 +1,43 @@
package aquality.selenium.configuration;

/**
* Describes timeouts configuration.
*/
public interface ITimeoutConfiguration {

/**
* Gets WedDriver ImplicitWait timeout.
* @return ImplicitWait timeout.
*/
long getImplicit();

/**
* Gets default ConditionalWait timeout.
* @return ConditionalWait timeout.
*/
long getCondition();

/**
* Gets WedDriver AsynchronousJavaScript timeout.
* @return AsynchronousJavaScript timeout.
*/
long getScript();

/**
* Gets WedDriver PageLoad timeout.
* @return PageLoad timeout.
*/
long getPageLoad();

/**
* Gets ConditionalWait polling interval.
* @return ConditionalWait polling interval.
*/
long getPollingInterval();

/**
* Gets Command timeout.
* @return Command timeout.
*/
long getCommand();
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,51 @@
import aquality.selenium.utils.JsonFile;
import org.openqa.selenium.Capabilities;

/**
* Describes web driver settings.
*/
public interface IDriverSettings {

/**
* Gets web driver capabilities.
* @return initialized {@link Capabilities}
*/
Capabilities getCapabilities();

/**
* Gets version of web driver for WebDriverManager.
* @return Version of web driver.
*/
String getWebDriverVersion();

/**
* Gets target system architecture for WebDriverManager.
* @return System architecture.
*/
String getSystemArchitecture();

/**
* Gets download directory for web driver.
* @return Path to download directory.
*/
String getDownloadDir();

/**
* Gets web driver capability key for download directory.
* @return Web driver capability key
*/
String getDownloadDirCapabilityKey();

/**
* Get desired browser name.
* @return Browser name
*/
BrowserName getBrowserName();

/**
* Gets desired json file.
* @return Json file.
*/
JsonFile getSettingsFile();

}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
import aquality.selenium.browser.JavaScript;
import aquality.selenium.elements.interfaces.ICheckBox;

/**
* Allows to perform actions on elements via JavaScript specific for CheckBoxes.
*/
public class CheckBoxJsActions extends JsActions {

public CheckBoxJsActions(ICheckBox checkBox, String elementType) {
Expand All @@ -17,18 +20,31 @@ public boolean getState() {
return Boolean.valueOf(executeScript(JavaScript.GET_CHECKBOX_STATE, element).toString());
}

/**
* Performs check action on the element.
*/
public void check() {
setState(true);
}

/**
* Performs uncheck action on the element.
*/
public void uncheck() {
setState(false);
}

/**
* Get status if element is checked
* @return true if checked, false otherwise
*/
public boolean isChecked() {
return getState();
}

/**
* Performs toggle action on the element.
*/
public void toggle() {
setState(!isChecked());
}
Expand Down
Loading

0 comments on commit 34b1995

Please sign in to comment.