TestProject Forum

Web component (no xpath), file upload and other issues

I have an application that runs inside a webcomponent. As far as I understand, there is only a unique way of performing test inside webcomponents, which is through “Execute js” and copying the full js path, and then performing actions such as .click()

This works, but sometimes doesn’t work (in the case of dynamic fields in angular). Am I following the correct way of doing this? The “full xpath” copied, such as “/html/body/shadow-overlay//div/div[2]/div/app-ahe-overlay/div/app-recovery-expenses-account/div/div[2]/form/nx-multi-stepper/div[6]/app-documents/div/app-form-element[1]/div/div/app-expenditure-documents-table/button” doesn’t work (probably not a surprise because of the shadow dom).

The biggest problem I am having, though, is related to the file upload field. Unfortunately the “file upload” addon works via xpath, and therefore it cannot work.

How can I perform this action in a webcomponent in your opinion?

Thanks

1 Like

Hi @andrea.maschio,
You can use the action - Upload a file with a robot
then your process will be like this

  1. execute javascript with a click in the upload element that opens the file explorer.
  2. Upload a file with robot with the file path you want to upload

This will open your file explorer and upload the file you want and close the file explorer automatically.

About element is dynamic and jsPath doesn’t work, try to see if the element has a unique id or class name, then you can use these scripts to find

document.getElementsByClassName("");
or
document.getElementById("");

Kind regards
Tal

Hi Tal,
I tried your solution but I get this error when uploading a file with a robot.

Kind regards,
Lorenz

Hi @lorenzc, can you please check if you have an update for the addon?
You can see if you have an update by clicking the addon tab and writing robot

Hi @Tal.Efraim I have updated the addon but still get the same error.

Thank you!

Hi @lorenzc,
What version of the agent are you using?
Does it happen with latest? 3.4.2?

Hi @Amit.Lacher all good now! It worked after updating the agent to the latest version. Thank you for the swift response!

Hi @lorenzc,
Glad everything worked out :slight_smile:
Feel free to reach out if you have any questions.

1 Like