Java 类org.openqa.selenium.ElementNotVisibleException 实例源码

项目:ats-framework    文件:RealHtmlButton.java   
private void doClick() {

        try {
            new RealHtmlElementState(this).waitToBecomeExisting();
            WebElement element = RealHtmlElementLocator.findElement(this);
            try {
                element.click();
            } catch (ElementNotVisibleException enve) {
                if (!UiEngineConfigurator.getInstance().isWorkWithInvisibleElements()) {
                    throw enve;
                }
                ((JavascriptExecutor) webDriver).executeScript("arguments[0].click()", element);
            }
        } catch (Exception e) {
            ((AbstractRealBrowserDriver) super.getUiDriver()).clearExpectedPopups();
            throw new SeleniumOperationException(this, "click", e);
        }

        UiEngineUtilities.sleep();

        ((AbstractRealBrowserDriver) super.getUiDriver()).handleExpectedPopups();
    }
项目:bobcat    文件:AemDialog.java   
/**
 * Clicks button at the bottom of edit Window and expect for dialog to disappear.
 *
 * @param buttonText button label
 * @return Returns this dialog instance.
 */
public AemDialog clickDialogFooterButton(final String buttonText) {
  final WebElement footerButton = getFooterButtonWebElement(buttonText);

  bobcatWait.withTimeout(Timeouts.BIG).until((ExpectedCondition<Object>) input -> {
    try {
      footerButton.click();
      footerButton.isDisplayed();
      return Boolean.FALSE;
    } catch (NoSuchElementException | StaleElementReferenceException
        | ElementNotVisibleException e) {
      LOG.debug("Dialog footer button is not available: {}", e);
      return Boolean.TRUE;
    }
  }, 2);
  bobcatWait.withTimeout(Timeouts.MEDIUM).until(CommonExpectedConditions.noAemAjax());
  return this;
}
项目:edx-app-android    文件:NativeAppDriver.java   
/**
 * Overridden webDriver find Elements with proper wait.
 */
@Override
public List<WebElement> findElements(By locator) {

    try {
        (new WebDriverWait(appiumDriver, maxWaitTime))
                .until(ExpectedConditions
                        .presenceOfAllElementsLocatedBy(locator));
    } catch (ElementNotVisibleException e) {
        Reporter.log("Element not found: " + locator.toString());
        captureScreenshot();
        throw e;
    }
    return appiumDriver.findElements(locator);

}
项目:Testy    文件:TabPanel.java   
/**
 * After the tab is set to active will wait 300ms to make sure tab is rendered
 *
 * @return true or false
 */
public boolean setActive() {
    String baseTabPath = "//*[" + getPathBuilder().getBasePath() + "]";
    String titlePath = baseTabPath + getTitlePath();
    WebLocator titleElement = new WebLocator(getPathBuilder().getContainer()).setElPath(titlePath).setInfoMessage(getPathBuilder().getText() + " Tab");
    LOGGER.info("setActive : " + toString());
    boolean activated;
    try {
        activated = titleElement.click();
    } catch (ElementNotVisibleException e) {
        LOGGER.error("setActive Exception: " + e.getMessage());
        activated = setActiveWithExtJS();
    }
    if (activated) {
        Utils.sleep(300); // need to make sure this tab is rendered
    }
    return activated;
}
项目:ats-framework    文件:HtmlFileBrowse.java   
/**
*
* @param webDriver {@link WebDriver} instance
* @param value the file input value to set
*/
protected void setFileInputValue( WebDriver webDriver, String value ) {

    String locator = this.getElementProperties()
                         .getInternalProperty(HtmlElementLocatorBuilder.PROPERTY_ELEMENT_LOCATOR);

    String css = this.getElementProperty("_css");

    WebElement element = null;

    if (!StringUtils.isNullOrEmpty(css)) {
        element = webDriver.findElement(By.cssSelector(css));
    } else {
        element = webDriver.findElement(By.xpath(locator));
    }

    try {
        element.sendKeys(value);
    } catch (ElementNotVisibleException enve) {

        if (!UiEngineConfigurator.getInstance().isWorkWithInvisibleElements()) {
            throw enve;
        }
        // try to make the element visible overriding some CSS properties
        // but keep in mind that it can be still invisible using another CSS and/or JavaScript techniques
        String styleAttrValue = element.getAttribute("style");
        JavascriptExecutor jsExec = (JavascriptExecutor) webDriver;
        try {
            jsExec.executeScript("arguments[0].setAttribute('style', arguments[1]);",
                                 element,
                                 "display:'block'; visibility:'visible'; top:'auto'; left:'auto'; z-index:999;"
                                          + "height:'auto'; width:'auto';");
            element.sendKeys(value);
        } finally {
            jsExec.executeScript("arguments[0].setAttribute('style', arguments[1]);", element,
                                 styleAttrValue);
        }

    } catch (InvalidElementStateException e) {
        throw new SeleniumOperationException(e.getMessage(), e);
    }
}
项目:bobcat    文件:AemDialog.java   
private void openByContextMenu(final WebElement element) {
  waitForComponentOnParsys();
  bobcatWait.withTimeout(Timeouts.BIG).until((ExpectedCondition<Object>) input -> {
    try {
      aemContextMenu.open(element);
      aemContextMenu.clickOption(MenuOption.EDIT);
    } catch (NoSuchElementException | StaleElementReferenceException
        | ElementNotVisibleException e) {
      LOG.debug("Dialog open element is not available: {}", e);
    }
    return isVisible();
  }, 5);
}
项目:AppiumFindByImage    文件:OCR.java   
/**
 * clickByImage is the main method that you should be using to tap on elements on screen using an image.
 * @param targetImgPath takes path to the screenshot of an element that you want to find.
 */
public void clickByImage(String targetImgPath) {
    Point2D coords = getCoords(takeScreenshot(), targetImgPath);
    if ((coords.getX() >= 0) && (coords.getY() >= 0)) {
        driver.tap(1, (int) coords.getX(), (int) coords.getY(), 100);
    } else {
        throw new ElementNotVisibleException("Element not found - " + targetImgPath);
    }
}
项目:AppiumFindByImage    文件:OCR.java   
public void clickByImage(String targetImgPath, double minSimilarityValue) {
    Point2D coords = getCoords(takeScreenshot(), targetImgPath, minSimilarityValue);
    if ((coords.getX() >= 0) && (coords.getY() >= 0)) {
        driver.tap(1, (int) coords.getX(), (int) coords.getY(), 100);
    } else {
        throw new ElementNotVisibleException("Element not found - " + targetImgPath);
    }
}
项目:AppiumFindByImage    文件:OCR.java   
public void longPressByImage(String targetImgPath) {
    Point2D coords = getCoords(takeScreenshot(), targetImgPath);
    if ((coords.getX() >= 0) && (coords.getY() >= 0)) {
        TouchAction touchA = new TouchAction(driver);
        touchA.longPress((int) coords.getX(), (int) coords.getY(), 1000).release().perform();
    } else {
        throw new ElementNotVisibleException("Element not found - " + targetImgPath);
    }
}
项目:AppiumFindByImage    文件:OCR.java   
public void longPressByImage(String targetImgPath, int pressDuration) {
    Point2D coords = getCoords(takeScreenshot(), targetImgPath);
    if ((coords.getX() >= 0) && (coords.getY() >= 0)) {
        TouchAction touchA = new TouchAction(driver);
        touchA.longPress((int) coords.getX(), (int) coords.getY(), pressDuration).release().perform();
    } else {
        throw new ElementNotVisibleException("Element not found - " + targetImgPath);
    }
}
项目:songs_play    文件:FacebookOAuth2Test.java   
private void signupUser() {
    goToLogin();
    browser
            .fill("#email").with(FACEBOOK_USER_EMAIL)
            .fill("#pass").with(System.getenv("FACEBOOK_USER_PASSWORD"))
            .find("#loginbutton").click();
    browser.await().untilPage().isLoaded();

    // save browser? no!
    try {
        // try, because this is not checked for test users, because they are not asked
        final String selector = "#u_0_2";
        browser.await().atMost(10, TimeUnit.SECONDS).until(selector);
        browser.find(selector).click();
        browser.find("#checkpointSubmitButton").click();
        browser.await().untilPage().isLoaded();
    } catch (final NoSuchElementException nsee) {
        // mobile
    } catch(final ElementNotVisibleException enve) {
        // desktop
    } catch(final WebDriverException wde) {
        // something else
    }

    // check login layout
    checkLoginLayout();

    // confirm login
    browser
            .find("[name='__CONFIRM__']")
            .click();
    browser
            .await()
            .untilPage()
            .isLoaded();

}
项目:SeleniumCucumber    文件:PageBase.java   
public void waitForElement(WebElement element,int timeOutInSeconds) {
    WebDriverWait wait = new WebDriverWait(driver, timeOutInSeconds);
    wait.ignoring(NoSuchElementException.class);
    wait.ignoring(ElementNotVisibleException.class);
    wait.ignoring(StaleElementReferenceException.class);
    wait.ignoring(ElementNotFoundException.class);
    wait.pollingEvery(250,TimeUnit.MILLISECONDS);
    wait.until(elementLocated(element));
}
项目:SeleniumCucumber    文件:WaitHelper.java   
private WebDriverWait getWait(int timeOutInSeconds,int pollingEveryInMiliSec) {
    oLog.debug("");
    WebDriverWait wait = new WebDriverWait(driver, timeOutInSeconds);
    wait.pollingEvery(pollingEveryInMiliSec, TimeUnit.MILLISECONDS);
    wait.ignoring(NoSuchElementException.class);
    wait.ignoring(ElementNotVisibleException.class);
    wait.ignoring(StaleElementReferenceException.class);
    wait.ignoring(NoSuchFrameException.class);
    return wait;
}
项目:kurento-room    文件:RoomClientBrowserTest.java   
public void exitFromRoom(int pageIndex, String userName) {
  Browser userBrowser = getPage(getBrowserKey(pageIndex)).getBrowser();
  try {
    Actions actions = new Actions(userBrowser.getWebDriver());
    actions.click(findElement(userName, userBrowser, "buttonLeaveRoom")).perform();
    log.debug("'buttonLeaveRoom' clicked on in {}", userName);
  } catch (ElementNotVisibleException e) {
    log.warn("Button 'buttonLeaveRoom' is not visible. Session can't be closed");
  }
}
项目:kurento-room    文件:RoomClientBrowserTest.java   
public void unsubscribe(int pageIndex, int unsubscribeFromIndex) {
  String clickableVideoTagId = getBrowserVideoStreamName(unsubscribeFromIndex);
  selectVideoTag(pageIndex, clickableVideoTagId);

  WebDriver userWebDriver = getPage(getBrowserKey(pageIndex)).getBrowser().getWebDriver();
  try {
    userWebDriver.findElement(By.id("buttonDisconnect")).click();
  } catch (ElementNotVisibleException e) {
    String msg = "Button 'buttonDisconnect' is not visible. Can't unsubscribe from media.";
    log.warn(msg);
    fail(msg);
  }
}
项目:kurento-room    文件:RoomClientBrowserTest.java   
public void selectVideoTag(int pageIndex, String targetVideoTagId) {
  WebDriver userWebDriver = getPage(getBrowserKey(pageIndex)).getBrowser().getWebDriver();
  try {
    WebElement element = userWebDriver.findElement(By.id(targetVideoTagId));
    Actions actions = new Actions(userWebDriver);
    actions.moveToElement(element).click().perform();
  } catch (ElementNotVisibleException e) {
    String msg = "Video tag '" + targetVideoTagId + "' is not visible, thus not selectable.";
    log.warn(msg);
    fail(msg);
  }
}
项目:kurento-room    文件:RoomClientBrowserTest.java   
protected void unpublish(int pageIndex) {
  WebDriver userWebDriver = getPage(getBrowserKey(pageIndex)).getBrowser().getWebDriver();
  try {
    userWebDriver.findElement(By.id("buttonDisconnect")).click();
  } catch (ElementNotVisibleException e) {
    log.warn("Button 'buttonDisconnect' is not visible. Can't unpublish media.");
  }
}
项目:phoenix.webui.framework    文件:SeleniumCheck.java   
@Override
public void checkByValue(Element element, String value)
{
    WebElement parentWebEle = searchStrategyUtils.findStrategy(WebElement.class, element).search(element);
    if(parentWebEle == null)
    {
        logger.error(String.format("can not found element byText [%s].", value));
        return;
    }

    List<Locator> locatorList = element.getLocatorList();
    List<Locator> tmpList = new ArrayList<Locator>(locatorList);

    ElementSearchStrategy<WebElement> strategy = context.getBean("zoneSearchStrategy", ElementSearchStrategy.class);

    SeleniumValueLocator valueLocator = context.getBean(SeleniumValueLocator.class);
    valueLocator.setHostType("byTagName");
    valueLocator.setHostValue("input");

    locatorList.clear();
    locatorList.add(valueLocator);
    valueLocator.setValue(value);

    WebElement itemWebEle = null;
    try
    {
        if(strategy instanceof ParentElement)
        {
            ((ParentElement) strategy).setParent(parentWebEle);
        }

        itemWebEle = strategy.search(element);
        if(itemWebEle != null)
        {
            if(!itemWebEle.isSelected())
            {
                itemWebEle.click();
            }
        }
    }
    catch(ElementNotVisibleException e)
    {
        e.printStackTrace();
        logger.error(String.format("Element [%s] click error, parent [%s], text [%s].",
                itemWebEle, element, value));
    }
    finally
    {
        //清空缓存
        locatorList.clear();
        locatorList.addAll(tmpList);

        if(strategy instanceof ParentElement)
        {
            ((ParentElement) strategy).setParent(null);
        }
    }
}
项目:UIFramework    文件:LineChart.java   
private PlotPoint getPlotPoint(int point) throws ElementNotVisibleException {
    if (point < 0) {
        throw new ElementNotVisibleException("Plot point ${point} not found");
    }
    return getPlotPoints().get(point);
}
项目:mineraloil-selenium    文件:RadioElement.java   
public void select() {
    if (isDisabled()) throw new ElementNotVisibleException("RadioElement is disabled and not selectable.");
    click();
}
项目:Testy    文件:FindElementIntegrationTest.java   
@Test (expectedExceptions = ElementNotVisibleException.class)
public void whenClickOnNotVisibleElIGetError() {
    showHiddenButton.click();
    hiddenElNotVisible.click();
}
项目:crawljax    文件:EmbeddedBrowser.java   
/**
 * fires the event.
 * 
 * @param event
 *            the event.
 * @return if fails.
 */
boolean fireEventAndWait(Eventable event) throws ElementNotVisibleException,
        InterruptedException;