List of usage examples for org.openqa.selenium.support.ui ExpectedConditions visibilityOfElementLocated
public static ExpectedCondition<WebElement> visibilityOfElementLocated(final By locator)
From source file:org.cerberus.service.SeleniumServiceTest.java
License:Open Source License
@Test public void testDoActionClickWaitWhenObjectNotNullAndPropertyNULL() throws Exception { String object = "id=test"; String property = "null"; String msg = "Element '" + object + "' clicked and waited for page to load"; PowerMockito.mockStatic(ExpectedConditions.class); PowerMockito.mockStatic(By.class); when(selenium.getDriver()).thenReturn(driver); when(By.id(anyString())).thenReturn(by); PowerMockito.whenNew(WebDriverWait.class).withAnyArguments().thenReturn(webDriverWait); when(ExpectedConditions.visibilityOfElementLocated(by)).thenReturn(expectedCondition); when(webDriverWait.until(ExpectedConditions.visibilityOfElementLocated(by))).thenReturn(element); when(driver.findElement(by)).thenReturn(element); MessageEvent message = this.seleniumService.doSeleniumActionClickWait(selenium, object, property); Assert.assertEquals(msg, message.getDescription()); }
From source file:org.cerberus.service.webdriver.impl.WebDriverService.java
License:Open Source License
private AnswerItem<WebElement> getSeleniumElement(Session session, Identifier identifier, boolean visible, boolean clickable) { AnswerItem<WebElement> answer = new AnswerItem<WebElement>(); MessageEvent msg;/*from w ww . j a v a 2s . c o m*/ By locator = this.getBy(identifier); MyLogger.log(WebDriverService.class.getName(), Level.DEBUG, "Waiting for Element : " + identifier.getIdentifier() + "=" + identifier.getLocator()); try { WebDriverWait wait = new WebDriverWait(session.getDriver(), TimeUnit.MILLISECONDS.toSeconds(session.getCerberus_selenium_wait_element())); WebElement element; if (visible) { if (clickable) { element = wait.until(ExpectedConditions.elementToBeClickable(locator)); } else { element = wait.until(ExpectedConditions.visibilityOfElementLocated(locator)); } } else { element = wait.until(ExpectedConditions.presenceOfElementLocated(locator)); } answer.setItem(element); msg = new MessageEvent(MessageEventEnum.ACTION_SUCCESS_WAIT_ELEMENT); msg.setDescription(msg.getDescription().replace("%ELEMENT%", identifier.getIdentifier() + "=" + identifier.getLocator())); } catch (TimeoutException exception) { MyLogger.log(WebDriverService.class.getName(), Level.FATAL, "Exception waiting for element :" + exception); //throw new NoSuchElementException(identifier.getIdentifier() + "=" + identifier.getLocator()); msg = new MessageEvent(MessageEventEnum.ACTION_FAILED_WAIT_NO_SUCH_ELEMENT); msg.setDescription(msg.getDescription().replace("%ELEMENT%", identifier.getIdentifier() + "=" + identifier.getLocator())); } answer.setResultMessage(msg); return answer; }
From source file:org.cerberus.serviceEngine.impl.SeleniumService.java
License:Open Source License
private WebElement getSeleniumElement(Selenium selenium, String input, boolean visible) { By locator = this.getIdentifier(input); MyLogger.log(RunTestCaseService.class.getName(), Level.DEBUG, "Waiting for Element : " + input); try {/*from ww w. j ava2 s . c o m*/ WebDriverWait wait = new WebDriverWait(selenium.getDriver(), selenium.getDefaultWait()); if (visible) { wait.until(ExpectedConditions.visibilityOfElementLocated(locator)); } else { wait.until(ExpectedConditions.presenceOfElementLocated(locator)); } } catch (TimeoutException exception) { throw new NoSuchElementException(input); } MyLogger.log(RunTestCaseService.class.getName(), Level.DEBUG, "Finding selenium Element : " + input); return selenium.getDriver().findElement(locator); }
From source file:org.cerberus.serviceEngine.impl.SeleniumServiceTest.java
License:Open Source License
@Test public void testDoActionClickObjectWhenSuccess() throws Exception { String object = "id=test"; String property = "null"; String msg = "Element '" + object + "' clicked."; boolean waitForVisibility = true; boolean waitForClickability = true; PowerMockito.mockStatic(ExpectedConditions.class); PowerMockito.mockStatic(By.class); when(session.getDriver()).thenReturn(driver); when(By.id(anyString())).thenReturn(by); PowerMockito.whenNew(WebDriverWait.class).withAnyArguments().thenReturn(webDriverWait); when(ExpectedConditions.visibilityOfElementLocated(by)).thenReturn(expectedCondition); when(fluentWait.until(expectedCondition)).thenReturn(element); when(driver.findElement(by)).thenReturn(element); MessageEvent message = this.webdriverService.doSeleniumActionClick(session, object, property, waitForVisibility, waitForClickability); Assert.assertEquals(msg, message.getDescription()); }
From source file:org.cerberus.serviceEngine.impl.SeleniumServiceTest.java
License:Open Source License
@Test public void testDoActionClickPropertyWhenSuccess() throws Exception { String object = "null"; String property = "id=test"; String msg = "Element '" + property + "' clicked."; boolean waitForVisibility = true; boolean waitForClickability = true; PowerMockito.mockStatic(ExpectedConditions.class); PowerMockito.mockStatic(By.class); when(session.getDriver()).thenReturn(driver); when(By.id(anyString())).thenReturn(by); PowerMockito.whenNew(WebDriverWait.class).withAnyArguments().thenReturn(webDriverWait); when(ExpectedConditions.visibilityOfElementLocated(by)).thenReturn(expectedCondition); when(fluentWait.until(ExpectedConditions.visibilityOfElementLocated(by))).thenReturn(element); when(driver.findElement(by)).thenReturn(element); MessageEvent message = this.webdriverService.doSeleniumActionClick(session, object, property, waitForVisibility, waitForClickability); Assert.assertEquals(msg, message.getDescription()); }
From source file:org.cerberus.serviceEngine.impl.SeleniumServiceTest.java
License:Open Source License
/** * Action ClickAndWait/*w w w . ja v a2 s . c om*/ */ @Test public void testDoActionClickWaitWhenSuccess() throws Exception { String object = "id=test"; String property = "100"; String msg = "Element '" + object + "' clicked and waited " + property + " ms."; PowerMockito.mockStatic(ExpectedConditions.class); PowerMockito.mockStatic(By.class); when(session.getDriver()).thenReturn(driver); when(By.id(anyString())).thenReturn(by); PowerMockito.whenNew(WebDriverWait.class).withAnyArguments().thenReturn(webDriverWait); when(ExpectedConditions.visibilityOfElementLocated(by)).thenReturn(expectedCondition); when(webDriverWait.until(ExpectedConditions.visibilityOfElementLocated(by))).thenReturn(element); when(driver.findElement(by)).thenReturn(element); MessageEvent message = this.webdriverService.doSeleniumActionClickWait(session, object, property); Assert.assertEquals(msg, message.getDescription()); }
From source file:org.cerberus.serviceEngine.impl.SeleniumServiceTest.java
License:Open Source License
@Test public void testDoActionClickWaitWhenPropertyNotNumeric() throws Exception { String object = "id=test"; String property = "dez"; String msg = "Failed to wait because '" + property + "' in not numeric!"; PowerMockito.mockStatic(ExpectedConditions.class); PowerMockito.mockStatic(By.class); when(session.getDriver()).thenReturn(driver); when(By.id(anyString())).thenReturn(by); PowerMockito.whenNew(WebDriverWait.class).withAnyArguments().thenReturn(webDriverWait); when(ExpectedConditions.visibilityOfElementLocated(by)).thenReturn(expectedCondition); when(webDriverWait.until(ExpectedConditions.visibilityOfElementLocated(by))).thenReturn(element); when(driver.findElement(by)).thenReturn(element); MessageEvent message = this.webdriverService.doSeleniumActionClickWait(session, object, property); Assert.assertEquals(msg, message.getDescription()); }
From source file:org.cerberus.serviceEngine.impl.SeleniumServiceTest.java
License:Open Source License
@Test public void testDoActionClickWaitWhenObjectNotNullAndPropertyNULL() throws Exception { String object = "id=test"; String property = "null"; String msg = "Element '" + object + "' clicked and waited for page to load"; PowerMockito.mockStatic(ExpectedConditions.class); PowerMockito.mockStatic(By.class); when(session.getDriver()).thenReturn(driver); when(By.id(anyString())).thenReturn(by); PowerMockito.whenNew(WebDriverWait.class).withAnyArguments().thenReturn(webDriverWait); when(ExpectedConditions.visibilityOfElementLocated(by)).thenReturn(expectedCondition); when(webDriverWait.until(ExpectedConditions.visibilityOfElementLocated(by))).thenReturn(element); when(driver.findElement(by)).thenReturn(element); MessageEvent message = this.webdriverService.doSeleniumActionClickWait(session, object, property); Assert.assertEquals(msg, message.getDescription()); }
From source file:org.cerberus.serviceEngine.impl.WebDriverService.java
License:Open Source License
private WebElement getSeleniumElement(Session session, String input, boolean visible, boolean clickable) { By locator = this.getIdentifier(input); MyLogger.log(RunTestCaseService.class.getName(), Level.DEBUG, "Waiting for Element : " + input); try {/* ww w . j a v a 2 s . co m*/ WebDriverWait wait = new WebDriverWait(session.getDriver(), session.getDefaultWait()); if (visible) { if (clickable) { wait.until(ExpectedConditions.elementToBeClickable(locator)); } else { wait.until(ExpectedConditions.visibilityOfElementLocated(locator)); } } else { wait.until(ExpectedConditions.presenceOfElementLocated(locator)); } } catch (TimeoutException exception) { MyLogger.log(RunTestCaseService.class.getName(), Level.FATAL, "Exception waiting for element :" + exception); throw new NoSuchElementException(input); } MyLogger.log(RunTestCaseService.class.getName(), Level.DEBUG, "Finding Element : " + input); return session.getDriver().findElement(locator); }
From source file:org.eclipse.che.selenium.debugger.NodeJsDebugTest.java
License:Open Source License
/** Check step into, step over and step out feature */ private void checkDebugStepsFeatures() { debugPanel.clickOnButton(DebuggerButtonsPanel.STEP_OVER); debugPanel.waitDebugHighlightedText("var b = greetings.sayHelloInEnglish();"); debugPanel.clickOnButton(DebuggerButtonsPanel.STEP_INTO); editorPageObj.waitActiveEditor();// www .j ava2 s .co m editorPageObj.waitTabIsPresent("greetings.js"); debugPanel.waitDebugHighlightedText("return \"HELLO\";"); debugPanel.clickOnButton(DebuggerButtonsPanel.STEP_OUT); debugPanel.waitDebugHighlightedText("var c=\"some add value\" + b;"); new WebDriverWait(ide.driver(), REDRAW_UI_ELEMENTS_TIMEOUT_SEC) .until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//div[text()='{app.js:13} ']"))); debugPanel.clickOnButton(DebuggerButtonsPanel.STEP_OVER); }