All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.sdl.selenium.extjs3.slider.Slider Maven / Gradle / Ivy

Go to download

Automated Acceptance Testing. Selenium and Selenium WebDriver test framework for web applications. (optimized for dynamic html, ExtJS, Bootstrap, complex UI, simple web applications/sites)

The newest version!
package com.sdl.selenium.extjs3.slider;


import com.sdl.selenium.extjs3.ExtJsComponent;
import com.sdl.selenium.utils.config.WebDriverConfig;
import com.sdl.selenium.web.WebLocator;
import org.openqa.selenium.By;
import org.openqa.selenium.Keys;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.interactions.Actions;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

// TODO this class is too specific to BeBlobal slider only
public class Slider extends ExtJsComponent {
    private static final Logger LOGGER = LoggerFactory.getLogger(Slider.class);

    public Slider() {
        setClassName("Slider");
    }

    /**
     * Constructor basen on ExtJsComponent
     *
     * @param container parent
     */
    public Slider(ExtJsComponent container) {
        this();
        setContainer(container);
    }

    public Slider(ExtJsComponent container, String label) {
        this(container);
        setLabel(label);
    }

    public String getThumbPath(int thumbIndex) {
        return getXPath() + "//descendant::*//*[contains(@class,'x-slider-thumb')][" + thumbIndex + "]";
    }

    public boolean move(int thumbIndex, int distance) {
        boolean exists = true;
        String thumbPath = getThumbPath(thumbIndex);
        WebLocator element = new WebLocator().setElPath(thumbPath);
        if (thumbPath != null && element.ready()) {
            // to scroll to this element (if element is not visible)
            WebDriver driver = WebDriverConfig.getDriver();
            WebElement thumbElement = driver.findElement(By.xpath(thumbPath));
            element.sendKeys(Keys.TAB);
            element.click();
            new Actions(driver).dragAndDropBy(thumbElement, distance, 1).build().perform();
        } else {
            LOGGER.warn("The slider for " + getPathBuilder().getLabel() + " has not been selected or is missing");
            exists = false;
        }
        return exists;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy