Search in sources :

Example 41 with JavascriptExecutor

use of org.openqa.selenium.JavascriptExecutor in project selenium-tests by Wikia.

the class ArticlePageObject method triggerEditCommentArea.

public MiniEditorComponentObject triggerEditCommentArea() {
    jsActions.scrollToElement(allCommentsArea);
    WebElement mostRecentComment = articleComments.get(0);
    PageObjectLogging.log("First check", mostRecentComment.getText(), true);
    JavascriptExecutor js = (JavascriptExecutor) driver;
    WebElement editButton = mostRecentComment.findElement(By.cssSelector(EDIT_BUTTON_SELECTOR));
    new Actions(driver).moveToElement(editButton).perform();
    js.executeScript("arguments[0].querySelector(arguments[1]).click()", mostRecentComment, EDIT_BUTTON_SELECTOR);
    return new MiniEditorComponentObject(driver);
}
Also used : MiniEditorComponentObject(com.wikia.webdriver.pageobjectsfactory.componentobject.minieditor.MiniEditorComponentObject) JavascriptExecutor(org.openqa.selenium.JavascriptExecutor) Actions(org.openqa.selenium.interactions.Actions) WebElement(org.openqa.selenium.WebElement)

Example 42 with JavascriptExecutor

use of org.openqa.selenium.JavascriptExecutor in project selenium-tests by Wikia.

the class AdsBaseObject method hideElementIfPresent.

protected void hideElementIfPresent(String cssSelector) {
    if (isElementOnPage(By.cssSelector(cssSelector))) {
        PageObjectLogging.log("Hiding element", cssSelector, true);
        WebElement element = driver.findElement(By.cssSelector(cssSelector));
        JavascriptExecutor js = (JavascriptExecutor) driver;
        js.executeScript("$(arguments[0]).css('display', 'none')", element);
        waitForElementNotVisibleByElement(element);
    }
}
Also used : JavascriptExecutor(org.openqa.selenium.JavascriptExecutor) WebElement(org.openqa.selenium.WebElement)

Example 43 with JavascriptExecutor

use of org.openqa.selenium.JavascriptExecutor in project selenium-tests by Wikia.

the class TableOfContentPageObject method isH2PaddingTopMoreThan.

public boolean isH2PaddingTopMoreThan(int index, int value) {
    JavascriptExecutor js = (JavascriptExecutor) driver;
    String h2PaddingString = js.executeScript("return $('h2').eq(" + index + ").css('padding-top')").toString();
    h2PaddingString = h2PaddingString.substring(0, h2PaddingString.length() - 2);
    int h2Padding = Integer.parseInt(h2PaddingString);
    return h2Padding >= value;
}
Also used : JavascriptExecutor(org.openqa.selenium.JavascriptExecutor)

Example 44 with JavascriptExecutor

use of org.openqa.selenium.JavascriptExecutor in project fess by codelibs.

the class WebDriverGenerator method generate.

@Override
public boolean generate(final String thumbnailId, final String url, final File outputFile) {
    if (logger.isDebugEnabled()) {
        logger.debug("Generate Thumbnail: " + url);
    }
    if (outputFile.exists()) {
        if (logger.isDebugEnabled()) {
            logger.debug("The thumbnail file exists: " + outputFile.getAbsolutePath());
        }
        return true;
    }
    final File parentFile = outputFile.getParentFile();
    if (!parentFile.exists()) {
        parentFile.mkdirs();
    }
    if (!parentFile.isDirectory()) {
        logger.warn("Not found: " + parentFile.getAbsolutePath());
        return false;
    }
    if (webDriver instanceof TakesScreenshot) {
        final FessConfig fessConfig = ComponentUtil.getFessConfig();
        synchronized (this) {
            try {
                webDriver.get(url);
                if (webDriver instanceof JavascriptExecutor) {
                    final Dimension dim = webDriver.findElement(By.tagName("body")).getSize();
                    if (dim.height >= fessConfig.getThumbnailHtmlPhantomjsMaxHeightAsInteger()) {
                        if (logger.isInfoEnabled()) {
                            logger.info("Skpped Thumbnail generation " + dim + " for " + url);
                        }
                        return false;
                    }
                }
                final File thumbnail = ((TakesScreenshot) webDriver).getScreenshotAs(OutputType.FILE);
                convert(thumbnail, outputFile);
                updateThumbnailField(thumbnailId, url, url);
                return true;
            } catch (final UnreachableBrowserException | SessionNotFoundException e) {
                if (logger.isDebugEnabled()) {
                    logger.debug("WebDriver is not available.", e);
                }
                previousCheckTime = 0;
            } finally {
                final long now = ComponentUtil.getSystemHelper().getCurrentTimeAsLong();
                if (now - previousCheckTime > fessConfig.getThumbnailHtmlPhantomjsKeepAliveAsInteger().longValue()) {
                    destroy();
                    startWebDriver();
                }
            }
        }
    } else {
        logger.warn("WebDriver is not instance of TakesScreenshot: " + webDriver);
    }
    return false;
}
Also used : JavascriptExecutor(org.openqa.selenium.JavascriptExecutor) UnreachableBrowserException(org.openqa.selenium.remote.UnreachableBrowserException) Dimension(org.openqa.selenium.Dimension) File(java.io.File) FessConfig(org.codelibs.fess.mylasta.direction.FessConfig) TakesScreenshot(org.openqa.selenium.TakesScreenshot) SessionNotFoundException(org.openqa.selenium.remote.SessionNotFoundException)

Example 45 with JavascriptExecutor

use of org.openqa.selenium.JavascriptExecutor in project blueocean-plugin by jenkinsci.

the class FavoritesCardsTest method testMultibranch.

@Test
public void testMultibranch() throws IOException, GitAPIException, InterruptedException {
    String branchOther = "feature/1";
    git.writeJenkinsFile(resources.loadJenkinsFile());
    git.addAll();
    git.commit("First");
    git.createBranch(branchOther);
    String jobName = "navigation-multibranch";
    MultiBranchPipeline pipeline = multibranchFactory.pipeline(FOLDER, jobName).createPipeline(git);
    String fullNameMaster = pipeline.getFullName();
    String fullNameOther = pipeline.getFullName(branchOther);
    dashboardPage.open();
    dashboardPage.togglePipelineListFavorite(jobName);
    dashboardPage.getFavoriteCard(fullNameMaster);
    dashboardPage.clickFavoriteCardActivityLink(fullNameMaster);
    activityPageFactory.withPipeline(pipeline).clickBranchTab().toggleFavoriteStatus(branchOther);
    dashboardPage.open();
    List<String> cardFullnames = ImmutableList.of(fullNameMaster, fullNameOther);
    int count = 2;
    dashboardPage.checkFavoriteCardStatus(fullNameMaster, SUCCESS);
    dashboardPage.checkFavoriteCardStatus(fullNameOther, SUCCESS);
    // Check that favorite actions are hidden until pointer is hovering the row
    JavascriptExecutor js = (JavascriptExecutor) driver;
    Object backgroundColor = js.executeScript("return getComputedStyle(document.querySelectorAll('.actions-container')[0], ':after').getPropertyValue('background-color')");
    // check that background color of overlay is  NOT transparent when pointer is NOT hovering the favorite row
    Assert.assertNotEquals(backgroundColor, "rgba(0, 0, 0, 0)");
    logger.info("move pointer over favorite card actions");
    Actions action = new Actions(driver);
    WebElement we = wait.until(By.xpath("//*[@class=\"pipeline-card success-bg-lite\"]"));
    action.moveToElement(we).perform();
    // check that background color of overlay is transparent when pointer is hovering the favorite row
    wait.until(hoverBackgroundColor());
    for (String fullName : cardFullnames) {
        logger.info(String.format("running tests against favorited branch: %s", fullName));
        count--;
        dashboardPage.clickFavoriteCardRunButton(fullName);
        dashboardPage.checkFavoriteCardStatus(fullName, RUNNING, SUCCESS);
        dashboardPage.clickFavoriteCardReplayButton(fullName);
        dashboardPage.checkFavoriteCardStatus(fullName, RUNNING, SUCCESS);
        dashboardPage.removeFavoriteCard(fullName);
        dashboardPage.checkFavoriteCardCount(count);
        dashboardPage.checkIsPipelineListItemFavorited(jobName, false);
    }
}
Also used : JavascriptExecutor(org.openqa.selenium.JavascriptExecutor) MultiBranchPipeline(io.blueocean.ath.model.MultiBranchPipeline) Actions(org.openqa.selenium.interactions.Actions) WebElement(org.openqa.selenium.WebElement) Test(org.junit.Test)

Aggregations

JavascriptExecutor (org.openqa.selenium.JavascriptExecutor)47 WebElement (org.openqa.selenium.WebElement)25 WebDriver (org.openqa.selenium.WebDriver)10 PublicAtsApi (com.axway.ats.common.PublicAtsApi)9 RealHtmlElementState (com.axway.ats.uiengine.utilities.realbrowser.html.RealHtmlElementState)4 Test (org.junit.Test)4 ChromeDriver (org.openqa.selenium.chrome.ChromeDriver)4 HiddenHtmlElementState (com.axway.ats.uiengine.utilities.hiddenbrowser.HiddenHtmlElementState)3 Dimension (org.openqa.selenium.Dimension)3 RemoteWebElement (org.openqa.selenium.remote.RemoteWebElement)3 Select (org.openqa.selenium.support.ui.Select)3 WebDriverWait (org.openqa.selenium.support.ui.WebDriverWait)3 VerificationException (com.axway.ats.uiengine.exceptions.VerificationException)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2 Cookie (org.openqa.selenium.Cookie)2 TimeoutException (org.openqa.selenium.TimeoutException)2 Actions (org.openqa.selenium.interactions.Actions)2 MobileDriver (com.axway.ats.uiengine.MobileDriver)1 MobileOperationException (com.axway.ats.uiengine.exceptions.MobileOperationException)1