How to use copy and paste with protractor on MAC with Chrome?

How can I use copy and paste with protractor on MAC with Chrome?

newInput.sendKeys(protractor.Key.chord(browser.controlKey, "a"));
newInput.sendKeys(protractor.Key.chord(browser.controlKey, "c"));
newInput.sendKeys(protractor.Key.chord(browser.controlKey, "v"));

I have "undefined" when I use this code

I am using this code from this post Using cross-platform keyboard shortcuts in end-to-end testing , but it does not work:

browser.controlKey = protractor.Key.CONTROL; //browser.controlKey is     a global variable and can be accessed anywhere in the test specs
browser.getCapabilities().then(function(capabilities){
    if(capabilities.caps_.platform === "MAC")
        browser.controlKey = protractor.Key.COMMAND;
});

elm.sendKeys(protractor.Key.chord(browser.controlKey, "c"));
+4
source share
1 answer

This is a known issuechromedriver . Unfortunately, sending keyboard shortcuts from Protractor / WebDriverJS will not work on Chrome + Mac.

In our project, we moved all the tests that use keyboard shortcuts for Firefox:

var firefox_only_specs = [
    "../specs/sometest1.spec.js",
    "../specs/sometest2.spec.js"
];

exports.config = {
    multiCapabilities: [
        {
            browserName: "chrome",
            chromeOptions: {
                args: ["incognito", "disable-extensions", "start-maximized"]
            },
            specs: [
                "../specs/*.spec.js"
            ],
            exclude: firefox_only_specs
        },
        {
            browserName: "firefox",
            specs: firefox_only_specs
        }
    ],

    // ...
}
+6

Source: https://habr.com/ru/post/1625335/


All Articles