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

webdriver timeouts


webdriver timeouts:

driver.get("http://www.gmail.com");

//timeouts will wait for the elemnt to load
// suppose  we give 5 sec, 5 sec is max time it waits and throws error then, if it ready in 3 sec, it will continue
//pageloading time- for the next page to load
driver.manage().timeouts().implicitlyWait(5,TimeUnit.SECONDS);
driver.manage().timeouts().pageLoadTimeout(10, TimeUnit.SECONDS);
WebElement table= driver.findElement(By.xpath("//*[@id='Passwd']")).sendKeys(keysToSend);;



Frames:

like  apage inside a page..

tag name iframe
there will be multiple iframes in a page- o ask developer about iframe
go to page source, find the link name and made own xpath

to switch frame

driver.switchTo().frame(1)  //control to 1 st frame

to find no.of frames in a web page, 
driver.findelement by tagname(iframe).size();

WebDriver driver= new FirefoxDriver();

driver.get("http://www.timesofindia.com");
System.out.println(driver.findElements(By.tagName("iframe")).size());//no.of frames in a page
//switch to frame
driver.switchTo().frame("liveScores");//get it from page source
//once move to the required frame, then click on url
//to kniw, if it is frame or not, right clcik on it and will see the option frame
driver.findElement(By.xpath("ccc"));


Frame inside Frame:

driver.get("http://www.borro.com");
driver.findElement(By.xpath("kkjkj")).click();
Thread.sleep(1000L);
//ligbox loaded
List<WebElement> frames= driver.findElements(By.tagName("iframe"));
System.out.println(frames.size());
System.out.println(frames.get(0).getAttribute("id"));//particular element
System.out.println(frames.get(1).getAttribute("id"));//2nd element

driver.switchTo().frame(1);
driver.findElement(By.xpath("kkjkj")).sendKeys("jj");
}