0
votes

I am working in python using selenium and web driver

from selenium import webdriver
from selenium.webdriver.common.keys import Keys

path="E:\Allah Kareem HelpmeGuid me\chromedriver.exe"
driver= webdriver.Chrome(path)
driver.get("https://lsg3.nlm.nih.gov/webapps/WebTc.2011/jsp/jdi/vJdi.jsp")

search=driver.find_element_by_name('IN_TERM ')
print(search)
search.send_keys("Glutathione S-transferase-dependent"+Keys.ENTER)
search.send_keys(Keys.RETURN)

driver.quit()

but I got error

Traceback (most recent call last): File "E:\Guide_me\selenum.py", line 9, in search=driver.find_element_by_name('IN_TERM ') File "E:\Allah Kareem HelpmeGuid me\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 496, in find_element_by_name return self.find_element(by=By.NAME, value=name) File "E:\Allah Kareem HelpmeGuid me\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 978, in find_element 'value': value})['value'] File "E:\Allah Kareem HelpmeGuid me\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 321, in execute self.error_handler.check_response(response) File "E:\Allah Kareem HelpmeGuid me\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 242, in check_response raise exception_class(message, screen, stacktrace) selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"css selector","selector":"[name="IN_TERM "]"} (Session info: chrome=86.0.4240.75)

please check my code and error input web page contain only one input and then GO will perform and result will appear in text area thanks in advance

2
Are you sure that i) The element has the name IN_TERM ? and ii) There is a space after IN TERM ? If not -- try removing the space at driver.find_element_by_name('IN_TERM ")Somenath Sinha
Yeah...It should be 'IN_TERM' instead of 'IN_TERM '. I have mentioned the same in my answer.Sushil

2 Answers

0
votes

You have added an extra space at the end of the element's name. Change this line:

search=driver.find_element_by_name('IN_TERM ')

To this:

search=driver.find_element_by_name('IN_TERM')
0
votes

Yes thanks for replay you Its only due to one space after IN_TERM

search=driver.find_element_by_name('IN_TERM')