Unable to post status on fB using appium!


I am trying to run this script to post to facebook status but when i run the script first time it ran sucessfully but 2nd time onwards it doesnt ,i dont know why it happens but i am observing this behaviour from the time i started learning writing appium scripts to automate fb login n status posting.

Here is my script:

package com.appium.facebook.androiduiselector;

import io.appium.java_client.android.AndroidDriver;
import io.appium.java_client.android.AndroidKeyCode;

import java.net.MalformedURLException;
import java.net.URL;
import java.util.concurrent.TimeUnit;

import org.junit.Test;
import org.openqa.selenium.remote.DesiredCapabilities;

public class FacebookLoginTest {


public void testLoginFB() throws MalformedURLException, InterruptedException
DesiredCapabilities capabilities = new DesiredCapabilities() ;
capabilities.setCapability(“deviceName”,“Nexus 6” );
capabilities.setCapability(“appActivity”, “com.facebook.katana.LoginActivity”);
AndroidDriver driver = new AndroidDriver (new URL (“”), capabilities) ;

//automating login procedure to FB
driver.findElementByAndroidUIAutomator("new UiSelector().resourceId(\"com.facebook.katana:id/login_username\")").sendKeys("[email protected]");
driver.findElementByAndroidUIAutomator("new UiSelector().resourceId(\"com.facebook.katana:id/login_password\")").click();
driver.findElementByAndroidUIAutomator("new UiSelector().resourceId(\"com.facebook.katana:id/login_password\")").sendKeys("XXXXXX");
driver.findElementByAndroidUIAutomator("new UiSelector().resourceId(\"com.facebook.katana:id/login_login\").text(\"LOG IN\")").click();
driver.findElementByAndroidUIAutomator("new UiSelector().resourceId(\"com.facebook.katana:id/dbl_on\").text(\"OK\")").click();

driver.findElementByAndroidUIAutomator("new UiSelector().resourceId(\"com.facebook.katana:id/feed_composer_status_button\").text(\"STATUS\")").click();
// driver.findElementByAndroidUIAutomator("new UiSelector().resourceId(\"com.facebook.katana:id/status_text\")").click();
driver.findElementByAndroidUIAutomator("new UiSelector().resourceId(\"com.facebook.katana:id/status_text\").text(\"What's on your mind?\")").sendKeys("hello");
driver.findElementByAndroidUIAutomator("new UiSelector().resourceId(\"com.facebook.katana:id/composer_primary_named_button\").description(\"Post\")").click();



Appium log is same:unable to locate the element
The script is stopping at this line
driver.findElementByAndroidUIAutomator(“new UiSelector().resourceId(“com.facebook.katana:id/feed_composer_status_button”).text(“STATUS”)”).click();

Maybe the id or text of this element changes when a status has previously been posted ?

Did you really just post your Facebook username and password on a public message board?

Yeah…Please hide those when posting from next time on wards !!!

@907howard, And if you have resource id’s , please use giving id directly to By class in Selenium i.e.,


Have a try…We’re giving generally by this way !!


Oh yeh my mistake, I will try running the script as you have mentioned

Hi @bhaskar: My question was I am unable to post status on FB ,meaning My script is running fine only upto opening the FB dash board ,after that its not able to locate the ‘Status’ button on FB profile page,please help me some one

Remove the password in your other topics as well and change it on facebook of course.
Did you check my suggestion about element changing when status was previously posted ?

Hi @Alexis yes i have removed the passowords although it was a test id

The problem is some times script is executing perfectly and facebook status gets posted and sometimes srcipts fails indicating that unable to locate the element,why doest that happens,how a beginner like me will be so sure while automating a app that test cases results will be true

Check with Automation viewer if the element’s id or text changes when a status has been previously posted compared to when no status is posted.

Ok now the script is working fine , i dont know its kind of random.

Hi -

wat we will do after clicking on login button:-
driver.findElementByAndroidUIAutomator(“new UiSelector().resourceId(“com.facebook.katana:id/login_login”).text(“LOG IN”)”).click();

after executing this line of code, there is another screen which needs affirmation of facebook login for my app.

“Continue as XXXX”

app will receive:

  1. your public profile

  2. Your friend list

  3. email address


now how i can check when OK button clicked ?
or what is id of that button ?

Can you help me. please

HI kashaf are you trying from your mobile or or on pc browser to loging on facebook website?