List of usage examples for org.openqa.selenium.support.ui WebDriverWait WebDriverWait
public WebDriverWait(WebDriver driver, Duration timeout)
From source file:com.denimgroup.threadfix.selenium.pages.BasePage.java
License:Mozilla Public License
protected void handleAlert() { sleep(3000);/*from w w w . ja v a2s. c om*/ WebDriverWait wait = new WebDriverWait(driver, 10); wait.until(ExpectedConditions.alertIsPresent()); Alert alert = driver.switchTo().alert(); alert.accept(); sleep(200); // sleep(1000); }
From source file:com.denimgroup.threadfix.selenium.pages.BasePage.java
License:Mozilla Public License
public void waitForElement(WebElement e) { WebDriverWait wait = new WebDriverWait(driver, 20); wait.until(ExpectedConditions.visibilityOf(e)); }
From source file:com.denimgroup.threadfix.selenium.pages.BasePage.java
License:Mozilla Public License
public void waitForInvisibleElement(WebElement e) { WebDriverWait wait = new WebDriverWait(driver, 10); wait.until(ExpectedConditions.invisibilityOfElementLocated(By.id(e.getAttribute("id")))); }
From source file:com.dhenton9000.selenium.generic.WaitMethods.java
public void waitForExpectedElement(int timeInSeconds, SELECTOR_CHOICE selectorChoice, String selectorValue) { WebDriverWait wait = new WebDriverWait(driver, timeInSeconds); By selectionBy = generateSelectorBy(selectorChoice, selectorValue); wait.until(ExpectedConditions.visibilityOfElementLocated(selectionBy)); }
From source file:com.dhenton9000.selenium.generic.WaitMethods.java
public void waitForExpectedPage(int timeInSeconds, String pageTitle) { WebDriverWait wait = new WebDriverWait(driver, timeInSeconds); wait.until(ExpectedConditions.titleContains(pageTitle)); }
From source file:com.dhenton9000.selenium.generic.WaitMethods.java
public void waitForElementToBeClickable(int timeInSeconds, SELECTOR_CHOICE selectorChoice, String selectorValue) {//from www. j a v a2 s. c o m WebDriverWait wait = new WebDriverWait(driver, timeInSeconds); By selectionBy = generateSelectorBy(selectorChoice, selectorValue); wait.until(ExpectedConditions.elementToBeClickable(selectionBy)); }
From source file:com.digi.selenium.util.BillNReload.Bill_n_Reload_Prepaid_Broadband_Util.java
protected void targetFinalAmt() { try {// ww w. j a v a2s .co m //*[@id='content']/div/div/div[1]/div[9]/div[2]/strong WebDriverWait wait = new WebDriverWait(getDriver(), 20); wait.until(ExpectedConditions.visibilityOfElementLocated( By.xpath("//*[@id='content']/div/div/div[1]/div[9]/div[2]/strong"))); WebElement amt = getDriver() .findElement(By.xpath("//*[@id='content']/div/div/div[1]/div[9]/div[2]/strong")); finalamt = amt.getText(); } catch (Exception e) { log.error("Fail : To validate the targetAir time amount on Payment Page"); } }
From source file:com.digi.selenium.util.BillNReload.Bill_n_Reload_Prepaid_Broadband_Util.java
protected void clickOnRadioRM50() { boolean breakIt; while (true) { breakIt = true;//from www . j a v a 2s . co m try { // Put email id on text field as it can not be blank //*[@id="reloadForm__email"] WebElement emailtxt = getDriver().findElement(By.id("reloadForm__email")); System.out.println(emailtxt.isEnabled()); if (emailtxt.isEnabled()) { handleInputField_ByID("reloadForm__email", AppConstants.EMAIL); Thread.sleep(500); } JavascriptExecutor js1 = (JavascriptExecutor) getDriver(); //js1.executeScript("window.scrollBy(0,400)", ""); //*[@id="prepaidReloadForm"]/ul/li[2]/label/div WebElement radio = getDriver() .findElement(By.xpath("//*[@id='prepaidReloadForm']/ul/li[4]/label/div")); radio.click(); // now select check box to accept license agreement WebElement checkbox = getDriver().findElement(By.xpath("//*[@id='prepaidReloadForm']/label/div")); checkbox.click(); // click on proceed button after selecting radio button and check box // WebElement elementproceed=getDriver().findElement(By.xpath("//*[@id='proceedBtn']")); //*[@id="proceedBtn"] WebElement proceed = (new WebDriverWait(getDriver(), 1000)) .until(ExpectedConditions.elementToBeClickable(By.xpath("//*[@id='proceedBtn']"))); proceed.click(); waitForPageLoad(100); Thread.sleep(500); JavascriptExecutor js = (JavascriptExecutor) getDriver(); js.executeScript("window.scrollBy(0,500)", ""); } catch (Exception e) { System.out.println(e); breakIt = false; e.printStackTrace(); log.error("Fail : Failed to Reload amount."); System.exit(0); } if (breakIt) { break; } } //while ends }
From source file:com.digi.selenium.util.BillNReload.Bill_n_Reload_Prepaid_Broadband_Util.java
protected void targetYAxisData(int index) { JavascriptExecutor jse = (JavascriptExecutor) getDriver(); jse.executeScript("window.scrollBy(0,-800)", ""); getWebElement_By_xpath("//*[@id='content']/div[9]/div[1]/div[2]/ul/li[" + index + "]/a").click(); Wait<WebDriver> wait = new WebDriverWait(getDriver(), 30); if (index == 1) jse.executeScript("window.scrollBy(0,210)", ""); wait.until(ExpectedConditions//from w w w .j a v a 2 s .c om .visibilityOfElementLocated(By.xpath("//*[name()='svg']/*[name()='g'][13]/*[name()='g'][2]"))); //Working :get the stroke attribute to get the color value of graph getDriver().manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS); boolean breakIt = true; //Get the BillCycle Elements String yaxisrootNodeXpath = "//*[name()='svg']/*[name()='g'][13]/*[name()='g'][2]"; WebElement yaxisrootElement = getDriver().findElement(By.xpath(yaxisrootNodeXpath)); String yaxischildXpath = "./*[name()='text']"; listyaxischild = yaxisrootElement.findElements(By.xpath(yaxischildXpath)); int eleListSize = listyaxischild.size(); // String targetrootdatapath= "//*[@id='content']/div[9]/div[1]/div[1]/div[2]/div/div/svg/g[13]/g[2]"; if (index == 1) System.out.println("===========30 Days Y-AxisData========"); else { if (index == 2) System.out.println("===========60 Days Y-AxisData========"); else System.out.println("===========90 Days Y-AxisData========"); } }
From source file:com.digi.selenium.util.BillNReload.Bill_n_Reload_Prepaid_Broadband_Util.java
protected void targetTableData() { Wait<WebDriver> waittable = new WebDriverWait(getDriver(), 30); JavascriptExecutor jse = (JavascriptExecutor) getDriver(); //if(index>0) jse.executeScript("window.scrollBy(0,-800)", ""); getWebElement_By_xpath("//*[@id='content']/div[9]/div[1]/div[2]/ul/li[1]").click(); jse.executeScript("window.scrollBy(0,800)", ""); waittable.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//*[@id='details-table']"))); WebElement headertable = getDriver().findElement(By.xpath("//*[@id='details-table']")); List<WebElement> header = headertable.findElements(By.xpath("//*[@id='billhistory']/tr")); System.out.println("===========Table Data========"); // And iterate over them, getting the header data for (WebElement node : header) { List<WebElement> cells = node.findElements(By.tagName("th")); for (WebElement cell : cells) headerlist.add(cell.getText()); }//from w w w. j a v a 2 s . c o m // Now get all the TR elements from the table WebElement table = getDriver().findElement(By.xpath("//*[@id='details-table']/tbody")); List<WebElement> rows = table.findElements(By.tagName("tr")); // And iterate over them, getting the cells for (WebElement row : rows) { List<WebElement> rowcells = row.findElements(By.tagName("td")); for (WebElement cell : rowcells) tabledatalist.add(cell.getText()); } }