Code trials:
package modules;
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.remote.LocalFileDetector;
import org.openqa.selenium.support.ui.Select;
public class PostUpdating {
public void Execute()
{
WebElement w = LaunchApplication.driver.findElement(By.id("whats-new"));
w.sendKeys("/C:/Users/Public/Pictures/Sample Pictures/Desert.jpg");
Select sel = new Select(LaunchApplication.driver.findElement(By.id("rtSelectPrivacy")));
sel.selectByVisibleText("Public");
Select sel1 = new Select(LaunchApplication.driver.findElement(By.id("whats-new-post-in")));
sel1.selectByVisibleText("My Profile");
LaunchApplication.driver.findElement(By.id("aw-whats-new-submit")).click();
}
}
The html
<div id="whats-new-textarea" style="position: relative;">
<textarea id="whats-new" class="bp-suggestions linkBox" rows="10" cols="50" name="whats-new" style="display: inline-block; height: 50px;"></textarea>
<div id="rtm-drop-files-title">Drop files here</div>
<div class="rtmp-url-scrapper-container">
<img class="rtmp-url-scrapper-loading" src="http://demo.rtcamp.com/rtmedia/wp-content/plugins/buddypress-media/app/assets/admin/img/boxspinner.gif">
<table id="rtmp-url-scrapper" style="display: none;">
<tbody>
<tr>
<td>
<table id="rtmp-url-scrapper-img-holder">
<tbody>
<tr>
<td style="height:100px; overflow:hidden;" colspan="2">
<div id="rtmp-url-scrapper-img">
<img src="">
</div>
</td>
</tr>
<tr>
<td id="" style="width:50%; text-align:right;">
<input id="rtmp-url-prevPicButton" type="button" value="<">
</td>
<td id="" style="width:50%; text-align:left;">
<input id="rtmp-url-nextPicButton" type="button" value=">">
</td>
</tr>
<tr>
<td colspan="2">
<div id="rtmp-url-scrapper-img-count"></div>
</td>
</tr>
</tbody>
</table>
</td>
<td>
I want to insert a image into my text box but when I use Sendkeys and gave the path from my computer but instead of sending the image it is sending the path only into my text box.Also there is a button in my webpage for uploading the picture but when I clicked on button windows dialoge box open. So selenium can't deal with Windows GUI.So Any help how to do this?