Unable to locate WYSIWYG element using selenium and phpunit



  • I am creating functional tests with selenium & PHPUnit, but I can't locate a WYSIWYG element using different locators:

    • Xpath
    • byId
    • byName
    • by Css Selector

    Examples:

    public function test(){
         $this->assertEquals($this->getBrowserUrl(),'url'); 
         $this->ByName('text field name')->value('test');
         $this->ByName('text field name')->value('test');   
         $this->ByName('wysiwyg name')->value('test');   
         $this->ByName('wysiwyg name')->value('test');
         $this->ById('submit id')->click();
    
         }
    

    In the two first text fields the value has been inserted, but for the two last no values are added. If some one has an idea of what is wrong, please help.

    The HTML code is like this:

    <html>
     <textarea id="test_libelle" class="item_field wysiwyg_editor" required="required" name="test[libelle]" style="visibility: hidden; display: none;"></textarea>
     <span id="cke_otest_libelle" class="cke_skin_kama cke_1 cke_editor_test_libelle" lang="fr" style="width: 788px;" aria-labelledby="cke_test_libelle_arialbl" role="application" title=" " dir="ltr">
      <span id="cke_test_libelle_arialbl" class="cke_voice_label">Éditeur‌·de‌·Texte‌·Enrichi</span>
      <span class="cke_browser_gecko" role="presentation">
       <span class="cke_wrapper cke_ltr" role="presentation">
        <table class="cke_editor" cellspacing="0" cellpadding="0" border="0" role="presentation">
         <tbody>
          <tr role="presentation" style="-moz-user-select: none;">
          <tr role="presentation">
          <tr role="presentation" style="-moz-user-select: none;">
         </tbody>
        </table>
        <style>
       </span>
      </span>
      <span role="presentation" style="position:absolute;" tabindex="-1"></span>
     </span>
     </div>
     </td>
     </tr>
    </html>
    

    Here is my selenium code:

    public function creatMat(){ 
        $this->assertEquals($this->getBrowserUrl(),'url/ssion'); 
        $this->ByValue('Créer')->click(); 
    }
    public function test(){ 
        $this->assertEquals($this->getBrowserUrl(),'url/session/new/'); 
        $this->ByName('text area1 name')->value('01 02 03');
        $this->ByName('text area2 name')->value('150'); 
        $this->ByName('wysiwyge1 name')->value('test');
        $this->ByName('wysiwyge name')->value('test'); 
        $this->ById('submit id')->click();
    } 
    


  • I had an issue once with CKEditor. Turned out that it was using its on IFRAME, so in order to find the element, first you might need to Switch to the WYSIWYG frame/iframe.

    Like this:

    driver.SwitchTo().Frame("frame_name");
    


Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2