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
Post a Comment