3

I have an app that performs an upload. I cannot seem to get the file system pop up to close. It does not mess up the test, it keeps running in the background but the odd chance that I want to watch the test a quarter of the screen is covered. So I figure a fix to this problem would just be force the rest of the test to complete in a new tab. I have no idea how to do this.

Here is my upload code:

var uploadPathLink = element(by.css('button.btn.btn-select'));
var path = require('path');
//the file to upload
fileToUpload,
//this is variable that inserts the path to find file to upload
absolutePath = path.resolve(__dirname, fileToUpload);
//inserts the path
uploadPathLink.sendKeys(absolutePath);

Related to this question: Upload modal will not close after filepath is sent

Community
  • 1
  • 1
Nicole Phillips
  • 753
  • 1
  • 18
  • 41

1 Answers1

3

To open a new tab, pass in the commands that you usually do using keyboard (CONTROL+T). Here's one sample of it -

element(by.tagName('html')).sendKeys(protractor.Key.chord(protractor.Key.CONTROL, "t")); //If you are using MAC then replace CONTROL with COMMAND
//element can be any element in your DOM

Later you can switch to the new tab using getWindowHandle(). Hope this helps.

giri-sh
  • 6,934
  • 2
  • 25
  • 50