0

Following is the page source of file upload section. enter image description here

Following is my code in Visual Studio Code

const remoteFilePath = await browser.uploadFile(filePath);
    let fileUpload_var = $('//input[@type="file"]');
    await fileUpload_var.setValue(remoteFilePath);

Am getting below Error

element not interactable: element not interactable
  (Session info: chrome=103.0.5060.53)
    enter code here

I tried this also, to make the enveloping span visible

const inputdiv = $(
      '//span[@class="p-button-label"]'
    );

    await browser.execute(function () {
      const elements = document.getElementsByClassName(
        ".p-button-label"
      );

      for (let i = 0; i < elements.length; i++) {
        elements[i].style.display = "block";
        elements[i].style.visibility = "visible";
      }
    });
    inputdiv.style.display = "block";
    inputdiv.style.visibility = "visible";
    
    await inputdiv.waitForDisplayed();

Now the error is : element ("//span[@class="p-button-label"]") still not displayed after 10000ms

2 Answers 2

2

Changing the method from "setValue" to "addValue" helped me resolve the issue.

await fileUpload_var.addValue(remoteFilePath)

0
const inputdiv = $(
      '//p-fileupload[@class="p-element service-input ng-star-inserted"]'
    );

    await browser.execute(function () {
      const elements = document.getElementsByClassName(
        ".p-element service-input ng-star-inserted"
      );

      for (let i = 0; i < elements.length; i++) {
        elements[i].style.display = "block";
        elements[i].style.visibility = "visible";
      }
    });
    inputdiv.style.display = "block";
    inputdiv.style.visibility = "visible";

    await inputdiv.waitForDisplayed();

    const filePath = "C:/SampleData/Upload.csv";
    const remoteFilePath = await browser.uploadFile(filePath);
    await browser.pause(20000);
    const fileUpload_var = $('//input[@type="file"]');

    fileUpload_var.style.visibility = "visible";
    fileUpload_var.style.display = "block";
    await browser.pause(20000);
    await fileUpload_var.addValue(remoteFilePath);

This worked!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.