1

I was wondering if anyone knew how to do the equivalent of 'keydown' and 'keyup' events with WebdriverIO? I currently have the following code:

// required pages
var LibraryPage = require('../../pageobjects/library.page.js'); 

describe('Delete Button', function(){
    before(function (){
        LibraryPage.open('/library/list/1/');
    });
    it('Delete button shows correct number of images', function (){
        browser.keys('Ctrl');       
        LibraryPage.Image('asset1.jpg').click();
        LibraryPage.Image('asset3.jpg').click();
        LibraryPage.Image('asset5.jpg').click();
        expect(LibraryPage.DeleteButton.getAttribute("title")).to.equal("Delete 3 assets");
    });
});     

// Library Page Object
DeleteButton: { get: function () { return browser.element('div[title^="TODO: Delete "]'); } },
Asset:        { value: function(assetName) { return browser.element('tr*=' + assetName); } },

I want to hold the CTRL key while selecting images to multi-select.

What I have read indicates that the keys function should be sticky until it gets nulled out, but that’s not what I am experiencing.. Each item gets clicked without the CTRL button being held.

Using WebdriverIO v4 (synchronous JS). Any help would be much appreciated, thanks!

  • have you looked at [this](http://stackoverflow.com/questions/30077667/how-to-simulate-ctrl-click-or-shift-click-with-webdriver-io) . It may be your answer – user1207289 Sep 07 '16 at 00:53
  • Yes, I saw that. Unfortunately that example uses WebdriverIO v3, not v4 with the global 'browser' object and synchronous commands. – Natasha Bykhovsky Sep 07 '16 at 04:13
  • i think you can use all commands as is synchronously, with v4. have you tried commands that are in there, synchronously? any error? – user1207289 Sep 07 '16 at 14:18
  • Yes I tried the commands, the problem is that the Control button isn't being held down and is released before I click on the images. – Natasha Bykhovsky Sep 07 '16 at 14:48
  • can you update and show your full code. This way you'll have more chances that you get answer from someone – user1207289 Sep 07 '16 at 15:04
  • sure, I added some additional code, but this is a more general question of getting the 'Control' or 'Shift' key to stick. This is also revelant to something that looks like this: `browser.keys('Ctrl');` `browser.click('#asset1.jpg');` `browser.click('#asset3.jpg');` `browser.click('#asset5.jpg');` – Natasha Bykhovsky Sep 07 '16 at 16:52
  • I think you should try `var ElemList= browser.elements() ; browser.click('#asset1.jpg'); browser.moveTo(ElemList.value[].ELEMENT, 0, 0) ;browser.keys('Shift');browser.click('#asset3.jpg'); browser.moveTo(ElemList.value[].ELEMENT, 0, 0) ; browser.click('#asset5.jpg'); ` – user1207289 Sep 07 '16 at 17:20
  • That does not work for me, the Shift key is still does not stick allowing me to select multiple images. – Natasha Bykhovsky Sep 07 '16 at 17:31

0 Answers0