mardi 18 juillet 2017

Upload file with selenide webdriver without any input

I am trying to upload file using java selenide automation test.

Place I wrote my test uses upload box without any input value near it.

Upload box is id='file'

I tried to used:

$(By.cssSelector("[id='file']")).uploadFile(new File("myfilePackage" + File.separator + "picture.jpg"))

but that did't help cause there is no input box for file upload.

Then I tried to use:

WebElement elem = getWebDriver().findElement(By.cssSelector("[id='file']"));
String js = "arguments[0].style.height='auto'; arguments[0].style.visibility='visible';";

((JavascriptExecutor) getWebDriver()).executeScript(js, elem);
elem.sendKeys("wholePath\\picture.png");

to make the element visible but I get unkown error: canno focus element\n ...

Is there any other way to get file from this kind of upload?

Aucun commentaire:

Enregistrer un commentaire