0

css code

How to find the web chat input message text for above. I tried few of options but none of them seems to work

driver.find_elements_by_xpath("/html/body/app-root/bot-component/div[2]/div/div[2]/div[2]/form")
driver.find_element_by_xpath("//input[type='text]")
driver.find_element_by_xpath("//*[type='text]")
DebanjanB
  • 118,661
  • 30
  • 168
  • 217
Mandy1999
  • 9
  • 2

3 Answers3

0

You should get value of attribute. Something like this.

driver.find_element_by_xpath("//input[type='text]").get_attribute("type")

Random1k11
  • 435
  • 3
  • 13
0

You want to find the value of Data=id?

        element = driver.find_element_by_xpath("//input[@type='text']").get_attribute("data-id")
        print(element)

or you want to get the xpath locator on that tag?

    driver.find_element_by_xpath("//input[@data-id='webchat-sendbox-input']")

try putting this above the code:

    driver.switch_to.default_content()
OMS
  • 1
  • 5
0

To locate the <input> tag, you have to induce WebDriverWait for the element_to_be_clickable() and you can use either of the following Locator Strategies:

  • Using CSS_SELECTOR:

    element = WebDriverWait(browser, 20).until(EC.element_to_be_clickable((By.CSS_SELECTOR, "div[data-id='webchat-sandbox-input'][@aria-label='Type your message']")))
    
  • Using XPATH:

    element = WebDriverWait(browser, 20).until(EC.element_to_be_clickable((By.XPATH, "//input[@data-id='webchat-sandbox-input' and @aria-label='Type your message']")))
    
DebanjanB
  • 118,661
  • 30
  • 168
  • 217