List of usage examples for org.openqa.selenium.support.ui ExpectedConditions presenceOfElementLocated
public static ExpectedCondition<WebElement> presenceOfElementLocated(final By locator)
From source file:org.orcid.integration.blackbox.api.v2.rc2.PersonalDetailsTest.java
License:Open Source License
private void changeNamesVisibility(Visibility changeTo) throws Exception { int privacyIndex = getPrivacyIndex(changeTo); try {//from w w w . ja va2 s . c om By openEditNames = By.xpath("//div[@id = 'names-section']//span[@id = 'open-edit-names']"); (new WebDriverWait(webDriver, WAIT)).until(ExpectedConditions.presenceOfElementLocated(openEditNames)); WebElement openEditNamesElement = webDriver.findElement(openEditNames); openEditNamesElement.click(); By namesVisibility = By .xpath("//div[@id = 'names-section']//ul[@class='privacyToggle']/li[" + privacyIndex + "]/a"); (new WebDriverWait(webDriver, WAIT)) .until(ExpectedConditions.presenceOfElementLocated(namesVisibility)); WebElement namesVisibilityElement = webDriver.findElement(namesVisibility); namesVisibilityElement.click(); By saveButton = By .xpath("//div[@id = 'names-section']//ul[@class='workspace-section-toolbar']//li[1]//button"); (new WebDriverWait(webDriver, WAIT)).until(ExpectedConditions.presenceOfElementLocated(saveButton)); WebElement button = webDriver.findElement(saveButton); button.click(); Thread.sleep(1000); } catch (Exception e) { System.out.println("Unable to find names-visibility-limited element"); e.printStackTrace(); throw e; } }
From source file:org.orcid.integration.blackbox.api.v2.rc2.PersonalDetailsTest.java
License:Open Source License
private void changeOtherNamesVisibility(Visibility changeTo) throws Exception { int privacyIndex = getPrivacyIndex(changeTo); try {/*from ww w.j a v a 2 s. c o m*/ By openEditOtherNames = By .xpath("//div[@id = 'other-names-section']//span[@id = 'open-edit-other-names']"); (new WebDriverWait(webDriver, WAIT)) .until(ExpectedConditions.presenceOfElementLocated(openEditOtherNames)); WebElement openEditOtherNamesElement = webDriver.findElement(openEditOtherNames); openEditOtherNamesElement.click(); By namesVisibility = By.xpath( "//div[@id = 'other-names-section']//ul[@class='privacyToggle']/li[" + privacyIndex + "]/a"); (new WebDriverWait(webDriver, WAIT)) .until(ExpectedConditions.presenceOfElementLocated(namesVisibility)); WebElement namesVisibilityElement = webDriver.findElement(namesVisibility); namesVisibilityElement.click(); By saveButton = By.xpath( "//div[@id = 'other-names-section']//ul[@class='workspace-section-toolbar']//li[2]//button"); (new WebDriverWait(webDriver, WAIT)).until(ExpectedConditions.presenceOfElementLocated(saveButton)); WebElement button = webDriver.findElement(saveButton); button.click(); Thread.sleep(1000); } catch (Exception e) { System.out.println("Unable to find biography-visibility-limited element"); e.printStackTrace(); throw e; } }
From source file:org.orcid.integration.blackbox.api.v2.rc2.PersonalDetailsTest.java
License:Open Source License
private void changeBioVisibility(Visibility changeTo) throws Exception { int privacyIndex = getPrivacyIndex(changeTo); try {/*from ww w . j ava2s . co m*/ By bioOPrivacySelectorLimited = By .xpath("//div[@id = 'bio-section']//ul[@class='privacyToggle']/li[" + privacyIndex + "]/a"); (new WebDriverWait(webDriver, WAIT)) .until(ExpectedConditions.presenceOfElementLocated(bioOPrivacySelectorLimited)); WebElement bioOPrivacySelectorLimitedElement = webDriver.findElement(bioOPrivacySelectorLimited); bioOPrivacySelectorLimitedElement.click(); Thread.sleep(1000); } catch (Exception e) { System.out.println("Unable to find nother-names-visibility-limited element"); e.printStackTrace(); throw e; } }
From source file:org.orcid.integration.blackbox.BlackBoxBase.java
License:Open Source License
public static void revokeApplicationsAccess(String... clientIdsParam) { // Nothing to remove if (clientIdsParam == null) { return;/*from ww w. j a v a 2 s . com*/ } List<String> clientIds = new ArrayList<String>(); for (String clientId : clientIdsParam) { if (!PojoUtil.isEmpty(clientId)) { clientIds.add(clientId); } } String userName = System.getProperty("org.orcid.web.testUser1.username"); String password = System.getProperty("org.orcid.web.testUser1.password"); String baseUrl = "http://localhost:8080/orcid-web"; if (!PojoUtil.isEmpty(System.getProperty("org.orcid.web.base.url"))) { baseUrl = System.getProperty("org.orcid.web.base.url"); } WebDriver webDriver = new FirefoxDriver(); int timeout = 4; webDriver.get(baseUrl + "/userStatus.json?logUserOut=true"); webDriver.get(baseUrl + "/my-orcid"); SigninTest.signIn(webDriver, userName, password); // Switch to accounts settings page By accountSettingsMenuLink = By.id("accountSettingMenuLink"); (new WebDriverWait(webDriver, timeout)) .until(ExpectedConditions.presenceOfElementLocated(accountSettingsMenuLink)); WebElement menuItem = webDriver.findElement(accountSettingsMenuLink); menuItem.click(); try { boolean lookAgain = false; do { // Look for each revoke app button By revokeAppBtn = By.id("revokeAppBtn"); (new WebDriverWait(webDriver, timeout)) .until(ExpectedConditions.presenceOfElementLocated(revokeAppBtn)); List<WebElement> appsToRevoke = webDriver.findElements(revokeAppBtn); boolean elementFound = false; // Iterate on them and delete the ones created by the specified // client id for (WebElement appElement : appsToRevoke) { String nameAttribute = appElement.getAttribute("name"); if (clientIds.contains(nameAttribute)) { appElement.click(); Thread.sleep(1000); // Wait for the revoke button By confirmRevokeAppBtn = By.id("confirmRevokeAppBtn"); (new WebDriverWait(webDriver, timeout)) .until(ExpectedConditions.presenceOfElementLocated(confirmRevokeAppBtn)); WebElement trash = webDriver.findElement(confirmRevokeAppBtn); trash.click(); Thread.sleep(2000); elementFound = true; break; } } if (elementFound) { lookAgain = true; } else { lookAgain = false; } } while (lookAgain); } catch (Exception e) { // If it fail is because it couldnt find any other application } finally { webDriver.get(baseUrl + "/userStatus.json?logUserOut=true"); webDriver.quit(); } }
From source file:org.orcid.integration.blackbox.BlackBoxBase.java
License:Open Source License
public void adminLockAccount(String adminUserName, String adminPassword, String orcidToLock) { adminSignIn(adminUserName, adminPassword); // Lock the account WebDriverWait wait = new WebDriverWait(webDriver, 10); WebElement lockProfileLink = webDriver.findElement(By.linkText("Lock profile")); lockProfileLink.click();//from w w w. j a va2 s . com WebElement lockProfileOrcidId = webDriver.findElement(By.id("orcid_to_lock")); lockProfileOrcidId.sendKeys(orcidToLock); WebElement lockButton = webDriver.findElement(By.id("bottom-confirm-lock-profile")); lockButton.click(); wait.until(ExpectedConditions.presenceOfElementLocated(By.id("btn-lock"))); WebElement confirmLockButton = webDriver.findElement(By.id("btn-lock")); confirmLockButton.click(); webDriver.quit(); }
From source file:org.orcid.integration.blackbox.client.SigninPage.java
License:Open Source License
public void signIn(String username, String password) { WebElement emailEl = xpath.findElement("//input[@name='userId']"); emailEl.sendKeys(username);//from w ww . ja va 2s . co m WebElement passwordEl = xpath.findElement("//input[@name='password']"); passwordEl.sendKeys(password); xpath.click("//button[@id='form-sign-in-button']"); utils.getWait().until(ExpectedConditions.presenceOfElementLocated(By.xpath("//a[text()='Sign out']"))); dismissVerifyEmailModal(); }
From source file:org.orcid.integration.blackbox.client.XPath.java
License:Open Source License
public WebElement findElement(String xpath) { By by = By.xpath(xpath); utils.getWait().until(ExpectedConditions.presenceOfElementLocated(by)); return webDriver.findElement(by); }
From source file:org.orcid.integration.blackbox.web.shibboleth.ShibbolethTest.java
License:Open Source License
@Test public void testLinkAndSignInWithShibboleth() { webDriver.get(baseUri + "/signin?shibboleth"); WebElement buttonEl = webDriver//from w w w .j a va2 s .c om .findElement(By.xpath("//a[text()=\"Sign in with my institution's single sign on\"]")); buttonEl.click(); WebDriverWait waitForUserId = new WebDriverWait(webDriver, DEFAULT_TIMEOUT_SECONDS); waitForUserId.until(ExpectedConditions.presenceOfElementLocated(By.xpath("//input[@name='userId']"))); SigninTest.signIn(webDriver, user1UserName, user1Password); By orcidRecordLinkBy = By.xpath("//a[text()='continue to your ORCID record']"); WebDriverWait orcidRecordLinkWait = new WebDriverWait(webDriver, DEFAULT_TIMEOUT_SECONDS); orcidRecordLinkWait.until(ExpectedConditions.presenceOfElementLocated(orcidRecordLinkBy)); WebElement orcidRecordLink = webDriver.findElement(orcidRecordLinkBy); orcidRecordLink.click(); new WebDriverWait(webDriver, DEFAULT_TIMEOUT_SECONDS).until(ExpectedConditions .presenceOfElementLocated(By.xpath("//span[contains(., '" + user1OrcidId + "')]"))); }
From source file:org.orcid.integration.blackbox.web.SigninTest.java
License:Open Source License
static public void signIn(WebDriver webDriver, String username, String password) { WebElement emailEl = webDriver.findElement(By.xpath("//input[@name='userId']")); emailEl.sendKeys(username);/*from w w w . j a va 2 s.c o m*/ WebElement passwordEl = webDriver.findElement(By.xpath("//input[@name='password']")); passwordEl.sendKeys(password); WebElement buttonEl = webDriver.findElement(By.xpath("//button[@id='form-sign-in-button']")); buttonEl.click(); WebDriverWait wait = new WebDriverWait(webDriver, 10); wait.until(ExpectedConditions.presenceOfElementLocated(By.xpath("//a[text()='Sign out']"))); }
From source file:org.orcid.integration.blackbox.web.works.AddWorksTest.java
License:Open Source License
public static void addSimple(String workName, WebDriver webDriver) { WebDriverWait wait = new WebDriverWait(webDriver, 10); ;/* ww w . java 2 s. c o m*/ waitWorksLoaded(wait); // Selenium is having issues finding this element, I supect do to CSS transformations // Run the function directly ((JavascriptExecutor) webDriver) .executeScript("angular.element('[ng-controller=WorkCtrl]').scope().addWorkModal()"); wait.until(ExpectedConditions .presenceOfElementLocated(By.xpath("//select[@ng-model='editWork.workCategory.value']"))); Select catSel = new Select( webDriver.findElement(By.xpath("//select[@ng-model='editWork.workCategory.value']"))); catSel.selectByVisibleText("Conference"); wait.until(ExpectedConditions.presenceOfElementLocated(By.xpath("//option[text()='Conference paper']"))); Select typeSel = new Select( webDriver.findElement(By.xpath("//select[@ng-model='editWork.workType.value']"))); typeSel.selectByVisibleText("Conference paper"); WebElement title = webDriver.findElement(By.xpath("//input[@ng-model='editWork.title.value']")); title.sendKeys(workName); WebElement buttonEl = webDriver.findElement(By.xpath("//button[@id='save-new-work']")); buttonEl.click(); SigninTest.colorBoxIsClosed(wait); waitWorksLoaded(wait); wait.until(ExpectedConditions.presenceOfAllElementsLocatedBy(byWorkTitle(workName))); }