List of usage examples for org.openqa.selenium.support.ui ExpectedConditions elementToBeClickable
public static ExpectedCondition<WebElement> elementToBeClickable(final WebElement element)
From source file:com.digi.selenium.util.PageNavigation.java
protected void clickOnRadioRM50() { try {/*from w w w .j a v a 2 s . c o m*/ WebElement emailtxt = getDriver().findElement(By.id("reloadForm__email")); if (emailtxt.isDisplayed()) { handleInputField_ByID("reloadForm__email", AppConstants.EMAIL); Thread.sleep(500); } JavascriptExecutor js1 = (JavascriptExecutor) getDriver(); js1.executeScript("window.scrollBy(0,400)", ""); WebElement radio = getDriver().findElement(By.xpath("//*[@id='prepaidReloadForm']/ul/li[4]/label/div")); radio.click(); // now select check box to accept license agreement WebElement checkbox = getDriver().findElement(By.xpath("//*[@id='prepaidReloadForm']/label/div")); checkbox.click(); // click on proceed button after selecting radio button and check box // WebElement elementproceed=getDriver().findElement(By.xpath("//*[@id='proceedBtn']")); //*[@id="proceedBtn"] WebElement proceed = (new WebDriverWait(driver, 1000)) .until(ExpectedConditions.elementToBeClickable(By.xpath("//*[@id='proceedBtn']"))); proceed.click(); waitForPageLoad(100); Thread.sleep(500); JavascriptExecutor js = (JavascriptExecutor) getDriver(); js.executeScript("window.scrollBy(0,500)", ""); } catch (Exception e) { System.out.println(e); e.printStackTrace(); log.error("Fail : Failed to Reload amount."); System.exit(0); } }
From source file:com.digi.selenium.util.PageNavigation.java
protected void clickOnRadioRM100() { try {/*from w w w. j av a 2 s.c om*/ WebElement emailtxt = getDriver().findElement(By.id("reloadForm__email")); if (emailtxt.isDisplayed()) { handleInputField_ByID("reloadForm__email", AppConstants.EMAIL); Thread.sleep(500); } JavascriptExecutor js1 = (JavascriptExecutor) getDriver(); js1.executeScript("window.scrollBy(0,400)", ""); WebElement radio = getDriver().findElement(By.xpath("//*[@id='prepaidReloadForm']/ul/li[1]/label/div")); radio.click(); // now select check box to accept license agreement WebElement checkbox = getDriver().findElement(By.xpath("//*[@id='prepaidReloadForm']/label/div")); checkbox.click(); // click on proceed button after selecting radio button and check box // WebElement elementproceed=getDriver().findElement(By.xpath("//*[@id='proceedBtn']")); //*[@id="proceedBtn"] WebElement proceed = (new WebDriverWait(driver, 1000)) .until(ExpectedConditions.elementToBeClickable(By.xpath("//*[@id='proceedBtn']"))); proceed.click(); waitForPageLoad(100); Thread.sleep(500); JavascriptExecutor js = (JavascriptExecutor) getDriver(); js.executeScript("window.scrollBy(0,500)", ""); } catch (Exception e) { System.out.println(e); e.printStackTrace(); log.error("Fail : Failed to Reload amount."); System.exit(0); } }
From source file:com.ecofactor.qa.automation.platform.util.Pageutil.java
License:Open Source License
/** * Checks if the given element is clickable. * @param driver the driver/*from www . java 2 s. c om*/ * @param locator the locator * @param timeout the timeout * @return true, if is clickable */ public static boolean isClickable(final WebDriver driver, final WebElement element, final CustomTimeout timeout) { boolean displayed = true; try { final WebDriverWait wait = new WebDriverWait(driver, timeout.getValue()); wait.until(ExpectedConditions.elementToBeClickable(element)); } catch (TimeoutException te) { displayed = false; } return displayed; }
From source file:com.ecofactor.qa.automation.util.PageUtil.java
License:Open Source License
/** * Checks if is form element clickable by id. * @param driver the driver//from ww w .j a v a2 s .c o m * @param fieldname the fieldname * @param timeOut the time out */ public static void isFormElementClickableById(final WebDriver driver, final String fieldname, final int timeOut) { WebDriverWait wait = new WebDriverWait(driver, timeOut); wait.until(ExpectedConditions.elementToBeClickable(By.id(fieldname))); }
From source file:com.elastica.webelements.BasePage.java
License:Apache License
public void waitForElementEditable(final HtmlElement element) { Assert.assertNotNull(element, "Element can't be null"); TestLogging.logWebStep(null, "wait for " + element.toString() + " to be editable.", false); WebDriverWait wait = new WebDriverWait(driver, explictWaitTimeout); wait.until(ExpectedConditions.elementToBeClickable(element.getBy())); }
From source file:com.fullteaching.backend.e2e.FullTeachingTestE2E.java
License:Apache License
private void logut(BrowserUser user) { if (user.getDriver().findElements(By.cssSelector("#fixed-icon")).size() > 0) { // Get out of video session page user.getDriver().findElement(By.cssSelector("#fixed-icon")).click(); watiForAngularAnimations(500);/* w w w .j ava 2s .com*/ user.getWaiter().until(ExpectedConditions.elementToBeClickable(By.cssSelector("#exit-icon"))); user.getDriver().findElement(By.cssSelector("#exit-icon")).click(); } //if (user.getDriver().findElements(By.cssSelector("#arrow-drop-down")).size() > 0) { try { // Up bar menu user.getWaiter().withTimeout(1000, TimeUnit.MILLISECONDS) .until(ExpectedConditions.visibilityOfElementLocated(By.cssSelector("#arrow-drop-down"))); user.getDriver().findElement(By.cssSelector("#arrow-drop-down")).click(); watiForAngularAnimations(250); user.getWaiter().until(ExpectedConditions.elementToBeClickable(By.cssSelector("#logout-button"))); user.getDriver().findElement(By.cssSelector("#logout-button")).click(); } catch (TimeoutException e) { // Shrunk menu user.getWaiter().withTimeout(1000, TimeUnit.MILLISECONDS) .until(ExpectedConditions.visibilityOfElementLocated(By.cssSelector("a.button-collapse"))); user.getDriver().findElement(By.cssSelector("a.button-collapse")).click(); watiForAngularAnimations(250); user.getWaiter().until(ExpectedConditions .elementToBeClickable(By.xpath("//ul[@id='nav-mobile']//a[text() = 'Logout']"))); user.getDriver().findElement(By.xpath("//ul[@id='nav-mobile']//a[text() = 'Logout']")).click(); } user.getWaiter().until(ExpectedConditions.elementToBeClickable(By.id("download-button"))); }
From source file:com.fullteaching.backend.e2e.FullTeachingTestE2ESleep.java
License:Apache License
@Test @DisplayName("Test video session") void oneToOneVideoAudioSessionChrome() throws Exception { // TEACHER/*w w w .java 2s . c o m*/ final String userEmail = "teacher@gmail.com"; final String userPass = "pass"; this.user = setupBrowser("chrome"); log.info("Test video session"); this.login(user, userEmail, userPass); try { Thread.sleep(1000); } catch (InterruptedException e) { e.printStackTrace(); } user.getWaiter().until(ExpectedConditions.presenceOfElementLocated( By.cssSelector(("ul.collection li.collection-item:first-child div.course-title")))); user.getDriver() .findElement(By.cssSelector("ul.collection li.collection-item:first-child div.course-title")) .click(); try { Thread.sleep(1000); } catch (InterruptedException e) { e.printStackTrace(); } user.getWaiter().until(ExpectedConditions.presenceOfElementLocated(By.cssSelector(("#md-tab-label-0-1")))); user.getDriver().findElement(By.cssSelector("#md-tab-label-0-1")).click(); try { Thread.sleep(1000); } catch (InterruptedException e) { e.printStackTrace(); } user.getDriver().findElement(By.cssSelector("ul div:first-child li.session-data div.session-ready")) .click(); try { Thread.sleep(1000); } catch (InterruptedException e) { e.printStackTrace(); } user.getWaiter() .until(ExpectedConditions.presenceOfElementLocated(By.cssSelector(("div.participant video")))); try { Thread.sleep(1000); } catch (InterruptedException e) { e.printStackTrace(); } checkVideoPlaying(user, user.getDriver().findElement(By.cssSelector(("div.participant video"))), "div.participant"); // STUDENT BrowserUser student = setupBrowser("chrome"); login(student, "student1@gmail.com", "pass"); try { Thread.sleep(1000); } catch (InterruptedException e) { e.printStackTrace(); } student.getWaiter().until(ExpectedConditions.presenceOfElementLocated( By.cssSelector(("ul.collection li.collection-item:first-child div.course-title")))); student.getDriver() .findElement(By.cssSelector("ul.collection li.collection-item:first-child div.course-title")) .click(); try { Thread.sleep(1000); } catch (InterruptedException e) { e.printStackTrace(); } student.getWaiter() .until(ExpectedConditions.presenceOfElementLocated(By.cssSelector(("#md-tab-label-0-1")))); student.getDriver().findElement(By.cssSelector("#md-tab-label-0-1")).click(); try { Thread.sleep(1000); } catch (InterruptedException e) { e.printStackTrace(); } student.getDriver().findElement(By.cssSelector("ul div:first-child li.session-data div.session-ready")) .click(); try { Thread.sleep(1000); } catch (InterruptedException e) { e.printStackTrace(); } student.getWaiter() .until(ExpectedConditions.presenceOfElementLocated(By.cssSelector(("div.participant video")))); try { Thread.sleep(1000); } catch (InterruptedException e) { e.printStackTrace(); } checkVideoPlaying(student, student.getDriver().findElement(By.cssSelector(("div.participant video"))), "div.participant"); // Student ask for intervention student.getWaiter().until(ExpectedConditions.elementToBeClickable( By.xpath("//div[@id='div-header-buttons']//i[text() = 'record_voice_over']"))); student.getDriver() .findElement(By.xpath("//div[@id='div-header-buttons']//i[text() = 'record_voice_over']")).click(); try { Thread.sleep(1000); } catch (InterruptedException e) { e.printStackTrace(); } // Teacher accepts intervention user.getWaiter() .until(ExpectedConditions.elementToBeClickable(By.xpath("//a[contains(@class, 'usr-btn')]"))); user.getDriver().findElement(By.xpath("//a[contains(@class, 'usr-btn')]")).click(); // Check both videos student.getWaiter().until( ExpectedConditions.presenceOfElementLocated(By.cssSelector(("div.participant-small video")))); checkVideoPlaying(student, student.getDriver().findElement(By.cssSelector(("div.participant-small video"))), "div.participant-small"); checkVideoPlaying(student, student.getDriver().findElement(By.cssSelector(("div.participant-small video"))), "div.participant-small"); user.getWaiter().until( ExpectedConditions.presenceOfElementLocated(By.cssSelector(("div.participant-small video")))); checkVideoPlaying(user, user.getDriver().findElement(By.cssSelector(("div.participant-small video"))), "div.participant-small"); checkVideoPlaying(user, user.getDriver().findElement(By.cssSelector(("div.participant-small video"))), "div.participant-small"); try { Thread.sleep(5000); } catch (InterruptedException e) { e.printStackTrace(); } // Teacher removes user user.getWaiter() .until(ExpectedConditions.elementToBeClickable(By.xpath("//a[contains(@class, 'usr-btn')]"))); user.getDriver().findElement(By.xpath("//a[contains(@class, 'usr-btn')]")).click(); // Wait until only one video user.getWaiter().until(ExpectedConditions.not(ExpectedConditions .presenceOfAllElementsLocatedBy(By.cssSelector(("div.participant-small video"))))); student.getWaiter().until(ExpectedConditions.not(ExpectedConditions .presenceOfAllElementsLocatedBy(By.cssSelector(("div.participant-small video"))))); try { Thread.sleep(4000); } catch (InterruptedException e) { e.printStackTrace(); } // Logout student this.logut(student); student.dispose(); }
From source file:com.fullteaching.backend.e2e.FullTeachingTestE2ESleep.java
License:Apache License
private void logut(BrowserUser user) { if (user.getDriver().findElements(By.cssSelector("#fixed-icon")).size() > 0) { // Get out of video session page user.getDriver().findElement(By.cssSelector("#fixed-icon")).click(); watiForAngularAnimations(500);// ww w. j a v a 2s .co m user.getWaiter().until(ExpectedConditions.elementToBeClickable(By.cssSelector("#exit-icon"))); user.getDriver().findElement(By.cssSelector("#exit-icon")).click(); } //if (user.getDriver().findElements(By.cssSelector("#arrow-drop-down")).size() > 0) { try { // Up bar menu user.getWaiter().withTimeout(1000, TimeUnit.MILLISECONDS) .until(ExpectedConditions.visibilityOfElementLocated(By.cssSelector("#arrow-drop-down"))); user.getDriver().findElement(By.cssSelector("#arrow-drop-down")).click(); watiForAngularAnimations(250); user.getWaiter().until(ExpectedConditions.elementToBeClickable(By.cssSelector("#logout-button"))); user.getDriver().findElement(By.cssSelector("#logout-button")).click(); } catch (TimeoutException e) { // Shrunk menu user.getWaiter().withTimeout(1000, TimeUnit.MILLISECONDS) .until(ExpectedConditions.visibilityOfElementLocated(By.cssSelector("a.button-collapse"))); user.getDriver().findElement(By.cssSelector("a.button-collapse")).click(); watiForAngularAnimations(250); user.getWaiter().until(ExpectedConditions .elementToBeClickable(By.xpath("//ul[@id='nav-mobile']//a[text() = 'Logout']"))); user.getDriver().findElement(By.xpath("//ul[@id='nav-mobile']//a[text() = 'Logout']")).click(); } try { Thread.sleep(1000); } catch (InterruptedException e) { e.printStackTrace(); } user.getWaiter().until(ExpectedConditions.elementToBeClickable(By.id("download-button"))); }
From source file:com.ggasoftware.uitest.control.Element.java
License:Open Source License
/** * Wait until element is clickable and click at it. * * @param timeoutSec seconds to wait until element become clickable. * @return Parent instance//from ww w. j a v a 2 s .c om */ public ParentPanel waitForClickableAndClick(final int timeoutSec) { boolean isClicked; logAction(this, getParentClassName(), format("waitForClickable: %s", locator)); long start = System.currentTimeMillis() / 1000; WebDriverWait wait = (WebDriverWait) new WebDriverWait(getDriver(), timeoutSec) .ignoring(StaleElementReferenceException.class); try { wait.until(ExpectedConditions.elementToBeClickable(avatar.byLocator)); isClicked = wait.until(new ExpectedCondition<Boolean>() { @Override public Boolean apply(WebDriver driver) { try { setTimeout(timeoutSec); getWebElement().click(); setTimeout(TIMEOUT); return true; } catch (Exception e) { return false; } } }); } catch (TimeoutException e) { logTechnical(format("waitForClickable: [ %s ] during: [ %d ] sec ", locator, System.currentTimeMillis() / 1000 - start)); isClicked = false; } logAssertTrue(BUSINESS_LEVEL, isClicked, format("waitForClickableAndClick: '%s' was clickable and click at it", getName()), takePassedScreenshot); return parent; }
From source file:com.github.wasiqb.coteafs.appium.device.DeviceActivity.java
License:Apache License
/** * @author wasiq.bhamla/*from w w w . j a v a 2 s .c o m*/ * @since Jan 30, 2018 7:33:47 PM * @param locator * @param waitStrategy */ private void wait(final By locator, final WaitStrategy waitStrategy) { switch (waitStrategy) { case ENABLED: this.wait.until(ExpectedConditions.elementToBeClickable(locator)); break; case PRESENT: this.wait.until(ExpectedConditions.presenceOfAllElementsLocatedBy(locator)); break; case VISIBLE: this.wait.until(visibilityOfAllElementsLocatedBy(locator)); break; case NONE: default: break; } }