List of usage examples for org.openqa.selenium.remote LocalFileDetector getLocalFile
@Override
public File getLocalFile(CharSequence... keys)
From source file:org.apache.directory.fortress.web.integration.FortressWebSeleniumITCase.java
License:Apache License
private void users() { String TEST_ROLE_NAME = "T15ROLE1"; String TEST_ADMIN_ROLE_NAME = "T3AdmRle1"; /*****//from w ww .ja v a2s.co m * USERS_PAGE TESTS */ driver.findElement(By.linkText("USERS")).click(); //driver.findElement( By.id( "roleRb" ) ).click(); driver.findElement(By.id("roleAssignLinkLbl")).click(); TUtils.sleep(1); driver.findElement(By.linkText(">")).click(); TUtils.sleep(1); driver.findElement(By.linkText(GlobalIds.SELECT)).click(); TUtils.sleep(1); driver.findElement(By.name("userformsearchfields:" + GlobalIds.SEARCH)).click(); driver.findElement(By.id(GlobalIds.FIELD_1)).clear(); driver.findElement(By.id(GlobalIds.FIELD_1)).sendKeys("dev1"); driver.findElement(By.id("ouAssignLinkLbl")).click(); TUtils.sleep(1); driver.findElement(By.linkText(GlobalIds.SELECT)).click(); TUtils.sleep(1); driver.findElement(By.name("userformsearchfields:" + GlobalIds.SEARCH)).click(); TUtils.sleep(1); WebElement table = driver.findElement(By.id("usertreegrid")); List<WebElement> allRows = table.findElements(By.tagName("tr")); allRows.get(4).findElement(By.className("imxt-cell")).click(); TUtils.sleep(1); allRows.get(5).findElement(By.className("imxt-cell")).click(); TUtils.sleep(1); allRows.get(6).findElement(By.className("imxt-cell")).click(); TUtils.sleep(1); driver.findElement(By.name(GlobalIds.CLEAR)).click(); TUtils.sleep(1); driver.findElement(By.id(GlobalIds.USER_ID)).sendKeys("selTestU1"); driver.findElement(By.id(GlobalIds.PASSWORD)).clear(); driver.findElement(By.id(GlobalIds.PASSWORD)).sendKeys("password"); driver.findElement(By.id(GlobalIds.OU)).clear(); driver.findElement(By.id(GlobalIds.OU)).sendKeys("dev1"); driver.findElement(By.name(GlobalIds.OU_SEARCH)).click(); TUtils.sleep(2); driver.findElement(By.linkText(GlobalIds.SELECT)).click(); TUtils.sleep(1); /* TODO: FIX ME: driver.findElement( By.name( GlobalIds.POLICY_SEARCH ) ).click(); TUtils.sleep( 2 ); driver.findElement( By.linkText( ">" ) ).click(); TUtils.sleep( 1 ); driver.findElement( By.linkText( GlobalIds.SELECT ) ).click(); TUtils.sleep( 1 ); */ driver.findElement(By.name(GlobalIds.ADD)).click(); TUtils.sleep(1); driver.findElement(By.id(GlobalIds.ROLE_ASSIGNMENTS_LABEL)).click(); //( ( JavascriptExecutor ) driver ).executeScript( "$(document.getElementById('roles')).val('role1');" ); driver.findElement(By.id(GlobalIds.ASSIGN_NEW_ROLE)).sendKeys(TEST_ROLE_NAME); driver.findElement(By.id(GlobalIds.BEGIN_TIME_RC)).clear(); driver.findElement(By.id(GlobalIds.BEGIN_TIME_RC)).sendKeys("8:00 AM"); driver.findElement(By.id(GlobalIds.END_TIME_RC)).clear(); driver.findElement(By.id(GlobalIds.END_TIME_RC)).sendKeys("5:00 PM"); driver.findElement(By.id(GlobalIds.BEGIN_DATE_RC)).clear(); driver.findElement(By.id(GlobalIds.BEGIN_DATE_RC)).sendKeys("1/1/2013"); driver.findElement(By.id(GlobalIds.END_DATE_RC)).clear(); driver.findElement(By.id(GlobalIds.END_DATE_RC)).sendKeys("1/1/2099"); driver.findElement(By.id(GlobalIds.BEGIN_LOCK_DATE_RC)).clear(); driver.findElement(By.id(GlobalIds.BEGIN_LOCK_DATE_RC)).sendKeys("6/1/2013"); driver.findElement(By.id(GlobalIds.END_LOCK_DATE_RC)).clear(); driver.findElement(By.id(GlobalIds.END_LOCK_DATE_RC)).sendKeys("6/15/2013"); driver.findElement(By.id(GlobalIds.TIMEOUT_RC)).clear(); driver.findElement(By.id(GlobalIds.TIMEOUT_RC)).sendKeys("120"); driver.findElement(By.id(GlobalIds.SUNDAY_RC)).click(); driver.findElement(By.id(GlobalIds.MONDAY_RC)).click(); driver.findElement(By.id(GlobalIds.TUESDAY_RC)).click(); driver.findElement(By.id(GlobalIds.WEDNESDAY_RC)).click(); driver.findElement(By.id(GlobalIds.THURSDAY_RC)).click(); driver.findElement(By.id(GlobalIds.FRIDAY_RC)).click(); driver.findElement(By.id(GlobalIds.SATURDAY_RC)).click(); driver.findElement(By.name(GlobalIds.ASSIGN)).click(); TUtils.sleep(1); driver.findElement(By.id(GlobalIds.ROLE_ASSIGNMENTS_LABEL)).click(); TUtils.sleep(1); driver.findElement(By.id(GlobalIds.ASSIGN_NEW_ROLE)).clear(); TUtils.sleep(2); driver.findElement(By.name(GlobalIds.ROLES_SEARCH)).click(); TUtils.sleep(2); driver.findElement(By.linkText("3")).click(); TUtils.sleep(2); driver.findElement(By.linkText(GlobalIds.SELECT)).click(); TUtils.sleep(2); driver.findElement(By.name(GlobalIds.ASSIGN)).click(); TUtils.sleep(2); driver.findElement(By.id("adminRoleAssignmentsLabel")).click(); /* if(driver.findElement( By.name( "adminRoles" ) ).isDisplayed()) { System.out.println("adminRoles is displayed!!!"); } else { System.out.println("adminRoles is NOT displayed!!!"); } */ //( ( JavascriptExecutor ) driver ).executeScript( "$(document.getElementById('adminRoles')).val" + // "('DemoAdminUsers');" ); driver.findElement(By.id(GlobalIds.ASSIGN_NEW_ADMIN_ROLE)).sendKeys(TEST_ADMIN_ROLE_NAME); driver.findElement(By.id(GlobalIds.BEGIN_TIME_ARC)).clear(); driver.findElement(By.id(GlobalIds.BEGIN_TIME_ARC)).sendKeys("8:00 AM"); driver.findElement(By.id(GlobalIds.END_TIME_ARC)).clear(); driver.findElement(By.id(GlobalIds.END_TIME_ARC)).sendKeys("5:00 PM"); driver.findElement(By.id(GlobalIds.BEGIN_DATE_ARC)).clear(); driver.findElement(By.id(GlobalIds.BEGIN_DATE_ARC)).sendKeys("1/1/2013"); driver.findElement(By.id(GlobalIds.END_DATE_ARC)).clear(); driver.findElement(By.id(GlobalIds.END_DATE_ARC)).sendKeys("1/1/2099"); driver.findElement(By.id(GlobalIds.BEGIN_LOCK_DATE_ARC)).clear(); driver.findElement(By.id(GlobalIds.BEGIN_LOCK_DATE_ARC)).sendKeys("6/1/2013"); driver.findElement(By.id(GlobalIds.END_LOCK_DATE_ARC)).clear(); driver.findElement(By.id(GlobalIds.END_LOCK_DATE_ARC)).sendKeys("6/15/2013"); driver.findElement(By.id(GlobalIds.TIMEOUT_ARC)).clear(); driver.findElement(By.id(GlobalIds.TIMEOUT_ARC)).sendKeys("180"); driver.findElement(By.id(GlobalIds.MONDAY_ARC)).click(); driver.findElement(By.id(GlobalIds.TUESDAY_ARC)).click(); driver.findElement(By.id(GlobalIds.WEDNESDAY_ARC)).click(); driver.findElement(By.id(GlobalIds.THURSDAY_ARC)).click(); driver.findElement(By.id(GlobalIds.FRIDAY_ARC)).click(); driver.findElement(By.name(GlobalIds.ASSIGN_ADMIN_ROLE)).click(); TUtils.sleep(1); driver.findElement(By.id("adminRoleAssignmentsLabel")).click(); TUtils.sleep(1); driver.findElement(By.name("adminRoles.search")).click(); TUtils.sleep(2); driver.findElement(By.linkText(">")).click(); TUtils.sleep(1); driver.findElement(By.linkText(">")).click(); TUtils.sleep(1); driver.findElement(By.linkText(GlobalIds.SELECT)).click(); TUtils.sleep(2); driver.findElement(By.name(GlobalIds.ASSIGN_ADMIN_ROLE)).click(); TUtils.sleep(2); driver.findElement(By.id("contactInformationLabel")).click(); TUtils.sleep(1); driver.findElement(By.id(GlobalIds.DESCRIPTION)).clear(); driver.findElement(By.id(GlobalIds.DESCRIPTION)).sendKeys("Selenium Test User"); driver.findElement(By.id(GlobalIds.EMPLOYEE_TYPE)).clear(); driver.findElement(By.id(GlobalIds.EMPLOYEE_TYPE)).sendKeys("Test User"); driver.findElement(By.id(GlobalIds.TITLE)).clear(); TUtils.sleep(1); driver.findElement(By.id(GlobalIds.TITLE)).sendKeys("TestUser"); // TODO: Fixme. The chrome driver.findElement( By.id( ) ).sendKeys can't find focus.... if (!driverType.equals(DriverType.CHROME)) { ((JavascriptExecutor) driver).executeScript("$(document.getElementById('emails')).show();"); TUtils.sleep(1); driver.findElement(By.id(GlobalIds.EMAILS)).click(); driver.findElement(By.id(GlobalIds.EMAILS)).clear(); TUtils.sleep(1); driver.findElement(By.id(GlobalIds.EMAILS)).sendKeys("joeuser@selenium.com"); TUtils.sleep(1); ((JavascriptExecutor) driver).executeScript("$(document.getElementById('phones')).show();"); driver.findElement(By.id(GlobalIds.PHONES)).clear(); TUtils.sleep(1); driver.findElement(By.id(GlobalIds.PHONES)).sendKeys("555-555-5555"); ((JavascriptExecutor) driver).executeScript("$(document.getElementById('mobiles')).show();"); driver.findElement(By.id(GlobalIds.MOBILES)).clear(); driver.findElement(By.id(GlobalIds.MOBILES)).sendKeys("222-222-2222"); driver.findElement(By.id(GlobalIds.ADDRESS_ASSIGNMENTS_LABEL)).click(); TUtils.sleep(1); ((JavascriptExecutor) driver).executeScript("$(document.getElementById('addresses')).show();"); driver.findElement(By.id(GlobalIds.ADDRESSES)).click(); driver.findElement(By.id(GlobalIds.ADDRESSES)).clear(); driver.findElement(By.id(GlobalIds.ADDRESSES)).sendKeys("9 Manor Road"); driver.findElement(By.id(GlobalIds.ADDRESS_CITY)).clear(); driver.findElement(By.id(GlobalIds.ADDRESS_CITY)).sendKeys("Salina"); driver.findElement(By.id(GlobalIds.ADDRESS_STATE)).clear(); driver.findElement(By.id(GlobalIds.ADDRESS_STATE)).sendKeys("KS"); driver.findElement(By.id(GlobalIds.ADDRESS_COUNTRY)).clear(); driver.findElement(By.id(GlobalIds.ADDRESS_COUNTRY)).sendKeys("US"); driver.findElement(By.id(GlobalIds.ADDRESS_POSTAL_CODE)).clear(); driver.findElement(By.id(GlobalIds.ADDRESS_POSTAL_CODE)).sendKeys("67401"); driver.findElement(By.id(GlobalIds.ADDRESS_POST_OFFICE_BOX)).clear(); driver.findElement(By.id(GlobalIds.ADDRESS_POST_OFFICE_BOX)).sendKeys("422"); driver.findElement(By.id(GlobalIds.ADDRESS_BUILDING)).clear(); driver.findElement(By.id(GlobalIds.ADDRESS_BUILDING)).sendKeys("2929"); driver.findElement(By.id(GlobalIds.ADDRESS_DEPARTMENT_NUMBER)).clear(); driver.findElement(By.id(GlobalIds.ADDRESS_DEPARTMENT_NUMBER)).sendKeys("2222"); driver.findElement(By.id(GlobalIds.ADDRESS_ROOM_NUMBER)).clear(); driver.findElement(By.id(GlobalIds.ADDRESS_ROOM_NUMBER)).sendKeys("555"); } driver.findElement(By.id(GlobalIds.TEMPORAL_CONSTRAINTS_LABEL)).click(); TUtils.sleep(1); driver.findElement(By.id(GlobalIds.BEGIN_TIME_P)).clear(); driver.findElement(By.id(GlobalIds.BEGIN_TIME_P)).sendKeys("8:00 AM"); driver.findElement(By.id(GlobalIds.END_TIME_P)).clear(); driver.findElement(By.id(GlobalIds.END_TIME_P)).sendKeys("5:00 PM"); driver.findElement(By.id(GlobalIds.BEGIN_DATE_P)).clear(); driver.findElement(By.id(GlobalIds.BEGIN_DATE_P)).sendKeys("1/1/2013"); driver.findElement(By.id(GlobalIds.END_DATE_P)).clear(); driver.findElement(By.id(GlobalIds.END_DATE_P)).sendKeys("1/1/2099"); driver.findElement(By.id(GlobalIds.BEGIN_LOCK_DATE_P)).clear(); driver.findElement(By.id(GlobalIds.BEGIN_LOCK_DATE_P)).sendKeys("6/1/2013"); driver.findElement(By.id(GlobalIds.END_LOCK_DATE_P)).clear(); driver.findElement(By.id(GlobalIds.END_LOCK_DATE_P)).sendKeys("6/15/2013"); driver.findElement(By.id(GlobalIds.TIMEOUT_P)).clear(); driver.findElement(By.id(GlobalIds.TIMEOUT_P)).sendKeys("0"); driver.findElement(By.id(GlobalIds.SUNDAY_P)).click(); driver.findElement(By.id(GlobalIds.MONDAY_P)).click(); driver.findElement(By.id(GlobalIds.TUESDAY_P)).click(); driver.findElement(By.id(GlobalIds.WEDNESDAY_P)).click(); driver.findElement(By.id(GlobalIds.THURSDAY_P)).click(); driver.findElement(By.id(GlobalIds.FRIDAY_P)).click(); driver.findElement(By.id(GlobalIds.SATURDAY_P)).click(); driver.findElement(By.id(GlobalIds.SYSTEM_INFO_LABEL)).click(); TUtils.sleep(1); driver.findElement(By.id(GlobalIds.SYSTEM)).click(); driver.findElement(By.id(GlobalIds.CN)).clear(); driver.findElement(By.id(GlobalIds.CN)).sendKeys("Firstname Lastname"); driver.findElement(By.id(GlobalIds.SN)).clear(); driver.findElement(By.id(GlobalIds.SN)).sendKeys("Lastname"); driver.findElement(By.id(GlobalIds.IMPORT_PHOTO_LABEL)).click(); TUtils.sleep(1); WebElement element = driver.findElement(By.name("upload")); LocalFileDetector detector = new LocalFileDetector(); String path = "./src/test/resources/p1.jpeg"; File f = detector.getLocalFile(path); element.sendKeys(f.getAbsolutePath()); driver.findElement(By.name(GlobalIds.SAVE)).click(); TUtils.sleep(3); driver.findElement(By.name(GlobalIds.COMMIT)).click(); TUtils.sleep(1); driver.findElement(By.id(GlobalIds.IMPORT_PHOTO_LABEL)).click(); TUtils.sleep(2); driver.findElement(By.name(GlobalIds.DELETE)).click(); TUtils.sleep(1); driver.findElement(By.id(GlobalIds.SYSTEM_INFO_LABEL)).click(); driver.findElement(By.id(GlobalIds.SYSTEM)).click(); driver.findElement(By.name(GlobalIds.COMMIT)).click(); TUtils.sleep(1); driver.findElement(By.name(GlobalIds.DELETE)).click(); TUtils.sleep(1); }