"Karmanyevadhikaraste ma phaleshu kadachana, Ma karma phala hetur bhurmatey sangostva akarmani."

WebDriver4

Thread.sleep(4000) - will pause your programme..this will wait for 4000 sec, even though its ready withiin 2 sec we use wait..
 2 types of waits, implicit and Explicit

implicit wait is like global time, when ever the item is ready it will move to next step

driver.manage().timeouts().implicitlyWait(20,TimeUnit.SECONDS);



Explicit is not global-but it is specific to an element-

WebDriverWait wait= new WebDriverWait(driver,20);

//wait for element to present
wait.until(ExpectedConditions.visibilityOfAllElementsLocatedBy(By.xpath("xxxx")));
//wait for element to disappear like loading icons
wait.until(ExpectedConditions.invisibilityOfElementLocated(By.xpath("xxx")));

ExpectedCondition is an interface and ExpectedConditions is class that implements

Suppose for one element i want to wait 10 sec..for other i want 30 secs...we use FluentWait
wait for 30 secs, and if we wont found element dont throw exception, keep continue

new FluentWait<WebDriver>(driver)
       .withTimeout(30, SECONDS)
       .pollingEvery(5, SECONDS)
       .ignoring(NoSuchElementException.class);



SET Interface:
Set s= new HashSet();

list is an interface and array list is class implementing interface List
set has no duplicate elements
List has index and set has no index
no order
sets r used to manage d/f windows in selenium- when we 
click on a link and it opens new page/tab,selenium stores the new windows id a unique value for each in set

u need iterator retrieve an element in set
  

  
 List <String> l= new ArrayList<String>();
  l.add("meeraja");
  l.add("sri");
  l.add("san");
  l.add("kumar");
  System.out.println(l.size());
  System.out.println(l.get(2));
  
// .hasNext() - if next element present it returns true and if not it returns false.
//.next will move to next element
  
  Set<String> s= new HashSet<String>();
  s.add("India");
  s.add("America");
  s.add("london");
  s.add("India");
  s.add("India");
  System.out.println(s.size());
  Iterator<String> iter= s.iterator(); 

//u need iterator retrive element in set, there is no Get function

 System.out.println(iter.hasNext());
 System.out.println(iter.next());//
 System.out.println(iter.hasNext());
  
 while(iter.hasNext()){
 System.out.println(iter.next()); 
 }

TAB function:
//  Firefox profile has feature that the new tab opens as a new window
  //so, try in chrome
System.setProperty("Webdriver.chrome,driver", "c:\\meeraja\\chromedriver.exe");
  
  WebDriver driver= new ChromeDriver();
  driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);