Skip to content
This repository has been archived by the owner on Nov 23, 2021. It is now read-only.

Commit

Permalink
#293 Removed usages of deprecated API
Browse files Browse the repository at this point in the history
  • Loading branch information
mkrzyzanowski committed Oct 22, 2018
1 parent ff8a1cc commit ea3396f
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 97 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,6 @@ public final class ConfigKeys {

public static final String WEBDRIVER_CAP_PLATFORM_NAME = "webdriver.cap.platformName";

/**
* @deprecated since 1.6.0; use {@code timings.*} properties
*/
@Deprecated
public static final String WEBDRIVER_DEFAULT_TIMEOUT = "webdriver.defaultTimeout";

public static final String WEBDRIVER_FIREFOX_BIN = "webdriver.firefox.bin";

public static final String WEBDRIVER_MAXIMIZE = "webdriver.maximize";
Expand All @@ -56,15 +50,6 @@ public final class ConfigKeys {

public static final String WEBDRIVER_URL = "webdriver.url";

@Deprecated
public static final String CONFIGURATION_PATHS = "configuration.paths";

@Deprecated
public static final String DEFAULT_PROPERTIES_NAME = "default.properties";

@Deprecated
public static final String JUNIT_RERUNS = "junit.reruns";

public static final String CONFIG_STRATEGY = "bobcat.config";
public static final String WEBDRIVER_PROP_PREFIX = "webdriver.";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import org.openqa.selenium.Dimension;
import org.openqa.selenium.Point;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.interactions.internal.Locatable;
import org.openqa.selenium.interactions.Locatable;

import com.cognifide.qa.bb.frame.FrameSwitcher;
import com.cognifide.qa.bb.scope.frame.FramePath;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
*/
public class WebDriverWrapper extends EventFiringWebDriver implements
HasCapabilities, MobileDriver, HasNetworkConnection, PushesFiles, StartsActivity,
FindsByAndroidUIAutomator, FindsByIosUIAutomation, HasIdentity, HasDeviceTime, HidesKeyboard,
FindsByAndroidUIAutomator, FindsByIosUIAutomation, HasDeviceTime, HidesKeyboard,
HidesKeyboardWithKeyName, PressesKeyCode, ShakesDevice, HasSessionDetails {

private final FrameSwitcher frameSwitcher;
Expand Down Expand Up @@ -439,11 +439,6 @@ public void longPressKeyCode(int key, Integer metastate) {
((AndroidDriver) super.getWrappedDriver()).longPressKeyCode(key, metastate);
}

@Override
public String getId() {
return UUID.randomUUID().toString();
}

@Override
public Response execute(String driverCommand) {
return ((ExecutesMethod) super.getWrappedDriver()).execute(driverCommand);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,25 +19,21 @@
*/
package com.cognifide.qa.bb.scope;

import static org.openqa.selenium.support.ui.ExpectedConditions.visibilityOf;

import java.lang.reflect.Field;
import java.util.Arrays;
import java.util.Collections;
import java.util.Optional;
import java.util.concurrent.TimeUnit;
import java.util.function.Function;

import org.openqa.selenium.NoSuchElementException;
import org.openqa.selenium.StaleElementReferenceException;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.cognifide.qa.bb.constants.ConfigKeys;
import com.cognifide.qa.bb.constants.Timeouts;
import com.cognifide.qa.bb.qualifier.CurrentScope;
import com.cognifide.qa.bb.qualifier.PageObject;
import com.cognifide.qa.bb.wait.BobcatWait;
import com.google.inject.Inject;
import com.google.inject.name.Named;

/**
* Contains methods for working with page objects current scopes.
Expand All @@ -46,17 +42,11 @@
*/
public class CurrentScopeHelper {

private static final Logger LOG = LoggerFactory.getLogger(CurrentScopeHelper.class);

private static final String NO_CURRENT_SCOPE_MESSAGE_FORMAT =
"%s doesn't contain @CurrentScope WebElement";

@Inject
private WebDriver webDriver;

@Inject
@Named(ConfigKeys.WEBDRIVER_DEFAULT_TIMEOUT)
private int defaultTimeout;
private BobcatWait bobcatWait;

/**
* Verifies if @CurrentScope from @PageObject class is visible.
Expand All @@ -66,17 +56,8 @@ public class CurrentScopeHelper {
* @return true if element represented by PageObject class is visible.
*/
public boolean isCurrentScopeVisible(Object pageObject) {
webDriver.manage().timeouts().implicitlyWait(Timeouts.MINIMAL, TimeUnit.SECONDS);
boolean isDisplayed = false;

try {
isDisplayed = getCurrentScope(pageObject).isDisplayed();
} catch (NoSuchElementException | StaleElementReferenceException e) {
LOG.debug("WebElement is not available at the moment: '{}'", e);
} finally {
webDriver.manage().timeouts().implicitlyWait(defaultTimeout, TimeUnit.SECONDS);
}
return isDisplayed;
return bobcatWait.ignoring(Collections.singletonList(StaleElementReferenceException.class))
.isConditionMet(visibilityOf(getCurrentScope(pageObject)));
}

private WebElement getCurrentScope(Object pageObject) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.interactions.internal.Locatable;
import org.openqa.selenium.interactions.Locatable;
import org.openqa.selenium.internal.WrapsElement;
import org.openqa.selenium.support.pagefactory.ElementLocatorFactory;
import org.openqa.selenium.support.pagefactory.internal.LocatingElementHandler;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
package com.cognifide.qa.bb.webelement;

import java.util.List;
import java.util.UUID;

import org.apache.commons.lang3.StringUtils;
import org.openqa.selenium.By;
Expand All @@ -32,7 +31,6 @@
import org.openqa.selenium.WebElement;
import org.openqa.selenium.interactions.Locatable;
import org.openqa.selenium.interactions.internal.Coordinates;
import org.openqa.selenium.internal.HasIdentity;
import org.openqa.selenium.internal.WrapsElement;

import com.google.inject.Inject;
Expand All @@ -41,7 +39,7 @@
/**
* Improves WebElement implementation with custom {@link #sendKeys(CharSequence...)} method
*/
public class BobcatWebElement implements WebElement, Locatable, WrapsElement, HasIdentity {
public class BobcatWebElement implements WebElement, Locatable, WrapsElement {

private static final int SEND_KEYS_RETRIES = 10;

Expand Down Expand Up @@ -190,9 +188,4 @@ private boolean isKeys(CharSequence charSequence) {
private String getValue() {
return element.getAttribute("value");
}

@Override
public String getId() {
return UUID.randomUUID().toString();
}
}

0 comments on commit ea3396f

Please sign in to comment.