List of usage examples for org.openqa.selenium.support.ui ExpectedConditions elementToBeClickable
public static ExpectedCondition<WebElement> elementToBeClickable(final WebElement element)
From source file:com.java.AppTestType_18_11_2015.java
public void SIGNIN(WebDriver driver, String fieldText, String value) { try {/*from www . jav a 2s . com*/ try { WebDriverWait wait = new WebDriverWait(driver, 20); // wait.until(ExpectedConditions.titleIs("Used Equipment Sales | Buy & Sell Online | Ritchie Bros. EquipmentOne")); driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS); driver.manage().deleteAllCookies(); //driver.findElement(By.linkText("Sign In")).click(); driver.findElement(By.name("josso_username")).clear(); driver.findElement(By.name("josso_username")).sendKeys(fieldText); driver.findElement(By.name("josso_password")).clear(); driver.findElement(By.name("josso_password")).sendKeys("Equipment1$"); try { driver.findElement(By.xpath("//*[@value='SIGN IN']")).click(); } catch (Exception elementnotfoundexException) { driver.findElement(By.xpath("//button[text()='SIGN IN']")).click(); } System.out.println("size is :" + driver.findElements(By.id("iduser")).size()); if (driver.findElements(By.id("iduser")).size() > 0) { System.out.println("1111111111"); driver.manage().timeouts().implicitlyWait(4, TimeUnit.SECONDS); if (driver.findElements(By.xpath("//input[@id='useragreetoterms' and @type='checkbox']")) .size() > 0) { driver.findElement(By.xpath("//input[@id='useragreetoterms' and @type='checkbox']")) .click(); driver.findElement( By.xpath("//*[@class='btn btn-primary btn-group-justified' and @type='submit']")) .click(); driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS); // driver.findElement(By.xpath("//input[@value='Go to EquipmentOne']")).click(); // wait.until(ExpectedConditions.titleIs("Used Equipment Sales | Buy & Sell Online | Ritchie Bros. EquipmentOne")); } //to confirm successful sign in as valid user,verifying the name displayed next to "Hello" text if (driver.findElement(By.id("iduser")).getText().equalsIgnoreCase(value)) System.out.println("Successfully Logged in"); else { driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS); driver.findElement(By.linkText("Sign Out")).click(); wait.until(ExpectedConditions.visibilityOfAllElementsLocatedBy(By.name("josso_password"))); driver.findElement(By.name("josso_username")).clear(); driver.findElement(By.name("josso_username")).sendKeys(fieldText); driver.findElement(By.name("josso_password")).clear(); driver.findElement(By.name("josso_password")).sendKeys("Equipment1$"); driver.findElement(By.xpath("//*[@value='SIGN IN']")).click(); wait.until(ExpectedConditions.elementToBeClickable(By.id("iduser"))); //agree terms-This piece of code is to verify agree terms checkbox after re logging(not logged in as the valid user) driver.manage().timeouts().implicitlyWait(4, TimeUnit.SECONDS); if (driver.findElements(By.xpath("//input[@id='useragreetoterms' and @type='checkbox']")) .size() > 0) { driver.findElement(By.xpath("//input[@id='useragreetoterms' and @type='checkbox']")) .click(); driver.findElement(By .xpath("//*[@class='btn btn-primary btn-group-justified' and @type='submit']")) .click(); driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS); // driver.findElement(By.xpath("//input[@value='Go to EquipmentOne']")).click(); // wait.until(ExpectedConditions.titleIs("Used Equipment Sales | Buy & Sell Online | Ritchie Bros. EquipmentOne")); } } resultDetails.setFlag(true); } } //This catch is used to catch the error "You are NOT authorized to access Site" in E1 Login// ///////////////////////////////////// catch (Exception e1) { driver.manage().timeouts().implicitlyWait(4, TimeUnit.SECONDS); if (driver.getPageSource().contains("You are NOT authorized to access Site")) { System.out.println("You are NOT authorized to access Site error message is displayed"); driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS); driver.navigate().to("http://e1.dev.assetnation.com"); SIGNIN(driver, fieldText, value); } } } catch (Exception e) { e.printStackTrace(); resultDetails.setFlag(false); } }
From source file:com.liferay.blade.sample.test.functional.utils.BladeSampleFunctionalActionUtil.java
License:Apache License
public static void customClick(WebDriver webDriver, WebElement webElement) { Actions action = new Actions(webDriver); Actions actionMoveTo = action.moveToElement(webElement); Action buildActionMoveTo = actionMoveTo.build(); buildActionMoveTo.perform();/*from ww w . j av a2 s .co m*/ WebDriverWait wait = new WebDriverWait(webDriver, 30); WebElement element = wait.until(ExpectedConditions.elementToBeClickable(webElement)); element.click(); }
From source file:com.liferay.blade.sample.test.functional.utils.BladeSampleFunctionalActionUtil.java
License:Apache License
public static boolean isClickable(WebDriver webDriver, WebElement webelement) { WebDriverWait webDriverWait = new WebDriverWait(webDriver, 30); try {/*w w w . ja v a 2s . co m*/ webDriverWait.until(ExpectedConditions.elementToBeClickable(webelement)); return true; } catch (org.openqa.selenium.TimeoutException te) { return false; } }
From source file:com.mkl.websuites.internal.command.impl.wait.WaitUntilClickableCommand.java
License:Apache License
@Override protected void doOperationOnElement(WebElement elem) { WebDriverWait wait = new WebDriverWait(browser, getWebElementWaitTimeout()); wait.until(ExpectedConditions.elementToBeClickable(elem)); }
From source file:com.moodle.testmanager.pageObjectModel.FormAddEditSettingsFileManager.java
License:GNU General Public License
/** * Clicks the Create folder button in the dialog launched when creating a new folder. *//*from ww w.java 2 s. c o m*/ public void clickCreateFolderButton() { fileManager.fileManButton(locCreateFolder); WebDriverWait wait = new WebDriverWait(driver, 10); @SuppressWarnings("unused") WebElement element = wait .until(ExpectedConditions.elementToBeClickable(By.xpath(".//*[@class='fp-thumbnail']"))); }
From source file:com.moodle.testmanager.pageObjectModel.FormAddEditSettingsFileManager.java
License:GNU General Public License
/** * Clicks the Cancel button in the dialog launched when creating a new folder. *//*from www .j a v a2s. c o m*/ public void clickCancelFolderButton() { fileManager.fileManButton(locCancelFolder); WebDriverWait wait = new WebDriverWait(driver, 10); @SuppressWarnings("unused") WebElement element = wait .until(ExpectedConditions.elementToBeClickable(By.xpath(".//*[@class='fp-thumbnail']"))); }
From source file:com.nabla.project.fronter.selenium.tests.pageobjects.RollsPage.java
License:Open Source License
@And("he Submits request for score calculation") public void He_submits_request_for_score() { final WebDriverWait wait = new WebDriverWait(SeleniumHelper.getDriver(), 10); wait.until(ExpectedConditions.elementToBeClickable(By.name("rolls_form:score"))); SeleniumHelper.getDriver().manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS); this.calculate.click(); }
From source file:com.nabla.project.fronter.selenium.tests.SimpleWebDriverSTest.java
License:Open Source License
public void testWithWrongInputS() throws Exception { // Get the StopWatch Object and start the StopWatch final StopWatch pageLoad = new StopWatch(); pageLoad.start();/*from w w w .ja va 2 s . co m*/ // Create an instance of Loan Page class // and provide the driver final RollsPage loanPage = new RollsPage(/* SeleniumHelper.getDriver() */); // Open the Loan Calculator Page loanPage.get(); loanPage.He_enters_rolls("ABC"); // wait for the application to get fully loaded /* * final WebElement findOwnerLink = (new WebDriverWait(SeleniumHelper.getDriver(), 5)).until(new ExpectedCondition<WebElement>() * { * @Override * public WebElement apply(final WebDriver d) * { * // d.get(baseUrl); * return d.findElement(By.name("loan_form:paybackTime")); * } * }); * findOwnerLink.click(); */ final WebDriverWait wait = new WebDriverWait(SeleniumHelper.getDriver(), 10); wait.until(ExpectedConditions.elementToBeClickable(By.name("rolls_form:score"))); SeleniumHelper.getDriver().manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS); SeleniumHelper.getDriver().findElement(By.name("rolls_form:score")).click(); loanPage.Ensure_a_transaction_failure_message(2, "Please enter the amount of your loan. Ex. 200000: Validation Error: Specified attribute is not between the expected values of 1 and 1,000,000,000."); loanPage.Ensure_a_transaction_failure_message(3, "Please enter the number of years you have to pay back your loan. Ex. 30: Validation Error: Specified attribute is not between the expected values of 1 and 120."); SeleniumHelper.testTakesScreenshot("testWithWrongInputS.png", SeleniumHelper.getDriver()); // Thread.sleep(1000); SeleniumHelper.getSelenium().open("/fronter/"); SeleniumHelper.getSelenium().waitForPageToLoad("1500"); }
From source file:com.nabla.project.visma.selenium.tests.pageobjects.LoanPage.java
License:Open Source License
@And("he Submits request for Payment's Schedule") public void He_submits_request_for_fund_transfer() throws InterruptedException { final WebDriverWait wait = new WebDriverWait(SeleniumHelper.getDriver(), 10); wait.until(ExpectedConditions.elementToBeClickable(By.name("loan_form:payment"))); SeleniumHelper.getDriver().manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS); this.calculate.click(); SeleniumHelper.getSelenium().waitForPageToLoad(SeleniumHelper.PAGE_TO_LOAD_TIMEOUT); // SeleniumHelper.getDriver().findElement(By.name("loan_form:payment")).click(); // Thread.sleep(10000); // 10 s }
From source file:com.partnet.automation.HtmlView.java
License:Apache License
/** * Waits for element to be visible (in view area of browser) and able to be * clickable (by a user)./*from ww w . j a v a 2 s. co m*/ * <p> * Returns the <code>WebElement</code> of interest. * <p> * See also * {@link com.partnet.automation.HtmlView#waitForElementToBeClickable(WebElement, int)}. * * @param by locator of element wanting to click * @param maxWaitInSeconds max seconds to wait for the element to become clickable * @return WebElement */ protected WebElement waitForElementToBeClickable(By by, int maxWaitInSeconds) { return (new WebDriverWait(webDriver, maxWaitInSeconds)).until(ExpectedConditions.elementToBeClickable(by)); }