Issue
I want to create a Selenium test to test our extensions with AOL mail. I managed to login 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 iframe and other elements by Xpath (or in any other way with Selenium)?
Solution
You cannot traverse through <iframe>
's until switching to them. Your xPath,
//iframe[@name='editor_body']//body[@contenteditable='true']
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:
driver.switch_to.frame('editor_body')...
Answered By - ddavison Answer Checked By - Senaida (PHPFixing Volunteer)
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.