'I unable to get list of elements & list size? After entering "Gorav" in google search box

Console Error log is given below

SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder". SLF4J: Defaulting to no-operation (NOP) logger implementation SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details. 1650804898952 geckodriver INFO Listening on 127.0.0.1:64899 1650804899967 mozrunner::runner INFO Running command: "C:\Program Files\Mozilla Firefox\firefox.exe" "--marionette" "--remote-debugging-port" "54286" "-no-remote" "-profile" "C:\Users\gorav\AppData\Local\Temp\rust_mozprofile0NSaWO" 1650804900257 Marionette INFO Marionette enabled console.warn: SearchSettings: "get: No settings file exists, new profile?" (new NotFoundError("Could not open the file at C:\Users\gorav\AppData\Local\Temp\rust_mozprofile0NSaWO\search.json.mozlz4", (void 0))) DevTools listening on ws://localhost:54286/devtools/browser/03ef91a7-9e1e-4c23-899c-76257a8cced3 1650804902076 Marionette INFO Listening on port 53496 1650804902128 RemoteAgent WARN TLS certificate errors will be ignored for this session Apr 24, 2022 6:25:02 PM org.openqa.selenium.remote.ProtocolHandshake createSession INFO: Detected dialect: W3C List Size- 0 1650804904576 CDP ERROR Invalid browser preferences for CDP. Set "fission.webContentIsolationStrategy"to 0 and "fission.bfcacheInParent" to false before Firefox starts. Apr 24, 2022 6:25:04 PM org.openqa.selenium.devtools.CdpVersionFinder findNearestMatch INFO: Found exact CDP implementation for version 85 1650804904596 Marionette INFO Stopped listening on port 53496

###!!! [Parent][PGPUParent] Error: RunMessage(msgname=PGPU::Msg_ShutdownVR) Channel closing: too late to send/recv, messages will be lost

```
package com.test;

import java.util.List;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;

public class GetListelements {
static WebDriver driver;
    public static void main(String[] args) throws InterruptedException 
    {
        System.setProperty("webdriver.gecko.driver","C:\\Users\\gorav\\Downloads\\New folder\\geckodriver.exe");
        driver = new FirefoxDriver();
        driver.get("https://www.google.com/");
        WebElement entertext = driver.findElement(By.xpath("//input[@class='gLFyf gsfi']"));
        entertext.sendKeys("Gorav");                          
            [enter image description here][1]
        List<WebElement> list= driver.findElements(By.xpath("//ul//div//ul//li[@data-view-type='1']"));
        //List<WebElement> list= driver.findElements(By.xpath("//ul//li[@role='presentation']"));
        Thread.sleep(1000);
        System.out.println("List Size- " +list.size());
        
        for(WebElement b:list)
        {
            String Str=b.getText();
            System.out.println(Str);
        }
        driver.close();
    }
}
```


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source