Reputation: 501
I'm using Selenium to test my website. I am making a functional test where it logs a new user in, goes to their profile, then asserts that it can successfully update their profile info. This includes name, email address and profile picture. I can check that the name and email are successfully updated, but don't know how to check that the image uploads correctly.
I am able to upload the image successfully (I used time.sleep(10) to check - I just need an assertion for it.
This is how im uploading the new image
self.browser.find_element_by_css_selector('.clearablefileinput.form-control-file').send_keys(settings.MEDIA_ROOT+'\profile_pics\\testImg.jpg')
Thank you.
Upvotes: 0
Views: 315
Reputation: 7744
As mentioned in the comments, you can check that the file name exists in the root media folder? You can check with something like
os.path.isfile(fname)
#Or
os.path.exists(file_path)
which both returns true if it exists or not.
I don't think deleting a file is possible in selenium, since its just an Automator. For that, you would have to use the os
module again with remove()
method.
Upvotes: 1