Issue with AttributeError: 'WebDriver' object has no attribute 'manage'

19,376

This is answer to an original question:

To fix your immediate problem, use

driver.implicitly_wait(10)

Manual is there

However you are probably going in a wrong direction altogether. Instead, try to use the WebDriverWait module.

from selenium.webdriver.support.ui import WebDriverWait

For example:

from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC

#...

footer = WebDriverWait(driver, 10).until(EC.visibility_of_element_located(
   (By.CSS_SELECTOR, ".b-footer__divider"))
)

Update for the updated part of question:

I'm trying to send a key to the comment box on youtube. I removed some code, I am currently running this code.

As I suspected, you don't need the implicitly_wait function at all there.

  • I have reviewed the YouTube page. Your first step is right - you are locating "Add a public comment..." box and clicking on it.

  • I skipping the implicitly_wait call - it doesn't affect nothing there.

  • At the next step you are trying to send keystrokes into the same box you found and clicked. This is wrong. Though they look exactly the same, you were clicking on the element with id simplebox-placeholder, but once clicked that element becomes invisible, and the same looking element with id contenteditable-textarea is ready to get your input.

In a simple approach, you should locate this element and send keystrokes into it:

commentr = driver.find_element_by_id("contenteditable-textarea")
commentr.click()
commentr.send_keys("HELO")

But when you are clicked to simplebox-placeholder, it could take some time for page to perform the necessary actions and make the contenteditable-textarea visible and clickable. The approach below will allow you to avoid exception if an element is not ready yet:

from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC

commentr = WebDriverWait(driver,10).until(EC.element_to_be_clickable( (By.ID, 'contenteditable-textarea') ))
commentr.click()
commentr.send_keys("HELO")
  • Finally, locate the "Comment" button and click it to submit your comment. Here you can use simplified approach, because the "Comment" button is already ready:

driver.find_element_by_id("submit-button").click()

Overall, your code could look like:

from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC

driver.find_element_by_id("simplebox-placeholder").click()

commentr = WebDriverWait(driver,10).until(EC.element_to_be_clickable( (By.ID, 'contenteditable-textarea') ))

commentr.click()
commentr.send_keys("HELO")
driver.find_element_by_id("submit-button").click()
Share:
19,376
justloookingforlove
Author by

justloookingforlove

Updated on June 16, 2022

Comments

  • justloookingforlove
    justloookingforlove almost 2 years

    My code:

    commentr = driver.find_element_by_id("simplebox-placeholder")
    commentr.click()
    
    driver.execute_script("document.getElementById('simplebox- 
    placeholder').value = 'your comment text here';")
    driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
    commentr.send_keys("HELO")
    

    My error:

    Traceback (most recent call last): File "C:\Users\weqwwg\Desktop\python\Game.py", line 77, in driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS); AttributeError: 'WebDriver' object has no attribute 'manage'

    I'm trying to send a key to the comment box on youtube. I removed some code, I am currently running this code.

    commentr = driver.find_element_by_id("simplebox-placeholder")
    commentr.click()
    driver.implicitly_wait(10)
    commentr.send_keys("HELO")
    

    This is the error I'm getting:

    Traceback (most recent call last):
      File "C:\Users\Brandsdo\Desktop\python\Game.py", line 76, in <module>
        commentr.send_keys("HELO")
      File "C:\Users\Braasdasndo\AppData\Local\Programs\Python\Python37-32\lib\site-packages\selenium\webdriver\remote\webelement.py", line 479, in send_keys
        'value': keys_to_typing(value)})
      File "C:\Users\Brsadasdando\AppData\Local\Programs\Python\Python37-32\lib\site-packages\selenium\webdriver\remote\webelement.py", line 633, in _execute
        return self._parent.execute(command, params)
      File "C:\Users\Braasdasndo\AppData\Local\Programs\Python\Python37-32\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 321, in execute
        self.error_handler.check_response(response)
      File "C:\Users\Braasdando\AppData\Local\Programs\Python\Python37-32\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 242, in check_response
        raise exception_class(message, screen, stacktrace)
    selenium.common.exceptions.ElementNotInteractableException: Message: element not interactable
      (Session info: chrome=73.0.3683.103)
      (Driver info: chromedriver=73.0.3683.68 (47787ec04b6e38e22703e856e101e840b65afe72),platform=Windows NT 10.0.17763 x86_64)
    

    UPDATED PART OF CODE

    driver.find_element_by_id("simplebox-placeholder").click()
    
    commentr = WebDriverWait(driver,10).until(EC.element_to_be_clickable( (By.ID, 'contenteditable-textarea') ))
    
    commentr.click().send_keys("HELO")
    driver.find_element_by_id("submit-button").click()
    

    THIS IS THE ERROR

    Traceback (most recent call last): File "C:\Users\Desktop\python\Game.py", line 74, in commentr.click().send_keys("HELO") AttributeError: 'NoneType' object has no attribute 'send_keys'

    • Sergey Nudnov
      Sergey Nudnov about 5 years
      What is your idea this timeout is going to do if set? Could you please explain directly in question. I feel, you use a wrong approach. And to fix your immediate problem, use driver.implicitly_wait(10). See there
    • JeffC
      JeffC about 5 years
      The problem is that your driver.manage... line is Java but you are writing in python. You need to use the python equivalent as Sergey indicated.
  • justloookingforlove
    justloookingforlove about 5 years
    I am still having errors Sergey. I will update the post to show you what is going on.
  • justloookingforlove
    justloookingforlove about 5 years
    I don't understand.
  • Sergey Nudnov
    Sergey Nudnov about 5 years
    @justloookingforlove, you should have sent me a comment when you updated your post. Now it is clear what are you trying to accomplish and what is a problem. Let me update my answer
  • justloookingforlove
    justloookingforlove about 5 years
    Could you explain it as well. I really would like to learn my mistake.
  • Sergey Nudnov
    Sergey Nudnov about 5 years
    @justloookingforlove, when you are updating your question, I don't receive any notifications, but when you are adding a comment - I do. I have just updated my answer, you could have a look.
  • justloookingforlove
    justloookingforlove about 5 years
    Sorry, I just read your most recent update. Upon application, I have gotten an error. I will update my post right now. It is an "AttributeError: 'NoneType' object has no attribute 'send_keys'"
  • Sergey Nudnov
    Sergey Nudnov about 5 years
    @justloookingforlove Apparently, click() function cannot be chained,so use two separately, as in code I updated right now. I hope you will succeed. I'm off till tomorrow
  • justloookingforlove
    justloookingforlove about 5 years
    It worked. Brilliant Sergey. Thank you very much for your time and efforts in helping me!!