use of com.github.sergueik.jprotractor.NgWebElement in project selenium_java by sergueik.
the class NgScrollableTablePage method getFullName.
public String getFullName(int index) {
waitPageLoad();
WebElement row = rows.get(index);
NgWebElement ngRowElement = new NgWebElement(ngDriver, row);
return String.format("%s %s", (String) ngRowElement.evaluate("row.firstName"), (String) ngRowElement.evaluate("row.lastName"));
}
use of com.github.sergueik.jprotractor.NgWebElement in project selenium_java by sergueik.
the class NgMultiSelectPage method selectAllCars.
public void selectAllCars() {
for (int rowNum = 0; rowNum != countCars(); rowNum++) {
// For every row, click on the car name
NgWebElement ngCar = new NgWebElement(ngDriver, directive).findElement(NgBy.repeaterElement("i in items", rowNum, "i.label"));
try {
System.err.println(ngCar.getAttribute("innerHTML"));
} catch (NullPointerException e) {
// ignore
}
try {
System.err.println("* " + ngCar.evaluate("i.label").toString());
ngCar.click();
} catch (WebDriverException e) {
// ignore
}
}
}
use of com.github.sergueik.jprotractor.NgWebElement in project selenium_java by sergueik.
the class NgIgnoreSyncIntegrationTest method testNonAngularIgnoreSync.
// @Ignore
@Test
public void testNonAngularIgnoreSync() {
if (isCIBuild) {
return;
}
NgWebDriver ngDriver = new NgWebDriver(seleniumDriver, true);
ngDriver.navigate().to("http://www.google.com");
long startTime = System.currentTimeMillis();
ngDriver.waitForAngular();
long estimatedTime = System.currentTimeMillis() - startTime;
System.err.println("waitForAngular: " + estimatedTime);
NgWebElement element = ngDriver.findElement(By.cssSelector("input#gs_htif0"));
try {
element.getAttribute("id");
} catch (TimeoutException exception) {
fullStackTrace = org.apache.commons.lang.exception.ExceptionUtils.getFullStackTrace(exception);
System.err.println("TimeoutException thrown: " + fullStackTrace);
return;
}
}
use of com.github.sergueik.jprotractor.NgWebElement in project selenium_java by sergueik.
the class NgLocalFileIntegrationTest method testUpload3.
// @Ignore
@Test
public void testUpload3() {
if (isCIBuild) {
return;
}
// TODO: abort the test on timeout
// http://stackoverflow.com/questions/2275443/how-to-timeout-a-thread
getPageContent("ng_upload3.htm");
WebElement drop = ngDriver.findElement(NgBy.binding("dropText"));
assertThat(drop, notNullValue());
highlight(drop);
WebElement fileToUpload = ngDriver.findElement(By.id("fileToUpload"));
assertThat(fileToUpload, notNullValue());
assertTrue(fileToUpload.getAttribute("type").equalsIgnoreCase("file"));
String localPath = "C:/developer/sergueik/powershell_selenium/powershell/testfile.txt";
System.err.println("sendKeys :" + localPath);
fileToUpload.sendKeys(localPath);
NgWebElement ng_fileToUpload = new NgWebElement(ngDriver, fileToUpload);
// String script = "angular.element(this).scope().setFiles(this)";
// Object result = CommonFunctions.executeScript(script,ng_fileToUpload);
// assertThat(result, notNullValue());
wait.until(ExpectedConditions.visibilityOf(ngDriver.findElement(By.cssSelector("input[ type='button' ][ value='Upload' ]"))));
// Element is not currently visible and may not be manipulated
WebElement button = ngDriver.findElement(By.cssSelector("input[ type='button' ][ value='Upload' ]"));
System.err.println("Click");
button.click();
}
use of com.github.sergueik.jprotractor.NgWebElement in project selenium_java by sergueik.
the class NgLocalFileIntegrationTest method testMultiSelect2.
@Ignore
@Test
public void testMultiSelect2() {
getPageContent("ng_multi_select2.htm");
WebElement button = ngDriver.findElement(By.cssSelector("multiselect-dropdown button[data-ng-click='openDropdown()']"));
assertThat(button, notNullValue());
button.click();
// selectedRepeaterOption("option in options") will not work with this
// directive
List<WebElement> elements = ngDriver.findElements(NgBy.binding("option.name"));
assertTrue(elements.size() > 0);
// find what is selected based on the bootstrap class attribute
String expression = "\\-remove\\-";
Pattern pattern = Pattern.compile(expression);
Matcher matcher = null;
int count = 0;
for (WebElement element : elements) {
NgWebElement ngElement = new NgWebElement(ngDriver, element);
String optionName = ngElement.evaluate("option.name").toString();
// switch to core Selenium
WebElement element2 = element.findElement(By.tagName("span"));
assertThat(element2, notNullValue());
String classAttribute = element2.getAttribute("class");
// System.err.println( "option.name = " + optionName + " " +
// classAttribute);
matcher = pattern.matcher(classAttribute);
if (matcher.find()) {
} else {
System.err.println("selected: " + optionName);
highlight(element);
count++;
}
}
elements = ngDriver.findElements(NgBy.repeaterColumn("country in SelectedCountries", "country.name"));
assertTrue(elements.size() == count);
elements.stream().forEach(element -> System.err.format("%s\n", element.getText()));
}
Aggregations