Karias Bolster
Karias Bolster

Reputation: 1035

browser.click() does not work in redactor buttons

Have anybody tried doing an automated test involving redactor? I have a problem with browser.click(). It will not click the button I want it to click eg. the bold, italicised or underline buttons. Can someone help me?

Attached image below shows the DOM elements in dev tools. In my locator, eg. for bold, i used ('.red-bold').click();

enter image description here

Upvotes: 0

Views: 84

Answers (1)

alecxe
alecxe

Reputation: 474161

There is probably something wrong with your code. In any case, here is an example working code that selects all the text inside the redactor editor, clicks the "B" button in the toolbar making all the text bold:

describe("Redactor demo test", function () {
    var editor;

    beforeEach(function () {
        var EC = protractor.ExpectedConditions;

        browser.ignoreSynchronization = true;
        browser.get("https://imperavi.com/redactor/");

        // wait for the redactor editor to become visible
        editor = $(".redactor-editor");
        browser.wait(EC.visibilityOf(editor), 5000);
    });

    it("should make the text bold", function () {
        // select all text in the editor
        editor.click();
        editor.sendKeys(protractor.Key.COMMAND, "a");

        // click "bold"
        var toolbar = $(".redactor-toolbar");
        toolbar.$(".re-bold").click();

        browser.sleep(30000);  // the delay is for you to see it becomes bold 
        // TODO: expectations
    });
});

Upvotes: 0

Related Questions