Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with uploading file on a web browser while running test on an Azure pipeline #34300

Open
abhay2506Singh opened this issue Jan 10, 2025 · 0 comments

Comments

@abhay2506Singh
Copy link

abhay2506Singh commented Jan 10, 2025

I am executing some tests where i am expected to upload pdf/excel files (Single/multiple). I am using the file from project repository itself and it works perfectly on local execution.
But when executing the same test on Azure pipeline(test run on a linux machine), the test does not give any error, but the file also does not get uploaded. Please help.

Element :
<input _ngcontent-ehr-c4="" multiple="" style="display: none;" type="file">
Code variations tried:

  1. Multi File
const filepathval = path.join(__dirname, "../../../PDF_Files_Folder");
var filePath:string[] = METHOD_TO_Get_FILE_ARRAY_FROM_FOLDER_PATH(filepathval);
var newFileName[] = METHOD_TO_GET_FILENAMES_CONCATENATED_WITH_TIMESTAMP(filePath);
for (let index = 0; index < filePath.length; index++) {
            files.push({buffer:FS.readFileSync(filepathval [index]),name:newFileName[index],mimeType: 'application/octet-stream'});
        }
await this.page.locator(this.selectors.fileInputElement).setInputFiles(files);
  1. Single FIle
const excelFilesForUploadPath = path.join(process.cwd(), '../../../PDF_File_NAME.pdf');
await this.page.locator(this.selectors.fileInputElement).setInputFiles(filepathval);
  1. Even tried using API
static async uploadFileService(request:APIRequestContext,filePath:string[], newFileName:string[], fileType:FileType) {
    const form = new FormData();
    for (let index = 0; index < filePath.length; index++) {
      const fileBuffer = FS.readFileSync(filePath[index]);
      form.append('file', new File([fileBuffer],newFileName[index],{ type: 'application/octet-stream' }));
    }
    
    const headers:any = await HeaderDataClient.getHeadersUploadFile();
    var baseURL = process.env.ENV_VAR_VAR==='qa'?
      "BASE_URL_QA":
      "BASE_URL_UAT";
    const response = await request.post(baseURL + resource, {
      headers: headers,
      multipart: form
    });
    return response;
  }

In all cases, files upload locally, but when executing the same code on Azure pipeline (runs on linux machine) , the loader for file upload keeps rotating, but the file does not load and the test times out.
For case 1 and 2, i.e. UI uploads, No errors appear in log.
For case 3, ie API , i ma getting 'apiRequestContext.post: connect ETIMEDOUT'

@abhay2506Singh abhay2506Singh changed the title Issue with uploading file on a web browser while running test on an Azure agent machine Issue with uploading file on a web browser while running test on an Azure pipeline Jan 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant