3

Testing a webpage which has an area for pasting out a tab separated text by using the CTRL+V keys only (There is no textarea or any input field), it is just a field where I can select the field by mouse click and then use CTRL+V, which automatically take all the text in the buffer.

So I get the Part of PASTING the text using the sendKeys for CTRL+v, eg: Sending Ctrl+A combination to an element

var elm = element(by.model('myModel'));
elm.sendKeys(protractor.Key.chord(protractor.Key.CONTROL, "v"));

I am STUCK at COPYING. How to copy?

Is there a way I can store the tab separated text in

var String =[col1   col2    col3    col4    col5    col6
row1 1  2   3   4   5   6
row2 7  8   9   10  11  12
row3 13 14  15  16  17  18
];

and then paste it using a CTRL+V command to paste it, on a Windows machine CTRL+V is explained here. https://msdn.microsoft.com/enus/library/windows/desktop/ms682541%28v=vs.85%29.aspx

Lets say the HTML is

 <input ng-paste="paste=true" ng-init="paste=false" placeholder='paste here'>
pasted: {{paste}}
Community
  • 1
  • 1
patz
  • 1,306
  • 4
  • 25
  • 42
  • I am pretty sure you can approach it without using the copy/paste shortcuts. Is it a public site and you can provide a link? Or, if not possible, show the HTML representation of the target element. – alecxe Mar 31 '15 at 18:58
  • it not a public site, but let me try to find an example, lets say the HTML is this https://docs.angularjs.org/api/ng/directive/ngPaste – patz Mar 31 '15 at 19:10
  • Thanks, could you please explain me what do you want to do step-by-step, using the provided link? Would definitely help to help. – alecxe Mar 31 '15 at 19:14
  • I want to copy a tab separated text from my MS Excel into the pasting area provided, So normally I would use CTRL+C in the MS Excel and on the website after click the input are would do CTRL+V to paste it. In portractor how do I perform CTRL+C COPY(not talking about the code for sendKeys CTRL+C). – patz Mar 31 '15 at 19:18
  • I can think of the easier way to do, copying the tab separated text before launching the protractor tests. once the tests launches it will have CTRL+V text on Windows buffer or any other OS's buffer – patz Mar 31 '15 at 19:22
  • Though this wouldn't work if I had multiple things to be copied and pasted . – patz Mar 31 '15 at 19:24
  • Got answered [here](http://stackoverflow.com/questions/11750447/performing-a-copy-and-paste-with-selenium-2) and [here](https://github.com/angular/protractor/issues/1037) – e382df99a7950919789725ceeec126 Oct 22 '15 at 07:42

1 Answers1

2

Instead of having a dependency presented as a manual copying a text from an Excel File and having it in the buffer, parse the data source excel file(s) via one of the nodejs excel parsers:

In this case you'll have the data available as a text in your test(s) and you would use the regular sendKeys() method on the element.

alecxe
  • 462,703
  • 120
  • 1,088
  • 1,195