2

I'm able to find the element by class name that this resides in but I'm not sure how to select it itself and send text to it.

Current Code:

editor = browser.find_element_by_class_name('editor')
editor.send_keys('text')

Element I'm trying to select:

<input type="text" tabindex="103" placeholder="" style="width: 444px;">

Error:

File "C:\Python35\lib\site-packages\selenium\webdriver\remote\webelement.py", line 347, in send_keys
    self._execute(Command.SEND_KEYS_TO_ELEMENT, {'value': keys_to_typing(value)})
  File "C:\Python35\lib\site-packages\selenium\webdriver\remote\webelement.py", line 494, in _execute
    return self._parent.execute(command, params)
  File "C:\Python35\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 236, in execute
    self.error_handler.check_response(response)
  File "C:\Python35\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 192, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: unknown error: cannot focus element
  (Session info: chrome=55.0.2883.87)
  (Driver info: chromedriver=2.27.440174 (e97a722caafc2d3a8b807ee115bfb307f7d2cfd9),platform=Windows NT 10.0.14393 x86_64)

2 Answers 2

4

Element that you try to select doesn't have class name. Try

from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC

editor = WebDriverWait(browser, 10).until(EC.visibility_of_element_located((By.XPATH, '//input[@type="text"][@tabindex="103"]')))
editor.send_keys('text')
Sign up to request clarification or add additional context in comments.

5 Comments

When I tried I received this error: selenium.common.exceptions.ElementNotVisibleException: Message: element not visible
I got this error and searched it but no dice: editor = WebDriverWait(browser, 10).until(EC.visibility_of_element_located((By.XPATH, '//input[@type="text"][@tabindex="103"]'))) File "C:\Python35\lib\site-packages\selenium\webdriver\support\wait.py", line 80, in until raise TimeoutException(message, screen, stacktrace) selenium.common.exceptions.TimeoutException: Message:
if to replace '//input[@type="text"][@tabindex="103"]' with just '//input[@type="text"]'?
Exception ignored in: <bound method Service.__del__ of <selenium.webdriver.chrome.service.Service object at 0x01931230>> Traceback (most recent call last): File "C:\Python36\lib\site-packages\selenium\webdriver\common\service.py", line 173, in __del__ File "C:\Python36\lib\site-packages\selenium\webdriver\common\service.py", line 149, in stop File "C:\Python36\lib\site-packages\selenium\webdriver\common\service.py", line 120, in send_remote_shutdown_command ImportError: sys.meta_path is None, Python is likely shutting down
It seem to be not related to current issue. ImportError is something different. Did you make any changes to your script?
0

Try with editor.click() before editor.send_keys('text') and see if it works.

2 Comments

The cursor popped up in the correct area but the same error message came up.
Did you maybe try this with Firefoxdriver or IEdriver?

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.