Sign up ×
Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them, it only takes a minute:

I am automating one web application. In that, I have to Automate one module which is file upload. When selenium clicks on upload button of application, in that case window which consist all the file displays. So there I want to go to specific folder , So I can select required file. By default there is no search button is coming in the upload dialogue, if it will be there then I can directly send the file path using sendKeys().

Any way to handle this situation or anyone has faced same kind of issue.

share|improve this question

1 Answer 1

Use below logic to upload file

driver.findElement(By.cssSelector("input[id='sql-file-upload'][type='file']")).sendKeys("/home/test/updaloadThis.jpg");

You can directly send the file absolute path to file upload locator.

share|improve this answer
    
I tried this it is not working – Saurabh Garg Jun 23 at 7:12
    
What is happening if you do like that ? Is that locator correct ? Post your html code for that file upload operation. – Santoshsarma Jun 23 at 7:16
    
<input id="sql-file-upload" class="upload" type="file" name="attachments"> this is the html code for that file upload. I think we can use sendKeys only when search option is visible. – Saurabh Garg Jun 23 at 9:06
    
try with this By.cssSelector("input[id='sql-file-upload'][type='file']"). (I've updated answer) – Santoshsarma Jun 23 at 9:08
    
Still not working – Saurabh Garg Jun 26 at 19:01

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.