java - How to use SendKeys(webdriver) command in Rich Text editor that is located in iframe -


I am facing the following problem. I can not type text in iframe which has a text editor in it: here is Html:

  & lt; Iframe class = "cke_wysiwyg_frame cke_reset" frameborder = "0" style = "width: 100%; height: 100%;" Aria-Description = "cke_39" heading = "WordTrash term for description, description 1" src = "" tabindex = "0" permissiveness = "true" & gt; & Lt ;! DOCTYPE html & gt; & Lt; Html lang = "bg" dir = "ltr" & gt; & Lt; Top & gt; & Lt; Body class = "cke_editable cke_editable_themed cke_contents_ltr" contenteditable = "true" spelling check = "wrong" & gt; & Lt; P & gt; & Lt; Br> & Lt; / P & gt; & Lt; / Body & gt; & Lt; / Html & gt; & Lt; / Iframe & gt;  

Even so far I have done this, but the examination was successfully passed and no text was written in the text editor. The solution is with Javascript, but I'm not familiar about it.

  WaitTool.waitForElementPresent (Browser.instance, By.tagName ("iframe"), 10); WebAlement iframe = Browser.instance.findElement (By.tagName ("iframe")); Browser.instance.switchTo () frame (iframe). Web Element Details = Browser.instance.findElement (Byexpath ("// body [@class = 'kk_editable kk_edit_stead cke_contents_ltr']")); Description.click (); Description.sendKeys ("someText"); . Browser.instance.switchTo () defaultContent ();  

Thanks in advance!

There are several ways to do this. Here is an article that you want to see.

  • Send the key directly

This approach is what you have tried to do and did not work. Please make sure your locators have & lt; Iframe & gt; and & lt; Body & gt; Otherwise I would suggest using the Javascript Exclorator for more stable solutions.

  • Set up the internal HTML
  waiting tool.witfail element display (browser in stains, bye.classname ( "Cke_wysiwyg_frame"), 10); WebArment iframe = Browser.instance.findElement (By.className ("cke_wysiwyg_frame")); Browser.instance.switchTo () frame (iframe). Web Element Description = Browser.instance.findElement (ccselector ("body"); (JavaScript Extractor) Browser.instance.executeScript ("Logic [0] .innerHTML = '& lt; h1 & gt; Set text using internal HTML & lt; / h1 & gt;" ", details);  
  • Use the CK Editor's native API
  // iframe switching Not Required (Javascript Exporter) Browser.instance.executeScript ("CKEDITOR.instances.ckeditor.setData ('

Native API Text & lt; / h1 & gt; Editor')");


Comments

Popular posts from this blog

ios - How do I use CFArrayRef in Swift? -

eclipse plugin - Run java code error: Workspace is closed -

c - Error on building source code in VC 6 -