I'm currently creating a selenium bot to create a bot for entering in kahoots. The problem is when i enter the code and I try to automatically write the nickname in the textfield the script gives me this error:
Traceback (most recent call last):
File "/Users/marcovinciguerra/Github/Python/Selenium _Kahoot_bot/a.py", line 32, in <module>
test_a()
File "/Users/marcovinciguerra/Github/Python/Selenium _Kahoot_bot/a.py", line 24, in test_a
driver.find_element(By.ID, "nickname").click()
File "/Users/marcovinciguerra/opt/anaconda3/envs/envpython/lib/python3.10/site-packages/selenium/webdriver/remote/webdriver.py", line 976, in find_element
return self.execute(Command.FIND_ELEMENT, {
File "/Users/marcovinciguerra/opt/anaconda3/envs/envpython/lib/python3.10/site-packages/selenium/webdriver/remote/webdriver.py", line 321, in execute
self.error_handler.check_response(response)
File "/Users/marcovinciguerra/opt/anaconda3/envs/envpython/lib/python3.10/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":"[id="nickname"]"}
(Session info: chrome=104.0.5112.79)
The code of the script is the following:
def test_a():
driver.get("https://kahoot.it/")
driver.set_window_size(1512, 945)
driver.find_element(By.ID, "game-input").click()
driver.find_element(By.ID, "game-input").send_keys("14988")
driver.find_element(By.ID, "game-input").send_keys(Keys.ENTER)
driver.find_element(By.ID, "nickname").click()
driver.find_element(By.ID, "nickname").send_keys("vinci0000")
driver.find_element(By.CSS_SELECTOR, ".sc-jJEJSO").click()
element = driver.find_element(By.CSS_SELECTOR, ".sc-jJEJSO")
actions = ActionChains(driver)
actions.move_to_element(element).perform()
if name == "main": test_a()
And the textfield i wanna enter the text is the following:
<input name="nickname" type="text" placeholder="Nickname" maxlength="15" id="nickname" data-functional-selector="username-input" class="sc-fWSCIC hEgquS" autocomplete="off" dir="ltr" value="jjj">