Operating system / user transporter test definition

I have a sequence of mouse / key buttons in a Protractor test that differs depending on the OS (Mac versus everything else). I would like to change which key is held down by the mouse click, depending on the OS or User Agent.

Depending on where I'm testing (local Mac OSx + Chrome or headless PhantomJS on Linux) a command key or Ctrl key is required.

The current test looks like this:

describe('my test', function() {

  //get elements with code not shown
   ptor.actions()
                        .sendKeys(protractor.Key.CONTROL)  //mac protrator.Key.COMMAND non mac protractor.Key.CONTROL
                        .mouseDown(trs[0])
                        .mouseUp(trs[0])
                        .sendKeys(protractor.Key.NULL)
                        .perform();
                    trs[0].evaluate('selectedItems.length')
                        .then(function(count) {
                            expect(count).toBe(0);
                        })

});

      

+3


source to share


1 answer


Heads-up first using the COMMAND key from webdriver probably won't work on OSX .

As for the way to determine the current operating system of the browser, I use some helper functions.

Usage - Configuration File

onPrepare: require('./capabilities.js'),

      



Usage - test files

if (browser.inOSX()) {
  // in Mac...
} else if (browser.inWindows()) {
  // in Windows...
} else {
  // likely in Linux...
}

      

Browser extensions

See features.js in this context

+3


source







All Articles