I'm trying to scrap WhatsApp using python selenium. I'm trying to find name by locating the search box and typing the name over there. But I'm getting error as Message: Element <div class="gQzdc _3sdhb"> is not reachable by keyboard.

The code is:

from selenium import webdriver as wd
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.support.ui import WebDriverWait as wdw
from selenium.webdriver.support.ui import Select
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
from selenium.common.exceptions import NoSuchElementException
from selenium.common.exceptions import TimeoutException
import base64
import time

print("Scan the QR code then come here.")
browser = input("Enter your fav. browser(Firefox/Chrome): ")
if browser == "Firefox":
    driver = wd.Firefox()  # open firefox
elif browser == "Chrome":
    driver = wd.Chrome()
    print("Choose between Firefox/Chrome.")


    element = wdw(driver, 10).until(

        print("Scan the QR code then proceed.")
        contact_name = input("Enter the contact/group name \nwhose data you want scrap: ")

            user = driver.find_element_by_xpath('//span[@title = "{}"]'.format(contact_name))
        except Exception as e:
            search_box = wdw(driver, 50).until(
                lambda driver : search_box)
            user = driver.find_element_by_xpath('//span[@title = "{}"]'.format(contact_name))
            wdw(driver, 50).until(lambda driver: user)

    except Exception as e:


I get to know that WebDriverWait will be helpful but I don't know how to use it as I don't think no new elements appear when we select the search button.

1 Answer 1


Use this locator instead:

class='_2S1VP copyable-text selectable-text'

if you open chrome dev tools and goto console tab:

You can jquery expressions there which shows that the locator your using is not editable.

enter image description here

so, if you check the element with class gQzdc . It is not editable.

enter image description here

But, class='_2S1VP copyable-text selectable-text' is editable (giving true)

enter image description here

  • thanks that work. I hv one more doubt. whenver i try to search a name i got an error as Message: Unable to locate element: //span[@title = Name]. what should i do? May 20, 2020 at 16:14
  • @AshutoshDash in console you can use only css locators . And you shoud wrap it with $() , which is the jguery constructor that finds element using the locator we provide .
    – PDHide
    May 20, 2020 at 17:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.