3

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();
} 
9
  • welcome to SQA, I am having a bit of trouble understanding what the issue is exactly. Are you saying that the $this->ByName('wysiwyg name')->value('test'); $this->ById('submit id')->click(); code segments are not working for your application?
    – Dan Snell
    Jul 11, 2013 at 18:23
  • when i execute the tests withe selenium serever all the text field get the value that i gives bur the wysiwyg doesn't take the value 'test' as value. did i was clear? tainks for traying.
    – Lorina
    Jul 12, 2013 at 9:32
  • Can you show the html? There are a number of different reasons why the selenium identifiers might not be working, but we can't tell which is which without a look at the html. Jul 15, 2013 at 10:13
  • @Lorina: You have to put four spaces before each line of the html, to make it show as embedded code instead of being interpreted as html. Jul 17, 2013 at 10:38
  • @Lorina: Your html doesn't match your selenium code; I guess the identifier 'wysiwyg name' isn't from your real code? Can you include the actual selenium code you are trying to run; otherwise it's difficult to tell what's going wrong. Jul 17, 2013 at 10:45

1 Answer 1

1

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");
2
  • tahinks very muche . i will try what you said, i want just mantion that am biggner in programing and in selenium. driver what is it is it a varible: $driver.switchTo().Frame("frame_name"); or what exactly??
    – Lorina
    Jul 17, 2013 at 10:42
  • is this code is in java?
    – Lorina
    Jul 26, 2013 at 9:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.