travisf
I’m trying to test a file upload:
file =
file_input(view, "#profile_pic_upload", :profile_pic, [
%{
last_modified: '1_624_366_053_000',
name: "profile_test.png",
content: File.read!("../support/profile_test.png"),
size: 269_280,
type: "image/png"
}
])
assert render_upload(file, "foo.png") =~ "100%"
But I keep getting this error:
** (ArgumentError) expected selector "#profile_pic_upload input[type=\"file\"][name=\"profile_pic\"]" to return a single element, but got none within:
But the HTML returned seems to contain that specific element:
<input accept=".jpg,.jpeg,.png" data-phx-active-refs="" data-phx-done-refs="" data-phx-preflighted-refs="" data-phx-update="ignore" data-phx-upload-ref="phx-Fors3j71WxhLhgGi" id="profile_pic_upload" name="profile_pic" phx-hook="Phoenix.LiveFileUpload" type="file"/>
So why is it unable to find the selector? Is there something I need to do to be more explicit?
For some context, I’m not actually trying to test the upload percentage, I’m just working through the docs. I am trying to populate the field with a file, submit the form to test some logic that my LiveView performs when a profile is updated with a profile picture. If there is another way to submit a form with a file attached, or fake it, I’m all ears!
Trending in Questions
Hello!
Suppose you are building workflow (order / task / payment) processing system with the following requirements:
Each workflow con...
New
I’m in search of an Elixir library that offers PDF generation capabilities similar to Ruby’s Prawn. While there have been discussions abo...
New
Hey guys,
I’ve got a huge CSV ( around 10 GB ) that needs to be processed hourly
Do you guys have any suggestions what is the best prac...
New
Kia ora,
We have been using elixir-google-api to connect to Google Drive. However, with the updates to Tesla due to CVEs this is now bro...
New
I’ve followed the Phoenix LiveView file upload code here Uploads — Phoenix LiveView v1.0.0-rc.7 and so far everything works just fine wit...
New
I’m using an Umbrella project for a Phoenix application, and I want to have one Ecto Repo and one PostgreSQL database shared by all apps....
New
Hello,
I’m developing a online persistent chat system (what’s app) like using elixir/dynamodb/aws for a mobile app(flutter).
The diffic...
New
Other Trending Topics
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
Hobbes is a low-level distributed database for the Elixir programming language.
Hobbes provides a simple, safe, and scalable storage lay...
New
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
ExRatatui lets you cook up rich terminal UIs in Elixir, powered by Rust’s ratatui via Rustler NIFs. Build interactive terminal applicatio...
New
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge & Solve.
They are GUI (Emerge) and State management (S...
New
Latest Phoenix Threads
Latest on Elixir Forum
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #blog-post
- #ai
- #phoenix_html
- #iex
- #graphql
- #elixirconf-us
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #hex
- #security
- #metaprogramming











Showing Posts 1 to 5- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
cblavier
I think that instead of doing
you should do
Let us know if it works!
travisf
Thanks @cblavier that definitely gets the correct field input.
Now I’m getting an error:
But I assume that’s related to something else.
mcrumm
What version of LiveView are you running currently? In the latest release we should be catching this exit for you.
chrismccord
Note that you do not need to pass
sizeif you are passing the content, as we’ll calculate the correct byte_size for you. You may be passing a mismatched size which we aren’t handlingtravisf
Thank you so much that was the exact issue. I wish I could mark two answers as solutions!