0

I am using protractor to automate my website. I have a scenario where need to upload the file clicking on upload button. When clicked on upload button then it renders the native os popup to select the file.

I tried to upload using below code without clicking on upload button.I think this approach is not correct as the user has to click on upload button and then select the file from native os popup.But still no luck

var fileToUpload = 'filePath';
var absolutePath = path.resolve(__dirname, fileToUpload);
element(by.id("creator--add-a-piece-empty")).sendKeys(absolutePath);

How to select the file in native os pop ? Is there any way to upload

Operating system - Mac siera

I have tried all the possible solution provided on How to upload file in angularjs e2e protractor testing But no luck . I have added the code below s ,that will redirect you to the problem page ,where i need to upload the file.Thanks in Advance.

describe('NeonMob', function() {
it('LoginUsingInvalidEmail', function() {
browser.get('https://staging.neonmob.com/login');
element(by.id('form-field-username')).click();
element(by.id('field-username')).sendKeys("sharif");
element(by.id('field-password')).sendKeys("1234");
element(by.id('signin-btn')).click();
element(by.css("a[id='primary-navigation--create']")).click();
element(by.id("create-new-amateur-series")).click();
element(by.id("confirm-btn")).click();
element(by.id("creator--add-a-piece-empty")).click();//to click on Add 


});   
});
Sharif
  • 1
  • 1
  • I marked this as a possible duplicate of [How to upload file in angularjs e2e protractor testing](https://stackoverflow.com/questions/21305298/how-to-upload-file-in-angularjs-e2e-protractor-testing) because uploading a file is explained there – wswebcreation Jun 04 '17 at 16:31
  • I need to upload file in my app ,I tried all ,No luck ,I have added the code above ,That will redirect you to the exact page ,where i need to upload file .I have not added the code for uploading ,because i tried many ways nothing work for me .Please have a look . Thanks for your response. – Sharif Jun 09 '17 at 17:40

1 Answers1

0

var sitepath = "site-100M.zip"; element(by.css('#siteTemplateUploadFile')).sendKeys("D:/localresources/"+sitepath); This is my code which works fine.

Bob Bai
  • 283
  • 4
  • 20