0

If I am inside a inner frame and there is button if I click on that button a new window will open. Will it be possible to switch to newly open window doing driver.switchTo().defaultContent(). ?

  • yes,you need to directly switch at child window. – Upkar Singh May 1 '19 at 14:48
1

You do not need to switch between frames, you do however, need to switch between windows.

for(String winHandle : driver.getWindowHandles()){ 
driver.switchTo().window(winHandle);     
 } 
| improve this answer | |
0
public class IndexOfIframe {
public static void main(String[] args) {
        WebDriver driver = new FirefoxDriver();
// I used http://demo.guru99.com/test/guru99home/
        driver.get("http://yourwebsite.com");  
        driver.manage().window().maximize();
        //driver.manage().timeouts().implicitlyWait(100, TimeUnit.SECONDS);
        int size = driver.findElements(By.tagName("iframe")).size();

        for(int i=0; i<=size; i++){
        driver.switchTo().frame(i);
        int total=driver.findElements(By.xpath("html/body/a/img")).size();
        System.out.println(total);
        driver.switchTo().defaultContent();}}}
| improve this answer | |
  • Why don't you add some explanations on what the code is doing so it is more useful for anyone that might read it? – Mate Mrše May 28 at 11:30
  • yes it make seance – kuldeep chhipa May 30 at 12:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.