Answered

Unable to perform file upload as their no @type='file'

We are unable to perform file update as we are unable to get //input[@type='file'].

We will not be able to use sikuli locators to perform file upload because for cloud runs, We will not be able to place the file in the desired location on cloud VMs.

Help us to get alternative way to upload file successfully

current xpath: //a[contains(text(),'Drag and drop a PDF file here or browse for a PDF file to upload.')]

0
6 comments
Avatar
Ajit Parthasarathy

0
Comment actions Permalink
Avatar
Joseph Hamdan

Hi Ajit,

In some instances, the input tag with type = file can sometimes be available in the DOM, but not situated in the place where you are inspecting.

Could you please click Console on Dev Tools to see if it exists by using the below:

$x("//input[@type='file']")

If you are able to find it, please check if it's the same one used for uploading files. If not, please send us the test case name for further investigation.

Regards,

Subject7 Team

0
Comment actions Permalink
Avatar
Ajit Parthasarathy

Hi Team,

I am finding something like this as mentioned in below screenshot.

But it is not working for file upload.

Please find the test case details below for further verification.

Name: UT_HCM_LR_004_Allow_contentforlasses_tobeuploaded

ID: 26734

Project: Oracle_All_Scripts_Main

--

Thanks,

Ajit P

0
Comment actions Permalink
Avatar
Joseph Hamdan

Hi Ajit,

Apologies for the delay in response. We have investigated this and it appears that modal window only changes state (progress bar appears and save and close button activates) when the upload is done by the user manually. When automated, the file does get uploaded using an XPath such as the below, but the issue is that the modal window does not change state so saving is not going to be allowed.

//input[@type='file']
//a[contains(text(),'Drag and drop a PDF file here or browse for a PDF file to upload.')]/ancestor::div/following-sibling::div/span/input[@type='file']

Regards,
Subject7 Team

0
Comment actions Permalink
Avatar
Joseph Hamdan

Hi Ajit,

Based on the previous response, we will continue to investigate and will let you know if a solution is found for this.

Regards,
Subject7 Team

0
Comment actions Permalink
Avatar
Joseph Hamdan

Hi Ajit,

We found a way which has worked, please follow the steps below:

1- Open function with name "UT_HCM_LR_004_Allow_contentforlasses_tobeuploaded"

2- After step # 98 which has captions "File_Upload HALT Learnings.link.drag_anddrop FILE birth_certificate.pdf", insert a step with Execute_Javascript command.

3- The Javascript step should include this code:

// 0. the behaviour of the "Drag and drop a PDF file here or browse for a PDF file to upload." link element is following:
// 0.1 the "link"'s clicking invokes a wrapper: "openFileBrowser";
// 0.2 the wrapper fills the "hcmEngmtVideoShareUpload" object;
// 0.3 the wrapper overrides the "onchange" handler of the "input" element: "file.onchange = hcmEngmtVideoShareUpload.handleBrowse";
// 0.4 the wrapper invokes "click" of the "input" element directly => it invokes the overriden "onchange" handler of the "input" element;
// to finish uploading correctly we should do the following:
// 1. click the "Drag and drop a PDF file here or browse for a PDF file to upload." link to invoke the wrapper ("openFileBrowser") and fill the "hcmEngmtVideoShareUpload" object;
// 1.1 since the wrapper invokes "click" of the "input" element we should refused source handler and invoke a custom one;
// 2. since the "onchange" handler of the "input" element is overriden we should invoke it directly: "hcmEngmtVideoShareUpload.validateFile(this.files)".
const uploadMessageXPath = "//a[contains(text(),'Drag and drop a PDF file here or browse for a PDF file to upload.')]";
const uploadMessageElement = document.evaluate(uploadMessageXPath, document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
//there is no possibility to use a Locator here because the Locator requires that an element must be visible
//in the current case the "input" element is hidden
const uploadInputXPath = "//a[contains(text(),'Drag and drop a PDF file here or browse for a PDF file to upload.')]/ancestor::div/following-sibling::div/span/input[@type='file']";
const uploadInputElement = document.evaluate(uploadInputXPath, document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
//override it and invoke "hcmEngmtVideoShareUpload.validateFile" directly
uploadInputElement.click = function() {
// in the current case "this" is "uploadInputElement" element
hcmEngmtVideoShareUpload.validateFile(this.files);
};
// the "uploadMessageElement.click()" method will invoke "uploadInputElement.click"
uploadMessageElement.click();

4- You can skip step # 97 with captions "File_Upload HALT learning.input.upload FILE birth_certificate.pdf "upload_file" if it was added to test uploading the same file.

Regards,
Subject7 Team

0
Comment actions Permalink

Please sign in to leave a comment.