2

I have entered correct from the developer tool xpath still it is not macthing element. How can find the xpath or other locator for google search box.

HTML:

<input id="input" type="search" autocomplete="off" spellcheck="false" role="combobox" ariacontrols="matches" placeholder="Search Google or type a URL" aria-expanded="false" aria-live="polite">

Relative Xpath:

/html/body/ntp-app/div/div[2]/ntp-realbox/div/input

Absolute Xpath:

//*[@id="input"]

Snapshot A: enter image description here

Snapshot B:

enter image description here

undetected Selenium
  • 183,867
  • 41
  • 278
  • 352

2 Answers2

0

I believe you may simply look for the textarea tag, as seen in the Xpath below.

//textarea[@type="search"]

google search page screenshot

MD Kawsar
  • 313
  • 2
  • 12
0

Given the snapshot:

snapshot

You are trying to locate the search box of the default chrome browser page opened manaually, which won't be available within Selenium driven ChromeDriver initiated Browsing Context


Ideally you should access an url. If you access the url https://www.google.com/ you can locate the search box using the following locator strategy:

  • Code block:

    driver.get("https://www.google.com/")
    WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.NAME, "q"))).send_keys("BRAJESH KUMAR")
    
  • Browser snapshot:

BRAJESH KUMAR

undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
  • 1
    Yes i was tring to find the xpath of default chrome browser page opened manaually, which won't be available within Selenium driven ChromeDriver initiated google-chrome Browsing Context. Thanku so much for your kindness support – BRAJESH KUMAR Aug 10 '23 at 15:08