1

I have this code:

from selenium import webdriver
#open Firefox
driver=webdriver.Firefox()
#open arbitrary ur
url="https://www.scopus.com/search/form.uri?display=basic"
driver.get(url)
#click on input  element for writing special word
search=driver.find_element_by_xpath("""//*[@id="txtBoxSearch"]/label""")
search.click()
driver.implicitly_wait(5)
#write your special word
search.send_keys("internet of things")
driver.implicitly_wait(5)
search.submit()

Error stack trace :

raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.ElementNotInteractableException: Message: Element <label class="inputTextLabel activeInputLabel"> is not reachable by keyboard

The url is opened and x-path is identified, but send_keys doesn't work. What should I do?

undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
  • 2
    No element with `id="txtBoxSearch"` in the webpage.. – Arount Feb 22 '18 at 09:56
  • You must have subscribe for going to the url. –  Feb 22 '18 at 10:14
  • 1
    That does not help to answer you – Arount Feb 22 '18 at 10:15
  • I think you have too many quotes there: `find_element_by_xpath("""//*[@id="txtBoxSearch"]/label""")`. I recomend you to chage for this one: `find_element_by_xpath("//*[@id='txtBoxSearch']/label")` – j.barrio Feb 22 '18 at 10:42
  • It is correct 100%. –  Feb 22 '18 at 11:20
  • You're trying to send keys to `label` node while you should handle `input` node... try `search = driver.find_element_by_xpath("""//*[@id="txtBoxSearch"]/input[@type="text"]""")` instead – Andersson Feb 22 '18 at 12:03
  • That is great. my problem is solved. Thank your trying. Please add your comment as an answer to vote it. –  Feb 22 '18 at 12:07
  • @hamed_baziyad, note that there is no need to use `driver.implicitly_wait(5)` several times - it should be called once after webdriver instance creation and it will work for the rest of code – Andersson Feb 22 '18 at 21:11

1 Answers1

1

label node is just a "name" of the input field, you cannot send keys to this element. You need to handle text input node instead.

Assuming HTML looks like

<div id='txtBoxSearch'>
    <label>Search</label>
    <input type='text'>
</div>

You can try

search = driver.find_element_by_xpath("""//*[@id="txtBoxSearch"]/input[@type="text"]""")
Andersson
  • 51,635
  • 17
  • 77
  • 129