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

com.paulhammant.ngwebdriver.ByAngularRepeaterCell Maven / Gradle / Ivy

There is a newer version: 1.2
Show newest version
package com.paulhammant.ngwebdriver;

import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.SearchContext;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;

import java.util.List;

public class ByAngularRepeaterCell extends ByAngular.BaseBy {

    private final String repeater;
    private boolean exact;
    private final int row;
    private final String column;

    public ByAngularRepeaterCell(String repeater, boolean exact, int row, String column) {
        super();
        this.repeater = repeater;
        this.exact = exact;
        this.row = row;
        this.column = column;
    }

    protected Object getObject(SearchContext context, JavascriptExecutor javascriptExecutor) {
        return javascriptExecutor.executeScript(
                    "var using = arguments[0] || document;\n" +
                            "var rootSelector = 'body';\n" +
                            "var repeater = '" + repeater.replace("'", "\\'") + "';\n" +
                            "var index = " + row + ";\n" +
                            "var binding = '" + column + "';\n" +
                            "var exact = " + exact + ";\n" +
                            "\n" +
                            ByAngular.functions.get("findRepeaterElement")
                    , context);
    }

    // meaningless
    @Override
    public List findElements(SearchContext searchContext) {
        throw new UnsupportedOperationException("This locator zooms in on a single cell, findElements() is meaningless");
    }

    @Override
    public String toString() {
        return (exact? "exactR":"r") + "epeater(" + repeater + ").row(" + row + ").column(" + column + ")";
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy