-1

enter image description hereIn this image I want to click view buttons as one by one that view buttons have same names. I am using list concept that is not working.enter image description here

2
  • Can you share the DOM code from the iFrame element to the View elements? Commented Mar 25, 2019 at 13:13
  • Anijith, as a new contributor, you may not know, but it's common to mark as "Accepted" answers that fully satisfy your questions. It both motivates the contributors and express that you already have your answer. Commented Mar 25, 2019 at 18:00

1 Answer 1

2

Selenium provides two methods to deal with iFrames.

You can search for a iFrame with id IFRAME_ID

driver.switchTo().frame(IFRAME_ID)

And you can return to the context of the root element:

driver.switchTo().defaultContent()

Of course, you can chain iFrames:

driver.switchTo().frame(IFRAME_ID1).switchTo().frame(IFRAME_ID2)

Meaning you will enter in the iFrame with ID IFRAME_ID2 which is inside the IFRAME_ID1.

If they were siblings, you would need to return to the default context:

driver.switchTo().frame(IFRAME_ID1);
driver.switchTo().defaultContent();
driver.switchTo().frame(IFRAME_ID2);

After switching to a iFrame, you can use WebDriver and WebElements as if the only the DOM branches inside the iFrame exist.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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