I wrote the below code to check if it is storing the list from chatbox.PlzAdd necessary code to it to do the same. Thnx in advance.
WebDriver driver = new FirefoxDriver();
driver.get("https://www.fb.com");
driver.manage().window().maximize();
driver.findElement(By.xpath(".//*[@id = 'email']")).sendKeys("******");
driver.findElement(By.xpath(".//*[@id = 'pass']")).sendKeys("*******");
driver.findElement(By.xpath(".//*[@type='submit']")).click();
WebDriverWait wait = new WebDriverWait(driver, 60);
wait.until(ExpectedConditions.presenceOfElementLocated(By.xpath("//a[@title='Profile']")));
Thread.sleep(10000);
//This is path for the friends in the chat box, but its saying not able to find element
List<WebElement> friendsOnChatBox = (List<WebElement>) driver.findElement(By.xpath("//li[@class = '_42fz']"));
System.out.println("The No Of Friends in chatbox is: "+ friendsOnChatBox.size());
There is bug in your code Idk how you have executed it.There will be a
ClassCastException
thrown at runtime for the following as you are castingWebElement
toList<WebElement>
.It should befindElements
notfindElement
Any how I've altered the xpath to be more specific and this will do the job neatly