I encountered a problem during the test, and I was unable to find the HTML underneath the IFRAME through Cssselector:
<div id= "Maileditordiv" style= "Display:inline-block;" ><div class= "Maileditor" ><div style= "height:130px;" ><div class= "Divbody" ><div class= "Ke-container ke-container-default" style= "width:620px;" ><div class= "Ke-toolbar" style= "Display:block;" unselectable= "on" ><div class= "Ke-edit" style= "Display: Block height:286px; " ><iframe class= "ke-edit-iframe" frameborder= "0" hidefocus= "true" style= "width:100%; height:286px; " ><HTML>body class= "ke-content" >rrrrrrrt</body>< /html>
Later I found that I could only find the IFRAME here, and then I could not find it. I have used SendKeys to can send text to body, but want to verify the text of the IFRAME through assert, unable to do.
Workaround:
The problem is solved by switching the driver to the IFRAME and then switching back.
public void Sendkeystomailbodyeditboxandcheck (String mailbody) {webelement el = Page.getmailbodyeditbox (); El.sendkeys (Mailbody); Driver.switchto (). FRAME (EL); Assert.assertequals (Driver.findelement (By.xpath ("//html/body")). GetText (), Mailbody, "'" +mailbody+ "' should be displayed in mail body. "); Driver.switchto (). Defaultcontent ();}