List of usage examples for org.openqa.selenium.support.ui ExpectedConditions presenceOfElementLocated
public static ExpectedCondition<WebElement> presenceOfElementLocated(final By locator)
From source file:com.meschbach.onomate.tests.assembly.scenarios.OnomateAssembly.java
License:Apache License
private void waitOn(By selector) { try {/* w w w. ja v a 2 s. co m*/ WebDriverWait wait = new WebDriverWait(driver, 2); wait.until(ExpectedConditions.presenceOfElementLocated(selector)); } catch (TimeoutException te) { throw new WaitTimeoutException("Unable to locate " + selector.toString(), te); } }
From source file:com.mycompany.selenium.factory.pages.Google.ResultsPage.java
public ResultsPage() { PageFactory.initElements(Init.getDriver(), this); (new WebDriverWait(Init.getDriver(), 10)) .until(ExpectedConditions.presenceOfElementLocated(By.id("resultStats"))); }
From source file:com.nabla.project.fronter.selenium.tests.pageobjects.RollsPage.java
License:Open Source License
@Given("the user is on Rolls Page") public void The_user_is_on_loan_page() { SeleniumHelper.getDriver().get(SeleniumHelper.baseUrl + this.url); final JavascriptExecutor js = (JavascriptExecutor) SeleniumHelper.getDriver(); // Get the Load Event End final long loadEventEnd = (Long) js.executeScript("return window.performance.timing.loadEventEnd;"); // Get the Navigation Event Start final long navigationStart = (Long) js.executeScript("return window.performance.timing.navigationStart;"); // Difference between Load Event End and Navigation Event Start is Page Load Time System.out.println("Page Load Time is " + ((loadEventEnd - navigationStart) / 1000) + " seconds."); // Wait for the Calculate Button new WebDriverWait(SeleniumHelper.getDriver(), 10) .until(ExpectedConditions.presenceOfElementLocated(By.id("rolls_form:score"))); // WebElement myDynamicElement = (new WebDriverWait(driver, 20)).until(ExpectedConditions.presenceOfElementLocated(By.id("loan_form"))); Assert.assertEquals("Kata Bowling Calculator", SeleniumHelper.getDriver().findElement(By.cssSelector("h3")).getText()); }
From source file:com.nabla.project.visma.selenium.tests.pageobjects.LoanPage.java
License:Open Source License
@Given("the user is on Loan Page") public void The_user_is_on_loan_page() { SeleniumHelper.getDriver().get(SeleniumHelper.BASE_URL + this.url); final JavascriptExecutor js = (JavascriptExecutor) SeleniumHelper.getDriver(); // Get the Load Event End final long loadEventEnd = (Long) js.executeScript("return window.performance.timing.loadEventEnd;"); // Get the Navigation Event Start final long navigationStart = (Long) js.executeScript("return window.performance.timing.navigationStart;"); // Difference between Load Event End and Navigation Event Start is Page Load Time LOGGER.info("Page Load Time is {} seconds.", ((loadEventEnd - navigationStart) / 1000)); // SeleniumHelper.getSelenium().waitForPageToLoad(SeleniumHelper.PAGE_TO_LOAD_TIMEOUT); // Wait for the Calculate Button new WebDriverWait(SeleniumHelper.getDriver(), 10) .until(ExpectedConditions.presenceOfElementLocated(By.id("loan_form:payment"))); // WebElement myDynamicElement = (new WebDriverWait(driver, 20)).until(ExpectedConditions.presenceOfElementLocated(By.id("loan_form"))); Assert.assertEquals("Housing Loan Cost Calculator", SeleniumHelper.getDriver().findElement(By.cssSelector("h3")).getText()); }
From source file:com.novartis.opensource.yada.test.YADAAdminTest.java
License:Apache License
/** * Tests splash screen//from w ww . j ava 2 s. co m */ @Test(priority = 0) public void testLandingPage() { WebDriver d = getDriver(); for (WebElement e : d.findElement(By.tagName("nav")).findElements(By.cssSelector("li a"))) { try { e.click(); } catch (WebDriverException e1) { l.debug("Navbar unclickable as expected."); } } WebElement e = d.findElement(By.id("app-mgr")); Assert.assertFalse(e.isDisplayed()); e = d.findElement(By.id("query-table")); Assert.assertFalse(e.isDisplayed()); e = d.findElement(By.id("qname-copy")); Assert.assertFalse(e.isDisplayed()); e = d.findElement(By.id("migration-target-selector")); Assert.assertFalse(e.isDisplayed()); e = d.findElement(By.id("query-editor-container")); Assert.assertFalse(e.isDisplayed()); e = d.findElement(By.id("compare")); Assert.assertFalse(e.isDisplayed()); new WebDriverWait(d, 300) .until(ExpectedConditions.presenceOfElementLocated(By.cssSelector("#login .modal-dialog"))); Assert.assertFalse(d.findElement(By.id("login-btn")).isEnabled()); }
From source file:com.novartis.opensource.yada.test.YADAAdminTest.java
License:Apache License
/** * Test App Manager new app creation/*from ww w. j a va 2 s. c o m*/ * @throws InterruptedException if any thread has interrupted the current thread */ @Test(dependsOnMethods = { "testLoginSuccess" }) public void testAppCreation() throws InterruptedException { String t = new String(Long.valueOf(new Date().getTime()).toString()); this.app = "FOO" + t.substring(t.length() < 17 ? 0 : t.length() - 17); WebDriver d = getDriver(); d.findElement(By.id("app-hdr-new")).click(); Thread.sleep(100); Assert.assertTrue(d.findElement(By.id("app-new")).isDisplayed()); d.findElement(By.id("app-code-new")).sendKeys(this.app); d.findElement(By.id("app-active-new")).click(); d.findElement(By.id("app-name-new")).sendKeys(this.app); d.findElement(By.id("app-desc-new")).sendKeys("This is a test of new app functions using app " + this.app); StringBuilder conf = new StringBuilder(); conf.append("jdbcUrl="); conf.append(this.dbUrl); conf.append("\nusername="); conf.append(this.dbUser); conf.append("\npassword="); conf.append(this.dbPw); conf.append("\ndriverClassName="); conf.append(this.dbDriver); conf.append("\nautoCommit=false"); conf.append("\nconnectionTimeout=300000"); conf.append("\nidleTimeout=600000"); conf.append("\nmaxLifetime=1800000"); conf.append("\nminimumIdle=5"); conf.append("\nmaximumPoolSize=100"); WebElement e = d.findElement(By.id("app-conf-new")); e.clear(); e.sendKeys(conf.toString()); d.findElement(By.id("app-submit-new")).click(); e = new WebDriverWait(d, 20) .until(ExpectedConditions.presenceOfElementLocated(By.id("app-hdr-" + this.app))); Assert.assertTrue(e.isDisplayed()); }
From source file:com.novartis.opensource.yada.test.YADAAdminTest.java
License:Apache License
/** * Test App Manager new query for new app (prep only) * @throws InterruptedException if any thread has interrupted the current thread *///www . j av a 2 s . com @Test(dependsOnMethods = { "testNewQueryForNewAppCancel" }) public void testNewQueryForNewAppSave() throws InterruptedException { String qname = "Test Save"; this.createQueryForNewApp(qname, "save"); WebDriver d = getDriver(); // validate ui WebElement e = new WebDriverWait(d, 20) .until(ExpectedConditions.presenceOfElementLocated(By.cssSelector(".alert-success"))); String expected = "Hooray! Query " + this.app + " " + qname + " was saved successfully."; Assert.assertEquals(e.getText(), expected); WebElement save = d.findElement(By.id("button-save")); Assert.assertFalse(save.isDisplayed()); // close dialog d.findElement(By.id("button-cancel")).click(); Thread.sleep(3000); // validate query table has rows Assert.assertEquals(d.findElements(By.cssSelector("#query-table tbody td.dataTables_empty")).size(), 0); List<WebElement> rows = d.findElements(By.cssSelector("#query-table tbody tr[role=\"row\"]")); Assert.assertNotEquals(Integer.valueOf(rows.size()), Integer.valueOf(0)); // validate content of query table List<WebElement> cells = d.findElements(By.cssSelector("#query-table tbody tr[role=\"row\"] td")); String expectedQname = this.app + " " + qname; String expectedComments = "Testing comments".substring(0, 12) + ""; boolean qnameMatches = false; boolean commentsMatches = false; for (WebElement cell : cells) { if (cell.getText().equals(expectedQname)) { qnameMatches = true; break; } } for (WebElement cell : cells) { if (cell.getText().equals(expectedComments)) { commentsMatches = true; break; } } Assert.assertTrue(qnameMatches && commentsMatches); }
From source file:com.novartis.opensource.yada.test.YADAAdminTest.java
License:Apache License
/** * Clicks the "New Query" button and waits for dialog to open * @throws InterruptedException if any thread has interrupted the current thread *//*from ww w . java2s . co m*/ private void openQueryEditor() throws InterruptedException { // initiate query creation WebDriver d = getDriver(); d.findElement(By.id("new-query")).click(); this.switchToActiveElement(d, 3000); new WebDriverWait(d, 20) .until(ExpectedConditions.presenceOfElementLocated(By.id("query-editor-container"))); }
From source file:com.novartis.opensource.yada.test.YADAAdminTest.java
License:Apache License
/** * Makes assertions about default state of query editor modal */// w w w . jav a2 s .c o m private void validateQueryEditor() { WebDriver d = getDriver(); WebElement e = d.findElement(By.id("query-editor-container")); Assert.assertTrue(e.isDisplayed()); List<WebElement> list = d.findElements(By.xpath("//div[contains(@class,\"panel \")]")); Assert.assertEquals(list.size(), 3); list = d.findElements(By.xpath("//div[contains(@class,\"panel \") and @style=\"display: none;\"]")); Assert.assertEquals(list.size(), 2); new WebDriverWait(d, 20).until(ExpectedConditions.presenceOfElementLocated(By.id("collapseOne"))); Assert.assertTrue(d.findElement(By.id("collapseOne")).isDisplayed()); // comments Assert.assertFalse(d.findElement(By.id("collapseTwo")).isDisplayed()); // security Assert.assertFalse(d.findElement(By.id("collapseThree")).isDisplayed()); // params // validate buttons in footer list = d.findElements( By.xpath("//div[@id=\"query-editor-container\"]//div[contains(@class,\"modal-footer\")]/button")); Assert.assertEquals(list.size(), 5); list = d.findElements(By.xpath( "//div[@id=\"query-editor-container\"]//div[contains(@class,\"modal-footer\")]/button[@style=\"display: none;\"]")); Assert.assertEquals(list.size(), 3); Assert.assertTrue(d.findElement(By.id("button-save")).isDisplayed()); Assert.assertTrue(d.findElement(By.id("button-cancel")).isDisplayed()); Assert.assertFalse(d.findElement(By.id("button-rename")).isDisplayed()); Assert.assertFalse(d.findElement(By.id("button-copy")).isDisplayed()); Assert.assertFalse(d.findElement(By.id("button-delete")).isDisplayed()); }
From source file:com.novartis.opensource.yada.test.YADAAdminTest.java
License:Apache License
/** * Test App Manager new query for new app (prep only) * @param qname the name of query to test * @param query the sql to insert//from w w w . ja va 2 s .c o m * @param action {@code save} or {@code cancel}. Case matters as this value corresponds to a button id * @throws InterruptedException if any thread has interrupted the current thread */ private void createQueryForNewApp(String qname, String query, String action) throws InterruptedException { WebDriver d = getDriver(); // restore app-mgr d.findElement(By.id("app")).click(); new WebDriverWait(d, 20).until(ExpectedConditions.presenceOfElementLocated(By.id("app-mgr"))); // click app's 'queries' button d.findElement(By.id("app-qname-" + this.app)).click(); validateMenues(); openQueryEditor(); validateQueryEditor(); // populate fields d.findElement(By.id("query-name")).sendKeys(qname); d.findElement(By.id("query-comments")).sendKeys("Testing comments"); // codemirror WebElement e = d.findElement(By.cssSelector("div.CodeMirror")); JavascriptExecutor js = (JavascriptExecutor) d; js.executeScript("arguments[0].CodeMirror.setValue(\"" + query + "\");", e); d.findElement(By.id("button-" + action)).click(); }