Example usage for org.openqa.selenium Point Point

List of usage examples for org.openqa.selenium Point Point

Introduction

In this page you can find the example usage for org.openqa.selenium Point Point.

Prototype

public Point(int x, int y) 

Source Link

Usage

From source file:org.xframium.gesture.GestureManager.java

License:Open Source License

/**
 * Creates the pinch.//  www.  java 2  s .  com
 *
 * @return the gesture
 */
public Gesture createPinch() {
    return createPinch(new Point(15, 15), new Point(85, 85), new Point(45, 45), new Point(55, 55));
}

From source file:org.xframium.page.element.SeleniumElement.java

License:Open Source License

@Override
protected void _click() {
    if ("V_TEXT".equals(getBy().name().toUpperCase())) {
        ImageExecution iExec = PerfectoMobile.instance().imaging().textExists(getExecutionId(), getDeviceName(),
                getKey(), (short) 30, 50);
        if (Boolean.parseBoolean(iExec.getStatus())) {
            int centerWidth = Integer.parseInt(iExec.getLeft()) + (Integer.parseInt(iExec.getWidth()) / 2);
            int centerHeight = Integer.parseInt(iExec.getTop()) + (Integer.parseInt(iExec.getHeight()) / 2);

            int useX = (int) (((double) centerWidth / (double) Integer.parseInt(iExec.getScreenWidth())) * 100);
            int useY = (int) (((double) centerHeight / (double) Integer.parseInt(iExec.getScreenHeight()))
                    * 100);//from w  ww .  j  a  va2  s. c  o m

            GestureManager.instance().createPress(new Point(useX, useY)).executeGesture(webDriver);

        }
    } else
        getElement().click();

}

From source file:org.xframium.page.keyWord.step.AbstractKeyWordStep.java

License:Open Source License

/**
 * Creates the point./*from   w  w w . j a va2 s .  c o m*/
 *
 * @param pointValue
 *            the point value
 * @return the point
 */
protected Point createPoint(String pointValue) {
    Point x = null;

    try {
        String[] coors = pointValue.split(",");

        if (coors.length == 2) {
            x = new Point(Integer.parseInt(coors[0].trim()), Integer.parseInt(coors[1].trim()));
            return x;
        }
    } catch (Exception e) {
        log.warn(Thread.currentThread().getName() + ": Could not parse coordinates " + pointValue + " due to "
                + e.getMessage());
    }

    return null;

}

From source file:PokemonGoMapValidator.Config.java

public void configInstance(String driverFile, String profileFile, String mapFile) {
    WebDriver webDriver = null;/*from w  w w  . j a  v a  2 s  . c  o  m*/

    try {
        System.setProperty("webdriver.chrome.driver", driverFile);

        String currentDirectory = Paths.get(".").toAbsolutePath().normalize().toString();

        ZipFile zipFile = new ZipFile(profileFile);
        zipFile.extractAll(currentDirectory + "/" + "profile" + "/");

        File f = new File(currentDirectory + "/prints/");
        if (!f.isDirectory()) {
            new File(currentDirectory + "/prints/").mkdir();
        }

        HashMap<String, Object> chromePrefs = new HashMap<>();
        chromePrefs.put("profile.default_content_settings.popups", 0);
        chromePrefs.put("download.default_directory", currentDirectory);

        ChromeOptions options = new ChromeOptions();

        //se na user-data-dir nao existir profile do chrome,  gerado um na hora
        options.addArguments("user-data-dir=" + currentDirectory + "/" + "profile");
        options.addArguments("--start-maximized");
        //adicionei esta linha, j que dns e portos andam sempre em mudanas
        options.addArguments("--dns-prefetch-disable");
        //options.addExtensions(new File(extensionFile));
        options.setExperimentalOption("prefs", chromePrefs);

        DesiredCapabilities capabilities = new DesiredCapabilities();
        capabilities.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);
        capabilities.setCapability(ChromeOptions.CAPABILITY, options);
        webDriver = new ChromeDriver(capabilities);

        //pokemongos grow in sextagon shape, so I will force a square resolution
        webDriver.manage().window().setPosition(new Point(XCOORD, YCOORD));
        if (MAPDIMENSION > 0) {
            webDriver.manage().window().setSize(new Dimension(MAPDIMENSION, MAPDIMENSION));
        } else {
            webDriver.manage().window().maximize();
        }

        //in the code below, I tried to create a square, but the width's and height's
        //seem to change, and I didn't figured out why and how
        //TODO in the future
        /*
        webDriver.get("http://www.google.com");
        Thread.sleep(1000);
        Dimension win_size = webDriver.manage().window().getSize();
                
        WebElement html = webDriver.findElement(By.tagName("html"));
        int inner_width = Integer.parseInt(html.getAttribute("clientWidth"));
        int outer_width = win_size.width - inner_width;
        int inner_height = Integer.parseInt(html.getAttribute("clientHeight"));
        int outer_height = win_size.height - inner_height;
                
        //pokemongos grow in sextagon shape, so I will force a square resolution
        webDriver.manage().window().setPosition(new Point(0, -1080));
        webDriver.manage().window().setSize(new Dimension(800 + outer_width, 600 + outer_height));
                
        if (VALIDATEBROWSER) {
        new Graphics().browserDimension(webDriver);
        }
                
        */

        RunComparison comparison = new RunComparison();
        comparison.comparison(currentDirectory, webDriver, mapFile);

    } catch (ZipException | IOException | InterruptedException ex) {
        System.err.println("Config error: " + ex.getMessage());
    } finally {
        try {
            if (webDriver != null) {
                Exit sair = new Exit();
                sair.exit(webDriver);
                System.out.println("ChromeDriver and Chrome unloaded");
            }
        } catch (InterruptedException ex) {
            System.err.println("Exit error: " + ex.getMessage());
        }
    }
}

From source file:proxi.model.ArticleInflater.java

License:Open Source License

/**
 * Start the process to inflate the Articles to add to a recived Diary
 * //w w w .j av a 2s .  c o  m
 * @param url
 *            contains the url that will be parsed using selenium
 *            FirefoxDriver
 * @param diary
 *            is a Diary that will be stored as an attribute
 * @return Article with inflated with content
 */
public Article run(String url, Diary diary) {

    this.diary = diary;
    this.analyzedUrl = url;

    // Open or reuse the browser
    if (driver == null) {
        driver = new FirefoxDriver();
        driver.manage().window().setPosition(new Point(-2000, -2000));
        driver.manage().window().setSize(new Dimension(100, 100));

    }

    // Make the article from the web
    Article article = articleController();

    // Order the article commentaries
    orderByTime(article);

    return article;
}

From source file:ru.stqa.selenium.decorated.DecoratedCoordinatesTest.java

License:Apache License

@Test
void testOnScreen() {
    verifyFunction(Coordinates::onScreen, new Point(10, 20));
}

From source file:ru.stqa.selenium.decorated.DecoratedCoordinatesTest.java

License:Apache License

@Test
void testInViewPort() {
    verifyFunction(Coordinates::inViewPort, new Point(10, 20));
}

From source file:ru.stqa.selenium.decorated.DecoratedCoordinatesTest.java

License:Apache License

@Test
void testOnPage() {
    verifyFunction(Coordinates::onPage, new Point(10, 20));
}

From source file:ru.stqa.selenium.decorated.DecoratedWebElementTest.java

License:Apache License

@Test
void testGetLocation() {
    verifyFunction(WebElement::getLocation, new Point(10, 20));
}

From source file:ru.stqa.selenium.decorated.DecoratedWebElementTest.java

License:Apache License

@Test
void testGetRect() {
    verifyFunction(WebElement::getRect, new Rectangle(new Point(10, 20), new Dimension(100, 200)));
}