1

Experimenting with Taiko for UI automation. Trying to upload a csv file but giving the id of the csv file selector is not working. A red rectangle outline blinks on top of the file upload link file firing {attach("/Users/username/Downloads/report.csv",$('*[id="some"]'))} but shows following error message in console.

Error: Node is not a file input element, run `.trace` for more info.

HTML

enter image description here

I've tried following fieldfield examples from https://docs.taiko.dev/#filefield

attach('report.csv', to(fileField('Upload CSV file (Optional)')))
fileField('Upload CSV file (Optional)').exists()
fileField({'id':'event-csv-upload'}).exists()
fileField({id:'event-csv-upload'},below('Upload CSV file (Optional)')).exists()
fileField(below('Upload CSV file (Optional)')).exists()

none of this works and finally tried following

attach("/Users/username/Downloads/report.csv",$('*[id="event-csv-upload"]'))
and
attach("/Users/username/Downloads/report.csv",fileField({id:'event-csv-upload'}))

source:https://github.com/getgauge/taiko/issues/309

Still not able to upload file using Taiko.

Why this file upload element is difficult to locate in angular code?

Is it too early to try Taiko now for angular web projects?

Do you recommend any other UI automation framework that work well with any angular versions?

2 Answers 2

1

attach expects a File input field as a selector to perform action on, in your case that element seems to be a hidden element linked to a button, attaching to that hidden element should work. Try,

await attach("/Users/username/Downloads/report.csv",fileField({id:'eventCSVFileInput'},{ selectHiddenElements: true }))
Sign up to request clarification or add additional context in comments.

6 Comments

Tried your line of code getting this concat error now. [FAIL] Error: File field[@id = concat('eventCSVFileInput', "")] and [object Object] not found
Seems you are using a different selector, fileField({id:'eventCSVFileInput'},{ selectHiddenElements: true }) this uses only id.. make sure you are on latest version of taiko
Was using 1.0.0 now Updated to taiko 1.0.13,Chromium:85.0.4168.0. Tried following attach("/Users/username/Downloads/report.csv",fileField({id:'eventCSVFileInput'},{ selectHiddenElements: true }) Error seems to different now Thrown: { [SyntaxError: Unexpected token, expected "," (2:1) ] loc: Position { line: 2, column: 1 }, pos: 137 } ... Thrown: { [SyntaxError: Unexpected token, expected "," (3:1) ] loc: Position { line: 3, column: 1 }, pos: 139 } ...
Tried this, for some reason id is not detected fileField({'id':'csvFileInput'}).exists() false [PASS] Does not exists
Error with attach seems to be happening because of missing ) at the end, await attach("/Users/username/Downloads/report.csv",fileField({id:'eventCSVFileInput'},{ selectHiddenElements: true }))
|
0

Try this

await attach("/Users/username/Downloads/report.csv",fileField({id:'eventCSVFileInput'},{force:true}))

Comments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.