How to fill CKeditor textarea with content using codeception

拈花ヽ惹草 提交于 2019-12-13 08:36:02

问题


This is a follow up question to this one -- How to fill a rich text editor field for a Codeception Acceptance test

The solution given on this post, works perfectly on CKeditor version 4.3.2 Standard as seen on this site CKeditor instance but unfortunately does not work on my site's own CKeditor which is version 4.5.10.

Issue with my site's CKeditor - Webdriver throws an error that the name attribute of the textarea is not found. On the example, working CKeitor this is not an issue, I am able to gain focus and add custom content to the textarea.

Question - is there a big difference between CKeditor 4.3.2 (working) and version 4.5.10 (not working), that would cause this solution not to function?

Textarea on the working site

<textarea id="ckeditor" style="visibility: hidden; display: none;"></textarea>

Using id="ckeditor" works as expected.

Textarea on my site

<textarea class="js-text-full text-full form-textarea resize-vertical" data-drupal-selector="edit-field-pck-headline-0-value" aria-describedby="edit-field-pck-headline-0--54Lxz-5-U5g--description" id="edit-field-pck-headline-0-value--im63vH7ew8s" name="field_pck_headline[0][value]" rows="5" cols="60" placeholder="" data-editor-active-text-format="full_html" style="visibility: hidden; display: none;"></textarea>

I am using the name="field_pck_headline[0][value]" but webdriver cant locate this

Thanks for any help in getting focus to the CKeditor textarea on my version (4.5.10). I am glad to provide more details, let me know.

Here is a screen grab of my local CKEditor textarea that I am attempting to gain focus to My local CKEditor textarea


回答1:


Here's what worked for me (testing a Drupal 7 site):

$I->executeJS("CKEDITOR.instances['edit-body-und-0-value'].setData('Text entered via Selenium.');");



回答2:


i'm using CKeditor 4.4, selenium webdriver in acceptance test.

this works for me. following this

How to fill a rich text editor field for a Codeception Acceptance test

html of page:

<div id="cke_1_contents" class="cke_contents cke_reset">

    <iframe class="cke_wysiwyg_frame cke_reset" frameborder="0" src=""> 

in my test:

$I->fillCkEditorById('1_contents', 'your added content');

USE 1_contents AS A PARAM



来源:https://stackoverflow.com/questions/40093785/how-to-fill-ckeditor-textarea-with-content-using-codeception

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!