简体   繁体   中英

python selenium element not interactable error

I have two input texts

<input id="info.route.waypointSuggest.input0" title="search input1" class="input" type="text" autocomplete="off">
<input id="info.route.waypointSuggest.input1" title="search input2" class="input" type="text" autocomplete="off">

and while using Python Selenium, I accessed each text element and gave out dynamic input values

starting_point_path = '//*[@id="info.route.waypointSuggest.input0"]'
starting_point_element = web.find_elements_by_xpath(starting_point_path)
starting_point = input('first\n')
starting_point_element[0].send_keys(starting_point)
starting_point_element[0].submit()
time.sleep(3)
destination_path = '//*[@id="info.route.waypointSuggest.input1"]'
destination_element = web.find_elements_by_xpath(destination_path)
destination = input('second\n')
destination_element[0].send_keys(destination)
destination_element[0].submit()
time.sleep(3)

With the provided code above, I am able to change the first input text value, but not the second one. This code used to work fine, but it is no longer working and I don't understand what made such change. Instead, it is now returning

selenium.common.exceptions.ElementNotInteractableException: Message: element not interactable
  (Session info: chrome=80.0.3987.132)

I confirmed that both the first and second input element is accessible, by printing out elements title. So far, I tried setAttribute, executeScript... but none of them worked (or I did some wrongs) (Maybe, it might do something with google chrome auto-updates? it is only thing I can think of right now, )

So here is what I have done to solve this issue, Main issue here was (I assume) bad/low internet connections, I added

WebDriverWait(web, 4).until(EC.visibility_of_element_located((By.XPATH, destination_path)))

It is still weird that while starting_point_element caused no problem at all, destination input was the only one that caused the problem. I also tried with doing nothing with starting point input element and work only with destination point input, destination still caused a problem. In reverse (work with starting point only and nothing with destination point), it worked fine. However, after finding a better internet connection, and adding WebDriverWait code as above, I was able to solve the problem, but this seems to be only a temporary solution. Any additional suggestions are welcome.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM