Search
 
 

Display results as :
 


Rechercher Advanced Search

Latest topics
Navigation
 Portal
 Index
 Memberlist
 Profile
 FAQ
 Search

wait for input element to be populated from database value?

View previous topic View next topic Go down

wait for input element to be populated from database value?

Post by stefaca on Wed Feb 05, 2014 9:54 pm

I have a problem with adding pause for some steps. here is a problem: I have input form in which I input some value. in a few next forms data must be located in database and autopopulated. after that auto populated step I can continue with my test. here is what I did but with no success. locate first form which must be populated with database values pt1:r1:1:pt1:it8::content, try to get value. if there is value print (just for my print), if no value auto inputed from database I'm trying to make pause but no pause is apearing


Code:
WebElement we = driver.findElement(By.id("pt1:r1:1:pt1:it8::content"));
        String ime = we.getAttribute("value");
       
        if (ime != null && !ime.isEmpty()) {
            System.out.println("Popunjen podatak! Ime: " + ime);
        } else {
            Boolean pause = false;
            String temp = we.getAttribute("value");
            System.out.println("Ime u ličnim podacima :" + temp);
            pause = (new WebDriverWait(driver, 5)).until(ExpectedConditions.textToBePresentInElement(we, ""));
            if (pause){
                System.out.println("PAUZA!");
            } else {
                throw new Exception("Nisu povučeni podaci iz baze!");
            }
        }

stefaca

Posts : 2
Join date : 2014-02-05

Back to top Go down

Re: wait for input element to be populated from database value?

Post by stefaca on Thu Feb 20, 2014 6:11 pm

solution:

Code:
WebDriverWait wdw = new WebDriverWait(driver, 5);
 ExpectedCondition<Boolean> ec = new ExpectedCondition<Boolean>() {
 
@Override
 public Boolean apply(WebDriver wd) {
 WebElement result = wd.findElement(By.id("pt1:r1:1:pt1:it8::content"));
// da vrati kada se ime dovuce
 return !result.getAttribute("value").isEmpty();
 }
 };
 wdw.until(ec);

stefaca

Posts : 2
Join date : 2014-02-05

Back to top Go down

View previous topic View next topic Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum