Android apps to use in appium android test examples

Breaking

Tuesday, March 13, 2018

How to await for chemical gene to last clickable inward selenium webdriver using explicit wait

In my previous post, We convey seen how to expect implicitly inwards selenium webdriver software testing tool. Let me remind yous ane affair is implicit expect volition live on applied to all elements of evidence instance past times default while explicit volition live on applied to targeted chemical cistron only. This is the difference betwixt implicit expect together with explicit wait. Still I am suggesting you to purpose implicit expect inwards your evidence script.

If yous knows, In selenium IDE software testing tool nosotros tin privy purpose "waitForElementPresent" or "verifyElementPresent" to expect for or verify that chemical cistron is introduce or non on software spider web application page. In selenium webdriver, nosotros tin privy create same affair using explicit expect of elementToBeClickable(By locator). Full syntax is every bit bellow.

Read to a greater extent than tutorials on selenium WebDriver @Tutorials Part 1 and @Tutorials Part 2.

WebDriverWait expect = novel WebDriverWait(driver, 15); wait.until(ExpectedConditions.elementToBeClickable(By.cssSelector("#submitButton")));

Here higher upwards syntax volition expect till fifteen seconds to give-up the ghost targeted element(#submitButton) clickable if it is non clickable or non loaded on the page of software spider web application. As before long every bit targeted chemical cistron becomes clickable on the page of software spider web application, webdriver volition give-up the ghost for perform adjacent action. You tin privy increase or decrease webdriver expect fourth dimension from 15.

Let me arrive at yous practical instance for the element to live on clickable.
package junitreportpackage;  import java.util.concurrent.TimeUnit; import java.io.FileInputStream; import java.io.IOException; import jxl.Sheet; import jxl.Workbook; import jxl.read.biff.BiffException; import org.junit.After; import org.junit.Before; import org.junit.Test; import org.openqa.selenium.By; import org.openqa.selenium.JavascriptExecutor; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.firefox.FirefoxDriver; import org.openqa.selenium.support.ui.ExpectedConditions; import org.openqa.selenium.support.ui.Select; import org.openqa.selenium.support.ui.WebDriverWait;   populace degree Mytest1 {  WebDriver driver = novel FirefoxDriver();    @Before  populace void beforetest() {   driver.manage().window().maximize();   driver.get(" ");   driver.manage().timeouts().implicitlyWait(15, TimeUnit.SECONDS);  }    @After  populace void aftertest() {   driver.quit();     }    @Test   populace void evidence ()     {            driver.findElement(By.xpath("//input[@name='fname']")).sendKeys("My Name");     //Wait for chemical cistron to live on clickable     WebDriverWait expect = novel WebDriverWait(driver, 15);     wait.until(ExpectedConditions.elementToBeClickable(By.cssSelector("#submitButton")));      driver.findElement(By.cssSelector("#submitButton")).click();    }  populace void HighlightMyElement(WebElement element) {    for (int i = 0; i < 10; i++)    {     JavascriptExecutor javascript = (JavascriptExecutor) driver;    javascript.executeScript("arguments[0].setAttribute('style', arguments[1]);", element, "color: orange; border: 4px venture orange;");    javascript.executeScript("arguments[0].setAttribute('style', arguments[1]);", element, "color: pink; border: 4px venture pink;");    javascript.executeScript("arguments[0].setAttribute('style', arguments[1]);", element, "color: yellow; border: 4px venture yellow;");    javascript.executeScript("arguments[0].setAttribute('style', arguments[1]);", element, "");     }    }   }

Run higher upwards given instance of expect for chemical cistron to live on clickable inwards selenium webdriver inwards your eclipse amongst junit. Click hither to persuasion dissimilar posts on how to purpose junit amongst eclipse for your webdriver test.
More interesting articles here :Generation Enggelmundus Internet Marketing Tool here :Zeageat IM http://www.software-testing-tutorials-automation.com/

No comments:

Post a Comment