0

I've got a page like below and I 'm trying to identify the element DivToFind using selenium. But, as they are inside a frame and then inside another html, i'm unable to find it.

I 've tried below.

SwitchTo().frame() - Did not work
Window handler swapping - there is only one window handler

Any suggestions please?

<html>
<head>
<body unselectable="off">
<div ..... >
<iframe src="/something.jsp" name="FrameBox">
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<body>
<div id="DivToFind">
........

</div>
</body>
</head>
</html>
</iframe>

</div>
</body>
</head>
</html>
atish shimpi
  • 4,873
  • 2
  • 32
  • 50
  • The frame switching happend successfully but then, the code is unable to identify the 'DivToFind' element. Any thoughts please? `driver.switchTo().frame(driver.findElement(By.xpath("//iframe[contains(@name,'FrameBox')]"))); System.out.println("switched"); driver.findElement(By.id("DivToFind")); System.out.println("Found");` – Matheswaran Kanagarajan Dec 02 '14 at 15:30
  • One more point. Even though switchTo().frame() is successful, as there is another starts, the code is unable to identify the elements inside. – Matheswaran Kanagarajan Dec 02 '14 at 15:36
  • hi Rupesh, So, I gave below lines and it went through successfully ('found' was printed). I got some error using assertTrue and thus didn't use that. driver.getPageSource().contains("DivToFind"); System.out.println("Found"); But, when I use inspect element in firefox, I don't see anything inside. It is like this. – Matheswaran Kanagarajan Dec 02 '14 at 15:41
  • In this case Just seeing HTML will not work. The element which you are try to locate where it is present in i.e like alert, Window,etc. Can you show complete implementation in that case. Or will be more easy if the site you are trying to automate is publicly available. – Rupesh Shinde Dec 02 '14 at 15:58
  • hope fully this should answer your question http://stackoverflow.com/a/9960432/1520443 – deepak Dec 02 '14 at 17:01
  • Hi Rupesh, the code in the actual post is the same html code that im trying to automate.. Just a html created in my local drive. – Matheswaran Kanagarajan Dec 02 '14 at 17:29
  • Hi Deepak, that did not work. Still unable to identify the element – Matheswaran Kanagarajan Dec 02 '14 at 18:24

0 Answers0