List of usage examples for org.openqa.selenium.support.ui ExpectedConditions visibilityOf
public static ExpectedCondition<WebElement> visibilityOf(final WebElement element)
From source file:com.liferay.blade.samples.servicebuilder.web.BladeServiceBuilderWebTest.java
License:Apache License
protected boolean isVisible(WebElement webelement) { WebDriverWait webDriverWait = new WebDriverWait(_webDriver, 5); try {/* w w w. j ava2s. co m*/ webDriverWait.until(ExpectedConditions.visibilityOf(webelement)); return true; } catch (org.openqa.selenium.TimeoutException te) { return false; } }
From source file:com.mastfrog.selenium.Utils.java
License:Open Source License
/** * Verifies if an element is visible. Continue with tests even if false. * * @param expression boolean expression to evaluate * @param msg message to log on failure//from ww w. ja v a 2 s . c om */ public void waitForVisible(WebElement elementToBeVisible) { Checks.notNull("elementToBeVisible", elementToBeVisible); try { wait.until(ExpectedConditions.visibilityOf(elementToBeVisible)); } catch (Exception e) { Exceptions.chuck(e); } }
From source file:com.mkl.websuites.internal.command.impl.wait.WaitUntilVisibleCommand.java
License:Apache License
@Override protected void doOperationOnElement(WebElement elem) { WebDriverWait wait = new WebDriverWait(browser, getWebElementWaitTimeout()); wait.until(ExpectedConditions.visibilityOf(elem)); }
From source file:com.mycompany.myproject.sample.simple.UIFlowUsingSeLionPageObjectsTest.java
License:Apache License
@Test @WebTest/*from www .j a va 2 s . c om*/ public void myTest() { Grid.open(TestServerUtils.getAppURL()); MyAppHomePage page = new MyAppHomePage(System.getProperty("locale")); page.getFirstNameTextField().type("Joe"); page.getLastNameTextField().type("User"); page.getEmailTextField().type("joeuser@foo.bar"); page.getSubmitButton() .clickAndExpect(ExpectedConditions.visibilityOf(page.getRetryAgainButton().getElement())); assertEquals(page.getFirstNameLabel().getAttribute("innerHTML"), "Joe"); assertEquals(page.getLastNameLabel().getAttribute("innerHTML"), "User"); assertEquals(page.getEmailLabel().getAttribute("innerHTML"), "joeuser@foo.bar"); }
From source file:com.mycompany.myselion.sample.selion.UIFlowUsingSeLionPageObjectsTest.java
License:Apache License
@Test @WebTest// w ww .j av a 2 s . c o m public void myTest() { Grid.open(TestServerUtils.getAppURL()); //We are now creating a page object that represents the actual test page. //In our yaml file which resides under src/main/resources/GUIData our localization value is being //given as "english". The default value that SeLion assumes would be "US". So we have two options //1. We instantiate the page by passing in the value of 'english' which is how we are going to be // dealing with our localizations. //2. We can set this at the entire JVM level by passing in the value via the JVM argument //-DSELION_SITE_LOCALE=english //3. We can set this at a specific <test> level by setting the parameter //<parameter name="siteLocale" value="english"/> in the suite xml file. MyAppHomePage page = new MyAppHomePage("US"); page.getFirstNameTextField().type("Joe"); page.getLastNameTextField().type("User"); page.getEmailTextField().type("joeuser@foo.bar"); page.getSubmitButton() .clickAndExpect(ExpectedConditions.visibilityOf(page.getRetryAgainButton().getElement())); assertEquals(page.getFirstNameLabel().getAttribute("innerHTML"), "Joe"); assertEquals(page.getLastNameLabel().getAttribute("innerHTML"), "User"); assertEquals(page.getEmailLabel().getAttribute("innerHTML"), "joeuser@foo.bar"); }
From source file:com.owncloud.android.test.ui.actions.Actions.java
License:Open Source License
public static FileListView login(String url, String user, String password, Boolean isTrusted, AndroidDriver driver) throws InterruptedException { LoginForm loginForm = new LoginForm(driver); CertificatePopUp certificatePopUp = loginForm.typeHostUrl(url); if (!isTrusted) { WebDriverWait wait = new WebDriverWait(driver, 30); //sometimes the certificate has been already accept //and it doesn't appear again try {// ww w .j ava2 s . c o m wait.until(ExpectedConditions.visibilityOf(certificatePopUp.getOkButtonElement())); //we need to repaint the screen //because of some element are misplaced driver.rotate(ScreenOrientation.LANDSCAPE); driver.rotate(ScreenOrientation.PORTRAIT); certificatePopUp.clickOnOkButton(); } catch (NoSuchElementException e) { } } loginForm.typeUserName(user); loginForm.typePassword(password); //TODO. Assert related to check the connection? return loginForm.clickOnConnectButton(); }
From source file:com.owncloud.android.test.ui.actions.Actions.java
License:Open Source License
public static AndroidElement shareLinkElementByGmail(String elementName, FileListView fileListView, AndroidDriver driver, Common common) throws Exception { try {/* www .j av a2 s . c om*/ //To open directly the "file list view" and //we don't need to know in which view we are driver.startActivity("com.owncloud.android", ".ui.activity.FileDisplayActivity"); ElementMenuOptions menuOptions = fileListView.longPressOnElement(elementName); ShareView shareView = menuOptions.clickOnShareLinkElement(); Actions.scrollTillFindElement("Gmail", shareView.getListViewLayout(), driver).click(); GmailSendMailView gmailSendMailView = new GmailSendMailView(driver); gmailSendMailView.typeToEmailAdress(Config.gmailAccount); gmailSendMailView.clickOnSendButton(); Common.waitTillElementIsNotPresentWithoutTimeout(fileListView.getProgressCircular(), 1000); common.wait.until(ExpectedConditions.visibilityOf(fileListView.getFileElementLayout() .findElement(By.id(FileListView.getSharedElementIndicator())))); } catch (NoSuchElementException e) { return null; } return (AndroidElement) fileListView.getFileElementLayout() .findElement(By.id(FileListView.getSharedElementIndicator())); }
From source file:com.owncloud.android.test.ui.actions.Actions.java
License:Open Source License
public static AndroidElement shareLinkElementByCopyLink(String elementName, FileListView fileListView, AndroidDriver driver, Common common) throws Exception { try {/*from w w w. jav a 2 s .com*/ //To open directly the "file list view" and //we don't need to know in which view we are driver.startActivity("com.owncloud.android", ".ui.activity.FileDisplayActivity"); ElementMenuOptions menuOptions = fileListView.longPressOnElement(elementName); ShareView shareView = menuOptions.clickOnShareLinkElement(); Actions.scrollTillFindElement("Copy link", shareView.getListViewLayout(), driver).click(); WaitAMomentPopUp waitAMomentPopUp = new WaitAMomentPopUp(driver); Common.waitTillElementIsNotPresentWithoutTimeout(waitAMomentPopUp.getWaitAMomentTextElement(), 100); common.wait.until(ExpectedConditions.visibilityOf(fileListView.getFileElementLayout() .findElement(By.id(FileListView.getSharedElementIndicator())))); } catch (NoSuchElementException e) { return null; } return (AndroidElement) fileListView.getFileElementLayout() .findElement(By.id(FileListView.getSharedElementIndicator())); }
From source file:com.owncloud.android.test.ui.testSuites.DeleteFileTestSuite.java
License:Open Source License
@Test @Category({ NoIgnoreTestCategory.class, SmokeTestCategory.class }) public void testDeleteFile() throws Exception { FileListView fileListView = Actions.login(Config.URL, Config.user, Config.password, Config.isTrusted, driver);/*from www . j a v a2s . com*/ common.assertIsInFileListView(); //TODO. if the file already exists, do not upload FileListView fileListViewAfterUploadFile = Actions.uploadFile(FILE_NAME, fileListView); fileListViewAfterUploadFile.scrollTillFindElement(FILE_NAME); Common.waitTillElementIsNotPresentWithoutTimeout(fileListViewAfterUploadFile.getProgressCircular(), 1000); common.wait.until(ExpectedConditions.visibilityOf(fileListViewAfterUploadFile.getFileElementLayout() .findElement(By.id(FileListView.getLocalFileIndicator())))); Actions.deleteElement(FILE_NAME, fileListViewAfterUploadFile, driver); assertFalse(fileListViewAfterUploadFile.getFileElement().isDisplayed()); }
From source file:com.owncloud.android.test.ui.testSuites.RenameFileTestSuite.java
License:Open Source License
@Test @Category({ NoIgnoreTestCategory.class, SmokeTestCategory.class }) public void testRenameFile() throws Exception { FileListView fileListView = Actions.login(Config.URL, Config.user, Config.password, Config.isTrusted, driver);/* w w w . ja v a 2s . c o m*/ common.assertIsInFileListView(); //TODO. if the file already exists, do not upload FileListView fileListViewAfterUploadFile = Actions.uploadFile(OLD_FILE_NAME, fileListView); //check if the file with the new name already exists, if true delete it Actions.deleteElement(FILE_NAME, fileListView, driver); fileListViewAfterUploadFile.scrollTillFindElement(OLD_FILE_NAME); assertTrue(fileHasBeenCreated = fileListViewAfterUploadFile.getFileElement().isDisplayed()); CurrentCreatedFile = OLD_FILE_NAME; Common.waitTillElementIsNotPresentWithoutTimeout(fileListViewAfterUploadFile.getProgressCircular(), 1000); common.wait.until(ExpectedConditions.visibilityOf(fileListViewAfterUploadFile.getFileElementLayout() .findElement(By.id(FileListView.getLocalFileIndicator())))); ElementMenuOptions menuOptions = fileListViewAfterUploadFile.longPressOnElement(OLD_FILE_NAME); NewFolderPopUp newFolderPopUp = menuOptions.clickOnRename(); newFolderPopUp.typeNewFolderName(FILE_NAME); WaitAMomentPopUp waitAMomentPopUp = newFolderPopUp.clickOnNewFolderOkButton(); Common.waitTillElementIsNotPresentWithoutTimeout(waitAMomentPopUp.getWaitAMomentTextElement(), 100); fileListViewAfterUploadFile.scrollTillFindElement(FILE_NAME); assertNotNull(fileListViewAfterUploadFile.getFileElement()); assertTrue(fileListViewAfterUploadFile.getFileElement().isDisplayed()); assertEquals(FILE_NAME, fileListViewAfterUploadFile.getFileElement().getText()); CurrentCreatedFile = FILE_NAME; }