javascript - When element is 'display:none', how can I upload a image file? -


i'd upload file selenium. page url below.

<div class="async-upload__thumb item-image__area">   <div class="fab-dialog__thumb-drop-zone async-upload__thumb-drop-zone">     <p class="async-upload__thumb-msg" display="none">select image</p>     <input type="file" accept="image/jpeg,image/gif,image/png" multiple="" style="display:none">  </div> </div> 

but input element display="none" uploaded file code.

driver.findelement(by.xpath("//input[@type='file']")).sendkeys("test.jpg"); 

i got error this:

element not visible , may not interacted command duration or timeout: 24 milliseconds  

how can upload image file?

i not sure work or not, can remove style attribute.

webelement element = driver.findelement(by.xpath("//input[@type='file']")) javascriptexecutor js = (javascriptexecutor)driver; js.executescript("arguments[0].removeattribute('style')", element); 

you might need element again, attribute has changed or might staleelementexception

after above code following line should work.

driver.findelement(by.xpath("//input[@type='file']")).sendkeys("test.jpg"); 

Comments

Popular posts from this blog

networking - Vagrant-provisioned VirtualBox VM is not reachable from Ubuntu host -

c# - ASP.NET Core - There is already an object named 'AspNetRoles' in the database -

ruby on rails - ArgumentError: Missing host to link to! Please provide the :host parameter, set default_url_options[:host], or set :only_path to true -