Unable to find the XPath for google home page - Search box.
Refer the image, we have to write the Xpath for Google textarea or search box
driver.findElement(By.Xpath(//input[@id='input'])).sendkeys("testing");
Once we type the text in the search area, google will provide the suggestion based on text, we have to print the console suggested text.
I tried multiple ways to find the XPath but Match element not showing even element presence on webpage.
By.Id('input');
By.Xpath("//input[@id='input']");
By.cssSelector("input#input");
By.Xpath("/html/body/ntp-app//div/div[1]/ntp-realbox//div/inputb");
But Element not finding.
You can't get it, because element is placed in shadow-root, which is placed in shadow-root.
Example of code in Java that reaches your input
WebElement shadowRoot = driver.findElement(new By.ByTagName("ntp-app")); ;
JavascriptExecutor js = (JavascriptExecutor) driver;
WebElement insideShadowInput = (WebElement) js.executeScript("return arguments[0].shadowRoot.querySelector('ntp-realbox').shadowRoot.querySelector('#input');", shadowRoot);
insideShadowInput.sendKeys("testing");