1

I tried uploading a photo in Indyarocks.com and got an error

org.openqa.selenium.ElementNotVisibleException: Element is not currently visible and so may not be interacted with.

I inserted

((JavascriptExecutor) driver).executeScript("arguments[0].click();", X);

since i got ElementNotVisibleException and was not able to click on the upload photo box in the frame.Worked fine after the insertion. Displayed a windows pop up to choose file from system and i am not able to choose the file with my code as below:

My code looks like this:

driver.findElement(By.xpath("//input[@id='pic_up_click']")).click();        
frames= driver.findElements(By.tagName("iframe"));
System.out.println(frames.size());          
Thread.sleep(5000L);

WebElement X = driver.findElement(By.xpath("//*[@id='uploadfeedpic' or  @type='file' or @name='uploadfile']"));
((JavascriptExecutor) driver).executeScript("arguments[0].click();", X);
Thread.sleep(5000L);        
X.sendKeys("C:\\pics\\kesar\\24082011323.jpg");
Joe
  • 15,205
  • 8
  • 49
  • 56
  • 2
    Don't click the actual `Browse` button. Just use `.sendKeys` to send the file path to it. – Arran Jun 07 '13 at 10:11
  • Possible duplicate of [How to upload file using Selenium WebDriver in Java](https://stackoverflow.com/questions/16896685/how-to-upload-file-using-selenium-webdriver-in-java) – MikeJRamsey56 Jun 23 '17 at 18:38

0 Answers0