0 votes
1 view
in DevOps and Agile by (19.8k points)

I want to create a Selenium test to test our extensions with AOL mail. I managed to log in to AOL and compose an email, but I also need to select elements inside the editor, which is inside an iframe. I checked and even when the editor is open the following test fails:

self.assertEqual(first=1, second=len(self.driver.find_elements_by_xpath(xpath="//iframe[@name='editor_body']//body[@contenteditable='true']")))

I get the error AssertionError: 1 != 0. How do I select the body of the frame and other elements by Xpath (or in any other way with Selenium)?

1 Answer

0 votes
by (63.4k points)

You cannot traverse through <iframe>'s until switching to them. Your XPath,


will not work because the <body> tag is within an iFrame, which is not in the current context. you need to switch to it first:


Welcome to Intellipaat Community. Get your technical queries answered by top developers !