Module15: Unable to upload profile pic in fb | Selenium Forum
M
Posted on 12/07/2016
Hi,

I am using below code to upload profile pic on fb


package uploading;

import java.util.concurrent.TimeUnit;

import org.openqa.selenium.By;
import org.openqa.selenium.Keys;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.interactions.Actions;

public class Facebook {

public static void main(String[] args) {
WebDriver driver = new FirefoxDriver();
driver.manage().window().maximize();
driver.manage().timeouts().implicitlyWait(50, TimeUnit.SECONDS);
driver.manage().timeouts().pageLoadTimeout(50, TimeUnit.SECONDS);
driver.get("https://www.facebook.com");
driver.findElement(By.xpath("//*[@id='email']")).sendKeys("****@gmail.com");
driver.findElement(By.xpath("//*[@id='pass']")).sendKeys("*****");
driver.findElement(By.xpath("//*[@id='pass']")).sendKeys(Keys.ENTER);
driver.findElement(By.xpath("//*[@id='pagelet_welcome_box']/ul/li[1]/div/a")).click();

WebElement profileSelector = driver.findElement(By.xpath("//div[@class='fbTimelineProfilePicSelector _23fv']"));
Actions act = new Actions(driver);
act.moveToElement(profileSelector).build().perform();
[color=#FF0000:11le5fjl]
driver.findElement(By.xpath("//html/body/div[1]/div[2]/div[1]/div/div[2]/div[2]/div[2]/div/div[1]/div/div[3]/div/div[2]/div[3]/div/div/div/a/i")).click();[/color:11le5fjl]

//[b:11le5fjl]above line is not able to click on camera button present on profile pic[/b:11le5fjl]

//driver.findElement(By.xpath("//input[@name='file']")).sendKeys("C:\\Test\\xyz.jpg");
//driver.findElement(By.xpath("//input[@name='file']")).click();



}

}

M
Replied on 12/07/2016

i am getting below error

Exception in thread "main" org.openqa.selenium.WebDriverException: Element is not clickable at point (221.5833282470703, 246.23333740234375). Other element would receive the click: <div class="_156p"></div>
Command duration or timeout: 82 milliseconds
Build info: version: '2.53.0', revision: '35ae25b', time: '2016-03-15 16:57:40'
System info: host: 'INBANN0H333571', ip: '135.250.28.62', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0_77'
Driver info: org.openqa.selenium.firefox.FirefoxDriver
Capabilities [{applicationCacheEnabled=true, rotatable=false, handlesAlerts=true, databaseEnabled=true, version=45.2.0, platform=WINDOWS, nativeEvents=false, acceptSslCerts=true, webStorageEnabled=true, locationContextEnabled=true, browserName=firefox, takesScreenshot=true, javascriptEnabled=true, cssSelectorsEnabled=true}]
Session ID: 01e675d4-3416-47d6-9144-812ebe6937d5
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:206)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:158)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:678)
at org.openqa.selenium.remote.RemoteWebElement.execute(RemoteWebElement.java:327)
at org.openqa.selenium.remote.RemoteWebElement.click(RemoteWebElement.java:85)
at uploading.Facebook.main(Facebook.java:29)


M
Replied on 12/07/2016

facebook keeps on changing there interface.

try some other site to upload a picture.