Skip to content
12 changes: 6 additions & 6 deletions src/main/java/aquality/selenium/browser/Browser.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public Browser(RemoteWebDriver remoteWebDriver, IDriverSettings driverSettings,
this.timeouts = timeouts;
this.timeoutImpl = timeouts.getImplicit();
getDriver().manage().timeouts().implicitlyWait(timeoutImpl, TimeUnit.SECONDS);
setPageLoadTimeOuts(timeouts.getPageLoad());
setPageLoadTimeout(timeouts.getPageLoad());
setScriptTimeout(timeouts.getScript());
}

Expand Down Expand Up @@ -87,14 +87,14 @@ public void goTo(String url) {
* Set Page Load timeout (Will be ignored for Safari https://github.com/SeleniumHQ/selenium-google-code-issue-archive/issues/687)
* @param timeout seconds to wait
*/
public void setPageLoadTimeOuts(Long timeout) {
public void setPageLoadTimeout(Long timeout) {
if(!getBrowserName().equals(BrowserName.SAFARI)){
getDriver().manage().timeouts().pageLoadTimeout(timeout, TimeUnit.SECONDS);
}
}

public void setImplicitWaitTimeOut(Long timeout) {
if(!timeout.equals(getTimeoutImpl())){
public void setImplicitWaitTimeout(Long timeout) {
if(!timeout.equals(getImplicitWaitTimeout())){
getDriver().manage().timeouts().implicitlyWait(timeout, TimeUnit.SECONDS);
timeoutImpl = timeout;
}
Expand Down Expand Up @@ -198,11 +198,11 @@ public void scrollWindowBy(int x, int y) {
executeScript(JavaScript.SCROLL_WINDOW_BY.getScript(), x, y);
}

public void setSize(int width, int height){
public void setWindowSize(int width, int height){
getDriver().manage().window().setSize(new Dimension(width, height));
}

public Long getTimeoutImpl() {
private Long getImplicitWaitTimeout() {
return timeoutImpl;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ private enum TIMEOUT {
IMPLICIT("timeoutImplicit"),
CONDITION("timeoutCondition"),
SCRIPT("timeoutScript"),
PAGE_LOAD("timeoutPageload"),
PAGE_LOAD("timeoutPageLoad"),
POLL_INTERVAL("timeoutPollingInterval");

private String key;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/aquality/selenium/elements/CheckBox.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public void toggle() {

@Override
public CheckBoxJsActions getJsActions() {
return new CheckBoxJsActions(this, getElementType(), getName());
return new CheckBoxJsActions(this, getElementType());
}

/**
Expand Down
14 changes: 7 additions & 7 deletions src/main/java/aquality/selenium/elements/ComboBox.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,16 @@ public void selectByIndex(int index) {
}

@Override
public void selectByText(String value) {
getLogger().info(getLocManager().getValue("loc.combobox.select.by.text"), value);
public void selectByText(String text) {
getLogger().info(getLocManager().getValue("loc.combobox.select.by.text"), text);
ConditionalWait.waitFor(y -> {
new Select(getElement()).selectByVisibleText(value);
new Select(getElement()).selectByVisibleText(text);
return true;
});
}

@Override
public void selectOptionThatContainsText(String text) {
public void selectByContainingText(String text) {
info(LOG_SELECTING_VALUE);
ConditionalWait.waitFor(y -> {
Select select = new Select(getElement());
Expand All @@ -63,7 +63,7 @@ public void selectOptionThatContainsText(String text) {
}

@Override
public void selectOptionThatContainsValue(String value) {
public void selectByContainingValue(String value) {
info(LOG_SELECTING_VALUE);
ConditionalWait.waitFor(y -> {
Select select = new Select(getElement());
Expand Down Expand Up @@ -98,7 +98,7 @@ public String getSelectedText() {
}

@Override
public List<String> getValuesList() {
public List<String> getValues() {
getLogger().info(getLocManager().getValue("loc.combobox.get.values"));
if(ElementFinder.getInstance().findElements(getLocator(), getDefaultTimeout(), getElementState()).isEmpty()){
throw new IllegalStateException(String.format(getLocManager().getValue("loc.element.wasnotfoundinstate"), getName(), getElementState(), getDefaultTimeout()));
Expand All @@ -119,7 +119,7 @@ public String getSelectedTextByJs() {

@Override
public ComboBoxJsActions getJsActions() {
return new ComboBoxJsActions(this, getElementType(), getName());
return new ComboBoxJsActions(this, getElementType());
}

}
22 changes: 7 additions & 15 deletions src/main/java/aquality/selenium/elements/Element.java
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,10 @@ public By getLocator() {
return locator;
}

@Override
/**
* get element state that used for interactions
* @return state of element that used for interactions
*/
public ElementState getElementState() {
return state;
}
Expand Down Expand Up @@ -148,7 +151,7 @@ public String getAttribute(final String attr, HighlightState highlightState) {
if (highlightState.equals(HighlightState.HIGHLIGHT)) {
getJsActions().highlightElement();
}
return String.valueOf(ConditionalWait.<String>waitFor(y -> getElement().getAttribute(attr)));
return ConditionalWait.waitFor(y -> getElement().getAttribute(attr));
}

@Override
Expand Down Expand Up @@ -177,17 +180,6 @@ public void setInnerHtml(final String value) {
getBrowser().executeScript(JavaScript.SET_INNER_HTML.getScript(), getElement(), value);
}

@Override
public void clickRight() {
info(String.format(getLocManager().getValue("loc.clicking.right")));
ConditionalWait.waitFor(y -> {
Actions actions = new Actions(getBrowser().getDriver());
actions.moveToElement(getElement());
actions.contextClick(getElement()).build().perform();
return true;
});
}

@Override
public void focus() {
ConditionalWait.waitFor(y -> {
Expand Down Expand Up @@ -216,12 +208,12 @@ protected void info(final String message) {

@Override
public JsActions getJsActions() {
return new JsActions(this, getElementType(), getName());
return new JsActions(this, getElementType());
}

@Override
public MouseActions getMouseActions() {
return new MouseActions(this, getElementType(), getName());
return new MouseActions(this, getElementType());
}

@Override
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/aquality/selenium/elements/ElementFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -79,23 +79,23 @@ public <T extends IElement> T findChildElement(IElement parentElement, By childL
}

@Override
public <T extends IElement> List<T> findElements(By locator, IElementSupplier<T> supplier, ExpectedCount count,
public <T extends IElement> List<T> findElements(By locator, IElementSupplier<T> supplier, ElementsCount count,
ElementState state) {
return findElementsCore(locator, supplier, state, count);
}

@Override
public <T extends IElement> List<T> findElements(By locator, Class<? extends IElement> clazz, ElementState state, ExpectedCount count) {
public <T extends IElement> List<T> findElements(By locator, Class<? extends IElement> clazz, ElementState state, ElementsCount count) {
return findElementsCore(locator, getDefaultElementSupplier(clazz), state, count);
}

@Override
public <T extends IElement> List<T> findElements(By locator, ElementType type, ElementState state, ExpectedCount count) {
public <T extends IElement> List<T> findElements(By locator, ElementType type, ElementState state, ElementsCount count) {
return findElements(locator, type.getClazz(), state, count);
}

private <T extends IElement> List<T> findElementsCore(By locator, IElementSupplier<T> supplier,
ElementState state, ExpectedCount count) {
ElementState state, ElementsCount count) {
List<T> elements = new ArrayList<>();
switch (count) {
case ZERO:
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/aquality/selenium/elements/ElementFinder.java
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ List<WebElement> findElements(By locator, long timeout, DesiredState desiredStat
List<WebElement> foundElements = new ArrayList<>();
List<WebElement> resultElements = new ArrayList<>();
long zeroTimeout = 0L;
getBrowser().setImplicitWaitTimeOut(zeroTimeout);
getBrowser().setImplicitWaitTimeout(zeroTimeout);
try{
ConditionalWait.waitFor(driver ->
{
Expand All @@ -80,7 +80,7 @@ List<WebElement> findElements(By locator, long timeout, DesiredState desiredStat
}catch (TimeoutException e){
applyResult(locator, desiredState, foundElements);
}
getBrowser().setImplicitWaitTimeOut(getTimeoutConfiguration().getImplicit());
getBrowser().setImplicitWaitTimeout(getTimeoutConfiguration().getImplicit());
return resultElements;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package aquality.selenium.elements;

public enum ExpectedCount {
public enum ElementsCount {
ZERO,
MORE_THEN_ZERO
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@

public class CheckBoxJsActions extends JsActions {

public CheckBoxJsActions(ICheckBox checkBox, String elementType, String name) {
super(checkBox, elementType, name);
public CheckBoxJsActions(ICheckBox checkBox, String elementType) {
super(checkBox, elementType);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@

public class ComboBoxJsActions extends JsActions {

public ComboBoxJsActions(IComboBox comboBox, String elementType, String name) {
super(comboBox, elementType, name);
public ComboBoxJsActions(IComboBox comboBox, String elementType) {
super(comboBox, elementType);
}

/**
* Values from ComboBox by js
*
* @return values from ComboBox
*/
public List<String> getValuesList() {
public List<String> getValues() {
return (List<String>) executeScript(JavaScript.GET_COMBOBOX_VALUES, element);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ public class JsActions {
private String name;


public JsActions(IElement element, String type, String name) {
public JsActions(IElement element, String type) {
this.element = element;
this.type = type;
this.name = name;
this.name = element.getName();
}

/**
Expand Down Expand Up @@ -56,7 +56,7 @@ public void highlightElement() {
/**
* Scrolling to element
*/
public void scrollToView() {
public void scrollIntoView() {
infoLoc("loc.scrolling.js");
executeScript(JavaScript.SCROLL_TO_ELEMENT, element, true);
}
Expand Down
19 changes: 16 additions & 3 deletions src/main/java/aquality/selenium/elements/actions/MouseActions.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,34 @@ public class MouseActions {
private String name;


public MouseActions(IElement element, String type, String name) {
public MouseActions(IElement element, String type) {
this.element = element;
this.type = type;
this.name = name;
this.name = element.getName();
}

/**
* Click via Action.
*/
public void click() {
infoLoc("loc.clicking");
new JsActions(element, type, name).highlightElement();
new JsActions(element, type).highlightElement();
ConditionalWait.waitFor(driver -> performAction(new Actions(driver).click(element.getElement())));
}

/**
* Right Click on the element
*/
public void rightClick() {
infoLoc("loc.clicking.right");
ConditionalWait.waitFor(driver -> {
Actions actions = new Actions(driver);
actions.moveToElement(element.getElement());
actions.contextClick(element.getElement()).build().perform();
return true;
});
}

/**
* Move mouse to this element.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,23 @@ public interface IComboBox extends IElement {
/**
* Select by visible text
*
* @param value text to be selected
* @param text text to be selected
*/
void selectByText(String value);
void selectByText(String text);

/**
* Select by containing visible text
*
* @param text visible text
*/
void selectOptionThatContainsText(String text);
void selectByContainingText(String text);

/**
* Select by containing value
*
* @param value partial option's value
*/
void selectOptionThatContainsValue(String value);
void selectByContainingValue(String value);

/**
* Select by value
Expand All @@ -52,7 +52,7 @@ public interface IComboBox extends IElement {
* Get values list
* @return list of values
*/
List<String> getValuesList();
List<String> getValues();

/**
* Get text from selected option in combobox using JavaScript
Expand Down
11 changes: 0 additions & 11 deletions src/main/java/aquality/selenium/elements/interfaces/IElement.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,6 @@ public interface IElement extends IParent {
*/
By getLocator();

/**
* get element state that used for interactions
* @return state of element that used for interactions
*/
ElementState getElementState();

/**
* get element name
* @return name
Expand Down Expand Up @@ -112,11 +106,6 @@ public interface IElement extends IParent {
*/
void setInnerHtml(String value);

/**
* Right Click on the element
*/
void clickRight();

/**
* Focuses the element
*/
Expand Down
Loading