protected void uploadFile ( PageElement pageElement , String fileOrKey , Object ... args ) throws TechnicalException , FailureException { final String path = Context . getValue ( fileOrKey ) != null ? Context . getValue ( fileOrKey ) : System . getProperty ( USER_DIR ) + File . separator + DOWNLOADED_FILES_FOLDER + File . separator + fileOrKey ; if ( ! "" . equals ( path ) ) { try { final WebElement element = Context . waitUntil ( ExpectedConditions . presenceOfElementLocated ( Utilities . getLocator ( pageElement , args ) ) ) ; element . clear ( ) ; if ( DriverFactory . IE . equals ( Context . getBrowser ( ) ) ) { final String javascript = "arguments[0].value='" + path + "';" ; ( ( JavascriptExecutor ) getDriver ( ) ) . executeScript ( javascript , element ) ; } else { element . sendKeys ( path ) ; } } catch ( final Exception e ) { new Result . Failure <> ( e . getMessage ( ) , Messages . format ( Messages . getMessage ( Messages . FAIL_MESSAGE_UPLOADING_FILE ) , path ) , true , pageElement . getPage ( ) . getCallBack ( ) ) ; } } else { logger . debug ( "Empty data provided. No need to update file upload path. If you want clear data, you need use: \"I clear text in ...\"" ) ; } }
Updates a html file input with the path of the file to upload .