Pawan Patil
Pawan Patil

Reputation: 1157

Element not found error in Pop up iframe in selenium

I am trying to find input element which is of type file which is present in Pop up Iframe. But whenever I try to find that element it is giving me element not found error. Could somebody help me out in this regard?

Upvotes: 0

Views: 210

Answers (1)

Amit Shukla
Amit Shukla

Reputation: 11

Switch to appropriate iframe and find your element in that frame.

Example ::

//By executing a java script

 JavascriptExecutor exe = (JavascriptExecutor) driver;
 Integer numberOfFrames = Integer.parseInt(exe.executeScript("return window.length").toString());
 System.out.println("Number of iframes on the page are " + numberOfFrames);

 //By finding all the web elements using iframe tag
 List<WebElement> iframeElements = driver.findElements(By.tagName("iframe"));
 System.out.println("The total number of iframes are " + iframeElements.size()); 

Upvotes: 1

Related Questions