List of usage examples for org.openqa.selenium.support.ui ExpectedConditions elementToBeClickable
public static ExpectedCondition<WebElement> elementToBeClickable(final WebElement element)
From source file:test.nov21.configuration.AbstractPage.java
License:Open Source License
public WebElement waitForElementToBeClickable(final WebElement element) { Wait<WebDriver> wait = new WebDriverWait(getDriver(), DRIVER_WAIT_TIME, 100); wait.until(ExpectedConditions.elementToBeClickable(element)); return element; }
From source file:test.nov21.configuration.AbstractPage.java
License:Open Source License
public void waitForElementToBeClickable(final By by) { Wait<WebDriver> wait = new WebDriverWait(getDriver(), DRIVER_WAIT_TIME, 100); wait.until(ExpectedConditions.elementToBeClickable(waitAndFindElement(by))); }
From source file:testrunner.elements.LocateUsing.java
License:Apache License
/** * This method takes the responsibility of locating a web element using the * following Order/*w ww. j a v a 2 s . c o m*/ * <ul> * <li>{@link #getId()} The ID of the element specified if its NOT null</li> * <li>{@link #getXPath()} The XPath of the element specified if its NOT * null</li> * <li>{@link #getCSSSelector()} The CSS Selector text of the element * specified if its NOT null</li> * </ul> * * @return WebElement - Located WebElement or Null */ public WebElement locate(WebDriver driver, int waitFor) { WebElement elementToLocate = null; try { if (getId() != null && !getId().trim().equals("")) { if (waitFor > 0) { WebDriverWait wait = new WebDriverWait(driver, waitFor); elementToLocate = wait.until(ExpectedConditions.elementToBeClickable(By.id(getId()))); } else { elementToLocate = driver.findElement(By.id(getId())); } } if (elementToLocate == null && (getxPath() != null && !getxPath().getPath().trim().equals(""))) { if (waitFor > 0) { WebDriverWait wait = new WebDriverWait(driver, waitFor); elementToLocate = wait.until( ExpectedConditions.elementToBeClickable(By.xpath(this.getxPath().getPath().trim()))); } else { elementToLocate = driver.findElement(By.xpath(this.getxPath().getPath().trim())); } } if (elementToLocate == null && (getCssSelector() != null && !getCssSelector().getSelectorText().trim().equals(""))) { if (waitFor > 0) { WebDriverWait wait = new WebDriverWait(driver, waitFor); elementToLocate = wait.until(ExpectedConditions .elementToBeClickable(By.cssSelector(this.getCssSelector().getSelectorText().trim()))); } else { elementToLocate = driver .findElement(By.cssSelector(this.getCssSelector().getSelectorText().trim())); } } } catch (Exception ex) { System.out.println("Unable to Locate Element with ID" + getId() + " OR XPATH" + this.getxPath() + " OR CSS Selector" + cssSelector); } return elementToLocate; }
From source file:TestSuite1.TestCase1.java
@Test public void test() throws InterruptedException { System.out.println("Test Start"); WebDriverWait wait = new WebDriverWait(driver, 10); int WindowsY = 752; int y;//from w w w. j a v a 2 s .c o m int x1; int y1; int start; int starty; int end; int endy; final int maxcount = 20; int count = maxcount; WebElement element = null; start = driver.findElement(By.xpath( "//android.widget.LinearLayout[1]/android.widget.FrameLayout[1]/android.support.v4.widget.DrawerLayout[1]/android.widget.FrameLayout[1]/android.widget.LinearLayout[1]/android.widget.FrameLayout[1]/android.support.v4.view.ViewPager[1]/android.widget.RelativeLayout[1]/android.view.View[1]/android.widget.ListView[1]/android.widget.LinearLayout[3]")) .getLocation().getY(); System.out.println(start); starty = driver.findElement(By.xpath( "//android.widget.LinearLayout[1]/android.widget.FrameLayout[1]/android.support.v4.widget.DrawerLayout[1]/android.widget.FrameLayout[1]/android.widget.LinearLayout[1]/android.widget.FrameLayout[1]/android.support.v4.view.ViewPager[1]/android.widget.RelativeLayout[1]/android.view.View[1]/android.widget.ListView[1]/android.widget.LinearLayout[3]")) .getSize().getHeight(); System.out.println(starty); end = driver.findElement( By.className("android.widget.LinearLayout").id("com.skmc.okcashbag.home_google:id/main_header")) .getLocation().getY(); System.out.println(end); endy = driver.findElement( By.className("android.widget.LinearLayout").id("com.skmc.okcashbag.home_google:id/main_header")) .getSize().getHeight(); System.out.println(endy); y = start + starty; x1 = WindowsY / 2; y1 = end + endy; while (count > 0) { try { Thread.sleep(1000); element = driver.findElement( By.className("android.widget.TextView").name("SK()?")); break; } catch (NoSuchElementException nsee) { System.out.println(" ? . scroll ."); } catch (InterruptedException e) { } try { Thread.sleep(1000); } catch (InterruptedException e) { } driver.swipe(x1, y, x1, y1, 6000); count--; } System.out.println("? " + element.getText()); Thread.sleep(5000); assertEquals(element.getText(), "SK()?"); // driver.findElement(By.className("android.widget.LinearLayout").id("com.skmc.okcashbag.home_google:id/summary")).click(); // element.click(); int ey = element.getLocation().getY(); int ex = element.getLocation().getX(); int eh = element.getSize().getHeight(); int ew = element.getSize().getWidth(); Thread.sleep(2000); // WebElement ee = // driver.findElement(By.xpath("//android.widget.LinearLayout[1]/android.widget.FrameLayout[1]/android.support.v4.widget.DrawerLayout[1]/android.widget.FrameLayout[1]/android.widget.LinearLayout[1]/android.widget.FrameLayout[1]/android.support.v4.view.ViewPager[1]/android.widget.RelativeLayout[1]/android.widget.RelativeLayout[1]/android.widget.RelativeLayout[1]")); WebElement ee = driver .findElement(By.className("android.view.View").id("com.skmc.okcashbag.home_google:id/empty_view")); int TestY = (ee.getLocation().getY() - ee.getSize().getHeight()); System.out.println(ee.getLocation().getY() - ee.getSize().getHeight()); System.out.println(ee.getLocation().getX()); System.out.println(ee.getSize().getHeight()); System.out.println(ee.getSize().getWidth()); System.out.println(" " + TestY); System.out.println(ey); System.out.println(ex); System.out.println(eh); System.out.println(ew); driver.tap(1, ex + (ew / 2), TestY + 10, 500); // driver.findElement(By.xpath("//android.widget.LinearLayout[1]/android.widget.FrameLayout[1]/android.support.v4.widget.DrawerLayout[1]/android.widget.FrameLayout[1]/android.widget.LinearLayout[1]/android.widget.FrameLayout[1]/android.support.v4.view.ViewPager[1]/android.widget.RelativeLayout[1]/android.widget.RelativeLayout[1]/android.widget.RelativeLayout[1]")).click(); /** * ? ? ? ? ?? ? / ? / ? ? ? * ture */ String[] Result = { "", "? ?? 264 The Planet", "1599-0512", "104-86-36968", "2014--0036", "?", "?", "? ?" }; WebElement Bizceo = driver.findElement( By.className("android.widget.TextView").id("com.skmc.okcashbag.home_google:id/biz_ceo")); WebElement Addres = driver.findElement( By.className("android.widget.TextView").id("com.skmc.okcashbag.home_google:id/biz_address")); WebElement Bizcall = driver.findElement( By.className("android.widget.TextView").id("com.skmc.okcashbag.home_google:id/biz_call")); WebElement Bizlicense = driver.findElement( By.className("android.widget.TextView").id("com.skmc.okcashbag.home_google:id/biz_license")); WebElement Bizsalereport = driver.findElement( By.className("android.widget.TextView").id("com.skmc.okcashbag.home_google:id/biz_sale_report")); WebElement Bizuseagreement = driver.findElement( By.className("android.widget.TextView").id("com.skmc.okcashbag.home_google:id/biz_use_agreement")); WebElement Bizprivacy = driver.findElement( By.className("android.widget.TextView").id("com.skmc.okcashbag.home_google:id/biz_privacy")); WebElement Bizinfom = driver.findElement( By.className("android.widget.TextView").id("com.skmc.okcashbag.home_google:id/biz_infom")); assertEquals(Bizceo.getText(), Result[0].toString()); assertEquals(Addres.getText(), Result[1].toString()); assertEquals(Bizcall.getText(), Result[2].toString()); assertEquals(Bizlicense.getText(), Result[3].toString()); assertEquals(Bizsalereport.getText(), Result[4].toString()); assertEquals(Bizuseagreement.getText(), Result[5].toString()); assertEquals(Bizprivacy.getText(), Result[6].toString()); assertEquals(Bizinfom.getText(), Result[7].toString()); /** * ? ?? / ? / ? ? ? ?? ?? ? */ /** * ? ? */ Bizuseagreement.click(); WebElement Title = driver.findElement( By.className("android.widget.TextView").id("com.skmc.okcashbag.home_google:id/title_txt")); assertEquals(Title.getText(), "OK? ?"); wait.until(ExpectedConditions.elementToBeClickable( By.className("android.widget.ImageView").id("com.skmc.okcashbag.home_google:id/back_btn"))); driver.findElement( By.className("android.widget.ImageView").id("com.skmc.okcashbag.home_google:id/back_btn")).click(); /* * ? ?? ? ? */ driver.tap(1, ex + (ew / 2), TestY + 10, 500); wait.until(ExpectedConditions.elementToBeClickable( By.className("android.widget.TextView").id("com.skmc.okcashbag.home_google:id/biz_privacy"))); driver.findElement( By.className("android.widget.TextView").id("com.skmc.okcashbag.home_google:id/biz_privacy")) .click(); // Bizprivacy.click(); Title = driver.findElement( By.className("android.widget.TextView").id("com.skmc.okcashbag.home_google:id/title_txt")); assertEquals(Title.getText(), "? "); wait.until(ExpectedConditions.elementToBeClickable( By.className("android.widget.ImageView").id("com.skmc.okcashbag.home_google:id/back_btn"))); driver.findElement( By.className("android.widget.ImageView").id("com.skmc.okcashbag.home_google:id/back_btn")).click(); /* * ? ?? ? ?(? ) ? ? */ driver.tap(1, ex + (ew / 2), TestY + 10, 500); wait.until(ExpectedConditions.elementToBeClickable( By.className("android.widget.TextView").id("com.skmc.okcashbag.home_google:id/biz_infom"))); Bizinfom.click(); WebElement url = driver .findElement(By.className("android.widget.EditText").id("com.android.chrome:id/url_bar")); System.out.println(url.getText()); Boolean UrlEquals = url.getText().contains("www.ftc.go.kr"); assertTrue(UrlEquals); driver.navigate().back(); /** *? ? ?? ? */ driver.findElement(By.className("android.widget.ImageView") .id("com.skmc.okcashbag.home_google:id/eventbanner_message")).click(); HashMap<String, String> scrollObject = new HashMap<String, String>(); RemoteWebElement element1 = (RemoteWebElement) ((AndroidDriver) driver) .findElementByAndroidUIAutomator("new UiSelector().className(\"android.widget.ListView\")"); JavascriptExecutor js = (JavascriptExecutor) driver; String webElementId = ((RemoteWebElement) element).getId(); scrollObject.put("text", "OK? ? 16.01.26~16.04.30 ??"); scrollObject.put("element", webElementId); js.executeScript("mobile: scrollTo", scrollObject); }
From source file:ui_Layer.LicencesPage.java
public void searchLicences(String searchValue) { wait.until(ExpectedConditions.elementToBeClickable(openSearchOption)); openSearchOption.click();// www. j ava2s . c o m wait.until(ExpectedConditions.visibilityOf(searchFiled)).sendKeys(searchValue); waitSleep(500); }
From source file:UI_Manipulation.SeleniumUtils.java
public void WaitForElementToBeClickableBySelector(By by) { WebDriverWait wait = new WebDriverWait(driver, 30); wait.until(ExpectedConditions.elementToBeClickable(by)); }
From source file:UI_Manipulation.SeleniumUtils.java
public void WaitForElementToBeClickableByWebElement(WebElement webElement) { WebDriverWait wait = new WebDriverWait(driver, 30); wait.until(ExpectedConditions.elementToBeClickable(webElement)); }
From source file:utils.WebDriverUtils.java
public static boolean isClickable(WebDriver webDriver, String xpath, long timeout) { WebDriverWait wait = new WebDriverWait(webDriver, timeout); try {/* ww w. j a v a 2 s . co m*/ wait.until(ExpectedConditions.elementToBeClickable(By.xpath(xpath))); } catch (TimeoutException e) { return false; } return true; }
From source file:xbdd.report.ReportManager.java
License:Apache License
/** * Open a openScenario from a report//from www.j a v a 2s . c om * * @param reportContext The context of the report * @param feature The name of the feature * @param scenarioPathParam The part of scenario id * @param scenarioName The name of the scenario * * @return the summary of the scenario */ public ScenarioSummary openScenario(final ReportContext reportContext, final String feature, final String scenarioPathParam) { openFeature(reportContext, feature); final String id = feature + "\\;" + scenarioPathParam; new WebDriverWait(this.webDriver, 20) .until(ExpectedConditions.elementToBeClickable(By.cssSelector("#" + id + " .scenario-name"))) .click(); return new WebDriverWait(this.webDriver, 20).until(new Function<WebDriver, ScenarioSummary>() { @Override public ScenarioSummary apply(final WebDriver driver) { return WEB_ELEMENT_SCENARIO_SUMMARY.apply(driver.findElement(By.cssSelector("#" + id))); } }); }
From source file:xbdd.stepdefs.AccessStepdefs.java
License:Apache License
@Then("^the user can make ajax requests$") public void the_user_can_make_ajax_requests() { this.webDriver.switchTo().defaultContent(); if (this.webDriver instanceof JavascriptExecutor) { ((JavascriptExecutor) this.webDriver).executeScript( "YUI().use('node', 'statusHelpers','io-base', 'session-timeout', 'handlebars', 'xbdd', function(Y) { Y.io(Y.statusHelpers.getContext(), { method: 'GET', on: { success: function() { document.body.innerHTML = '<span id=testspanresult>TEST SUCCESS</span>'; } } }); });"); }/*from w w w . j a v a 2s . c om*/ new WebDriverWait(this.webDriver, 10) .until(ExpectedConditions.elementToBeClickable(By.cssSelector("#testspanresult"))); }