I am currently doing scraping using selenium in java for a website. Most of the pages I scrap contains ckeditor
. I am currently using javascript to get the data from ckeditor using javascriptexecutor executescript method
CKEDITOR.instances['locator name/id/class'].getData()
but the problem here is the locator is changing dynamically I also found a way to get the name of the locator by getAttribute(name)
method and used it in javascript but the problem here is some ckeditors
use id , some use names or classes and mostly all the attributes(id,class,name) are used in html
Sample html
<textarea id="cm_ckeditor name="profile_description" style="width: 100%; height: 200px; visibility: hidden; display: none;"></textarea>
here if i use CKEDITOR.instances['profile_description'].getData()
it is failing
It returns the data correctly when I use CKEDITOR.instances['cm_ckeditor'].getData()
similarly there are scenarios in which the name works and id fails
From your question i guess you want to get data from ckeditor whose locator is changing dynamically
You can use this javascript inside javascript executor
Hope this helps you...kindly get back if you have any queries