selenium - JQuery: How to set FOCUS to a TinyMCE editor? -
i'm trying add text tinymce using selenium. i've been able add text using code:
$('iframe').last().contents().find('body').text('401c484b-68e4-4bf2-a13d-2a564acddc04');
the tinymce editor displaying guid. however, when selenium click submit button, i'm getting error: please, enter text.
.
i've noticed that, while selenium running, need click (manually) on tinymce then, when update button clicked, text returned.
so how click tinymce using javascript or jquery?
my answer came this post @siking pointed me to.
public void entertextintinymce(int n, string notetext, string escapeelementcss) { driver.switchto().frame(n - 1); iwebelement body = driver.findelement(by.xpath("//body")); body.click(); wait(3); ijavascriptexecutor jse = driver ijavascriptexecutor; jse.executescript("arguments[0].innerhtml = '" + notetext + "'", body); driver.switchto().defaultcontent(); wait(3); clicklinkbyfullcss(escapeelementcss); //--- added line force //--- iframe element lose focus }
clicklinkbyfullcss();
method defined in base class , escapeelementcss
element outside iframe
. chose title bar because it's div doesn't have button, avoid clicking on element might produce event.
in fact, switching defaultcontent pulling focus away editor. client element outside editor. force editor lose focus , update successful.
Comments
Post a Comment