Print names of all Facebook friends | Selenium Forum
Y
Yousuf Syed Posted on 22/07/2022

I have the following test case in order to get the list of friends on Facebook.

public class FacebookFriends extends TestBase {
@Test
public void getFacebookFriends() {
WebDriver driver = launchBrowser("chrome");
driver.get("https://www.facebook.com");
driver.findElement(By.id("email")).sendKeys("test@gmail.com");
driver.findElement(By.id("pass")).sendKeys("testpassword");
driver.findElement(By.name("login")).submit();

//span[contains(text(),'Friends')]
WebElement e = driver.findElement(getObjectLocator("friends_xpath"));
e.click();

e = driver.findElement(getObjectLocator("allFriends_xpath"));
e.click();

List<WebElement> friendsList = driver.findElements(getObjectLocator("friendsList_xpath"));
System.out.println("My friends' list size is: " + friendsList.size());

}

}
*************project.properties*****************
friends_xpath=//span[contains(text(),'Friends')]
allFriends_xpath=//span[contains(text(),'All friends')]
friendsList_xpath=//span[@class='d2edcug0 hpfvmrgz qv66sw1b c1et5uql lr9zc1uh gfeo3gy3 a3bd9o3v lrazzd5p oo9gr5id']
************************************************
The output on the console displays: My friends' list size is: 20
However, in the left side frame in Facebook shows that I have "188 friends".
What should I do in order to get the correct size of 188 friends?

Y
Yousuf Syed Replied on 30/07/2022

Please ignore the above question. The same scenario is discussed in a later video.