/** * Select from the drop down list,if the drop down element tag is "SELECT" then use this method */ public void selectDropDownByVisibleText(MethodParameters model) { wait1(2000); MainTestNG.LOGGER.info("inside selectDropDownByVisibleText"); WebDriverWait wait = new WebDriverWait(WebDriverClass.getDriver(), 30); wait.pollingEvery(2, TimeUnit.SECONDS) .until(ExpectedConditions.elementToBeClickable(model.getElement().get(0))); Select sel = new Select(model.getElement().get(0)); sel.selectByVisibleText(model.getData()); wait1(2000); }
/** * Simple test which verifies that the demo starts. * * @throws Exception oops */ @Test public void testDemoLoadsProperly() throws Exception { WebDriverWait wait = new WebDriverWait(driver, 20); wait.pollingEvery(500, TimeUnit.MILLISECONDS); driver.get("http://localhost:9080/"); // the login window should appear wait.until( new ExpectedCondition<Boolean>() { public Boolean apply(WebDriver d) { return null != d.findElement(By.id("isc_M")); } }); }
public static WebElement waitForElement(By by) { int count = 0; WebDriverWait wait = null; while (!(wait.until(ExpectedConditions.presenceOfElementLocated(by)).isDisplayed())) { wait = new WebDriverWait(WebDriverClass.getInstance(), 60); wait.pollingEvery(5, TimeUnit.MILLISECONDS); wait.until(ExpectedConditions.visibilityOfElementLocated(by)).isDisplayed(); wait.until(ExpectedConditions.presenceOfElementLocated(by)).isDisplayed(); count++; if (count == 100) { break; } return wait.until(ExpectedConditions.presenceOfElementLocated(by)); } return wait.until(ExpectedConditions.presenceOfElementLocated(by)); }