reteps / kbot

A kahoot bot that correctly answers questions.
81 stars 30 forks source link

Selenium TimeoutException:While Playing #10

Closed danielkp1234 closed 5 years ago

danielkp1234 commented 5 years ago

So Here is the stacktrace Traceback (most recent call last): File "C:\Users\danil\OneDrive\Desktop\danielkahootbot-master\kahootlib.py", line 77, in bot_answer waitForItem(driver, "div#app",timeout=20) File "C:\Users\danil\OneDrive\Desktop\danielkahootbot-master\kahootlib.py", line 13, in waitForItem WebDriverWait(driver, timeout).until(expected_conditions.visibility_of_element_located((By.CSS_SELECTOR, css))) File "C:\Users\danil\AppData\Local\Programs\Python\Python37\lib\site-packages\selenium\webdriver\support\wait.py", line 80, in until raise TimeoutException(message, screen, stacktrace) selenium.common.exceptions.TimeoutException: Message: During handling of the above exception, another exception occurred: Traceback (most recent call last): File "kbot", line 23, in kahootlib.start_bot(sys.argv[2],NAME,colors) File "C:\Users\danil\OneDrive\Desktop\danielkahootbot-master\kahootlib.py", line 67, in start_bot bot_answer(driver,colors) File "C:\Users\danil\OneDrive\Desktop\danielkahootbot-master\kahootlib.py", line 80, in bot_answer except selenium.common.exceptions.TimeoutException: NameError: name 'selenium' is not defined

for what I can understand I timeouts and then does not restart so when playing kahoot when I have like answered like 2 questions i just get that stacktrace and it does not run anymore isnt it just needing to catch the exception???

reteps commented 5 years ago

Will look into it this later. Selenium May have renamed the exception I am trying to catch

danielkp1234 commented 5 years ago

@reteps now it just keeps skipping the question like while the teachers are waiting in between questions it just keeps skipping

reteps commented 5 years ago

Fixed

danielkp1234 commented 5 years ago

@reteps Still geting the timeout exception¨ the code is now that u changed it except ElementNotVisibleException:

but now i have problem with Traceback (most recent call last): File "kbot", line 23, in kahootlib.start_bot(sys.argv[2],NAME,colors) File "C:\Users\danil\OneDrive\Desktop\danielkahootbot-master\kahootlib.py", line 66, in start_bot bot_answer(driver,colors) File "C:\Users\danil\OneDrive\Desktop\danielkahootbot-master\kahootlib.py", line 76, in bot_answer waitForItem(driver, "div#app",timeout=20) File "C:\Users\danil\OneDrive\Desktop\danielkahootbot-master\kahootlib.py", line 13, in waitForItem WebDriverWait(driver, timeout).until(expected_conditions.visibility_of_element_located((By.CSS_SELECTOR, css))) File "C:\Users\danil\AppData\Local\Programs\Python\Python37\lib\site-packages\selenium\webdriver\support\wait.py", line 80, in until raise TimeoutException(message, screen, stacktrace) selenium.common.exceptions.TimeoutException: Message:

its happing while waiting between questions

reteps commented 5 years ago

how long is the wait between questions?

danielkp1234 commented 5 years ago

like one or two min it really depends

danielkp1234 commented 5 years ago

cant u just set the waitforitem timeout to 1000 ?

reteps commented 5 years ago

ok. So it is timing out after 30 seconds. I can add an option to change the default timeout period, because I have never seen a question that long.

danielkp1234 commented 5 years ago

yeah in school the teachers some times tell us about a question after we have answeared thats why

danielkp1234 commented 5 years ago

what would the effect be if you just removed the timeout ????

reteps commented 5 years ago

I added an option for changing the timeout to the KBOT file.

danielkp1234 commented 5 years ago

Thanks

reteps commented 5 years ago

change it to whatever value you need

danielkp1234 commented 5 years ago

would changeing the value to 300 have a bad side effect

reteps commented 5 years ago

I don't believe so. Initially I was using that value to check for if a question was skipped, but now it only checks how long to wait before skipping over a question. I now catch an elementnotvisible to check for skips.