Python Selenium, but I get an error.
Is the error caused by using ('id') as the username id selector?
How should I specify in this case?
Please tell me who you understand.
Thank you.

driver = webdriver.Chrome ("Selenium/chromedriver.exe")

elem_username = driver.find_element_by_id ('id')
elem_username.send_keys ('**')
elem_password = driver.find_element_by_id ('passwd')
elem_password.send_keys ('**')
driver.find_element_by_class_name ('login-button'). click ()

NoSuchElementException: Message: no such element: Unable to locate element: {"method": "css selector", "selector": "[id =" id "]"}
(Session info: chrome = 78.0.3904.108)

  • Answer # 1

    If you look closely at the source
    elem_username = not driver.find_element_by_id ('id')
    elem_username = driver.find_element_by_name ('id')
    Thank you very much.

  • Answer # 2

    find_element_by_id ('id')is no problem for<~~~ id = "id" ~~>

    The error is that the element does not exist at that time.
    Stop running and check with your browser developer tools.

    Or, use a method that waits for that element.