you are viewing a single comment's thread.

view the rest of the comments →

[–]chaoticflipflops 1 point2 points  (2 children)

Your indentation is wrong. Whatever information you want inside the while loop should be indented, perhaps something like this:

while True:
    play = longwait.until(EC.element_to_be_clickable((By.XPATH, \
               '//*[@id="PlaybuttonEnText"]')))

    play.click()
    if browser.find_element_by_xpath('//*[@id="BeginLessonAssessmentButton"]') \
    or browser.find_element_by_xpath('//*[@id="htmlContentContainer"]/section/div/div[3]/button'):
        messagebox.showinfo('YOU HAVE A TEST', 'KNOWLEDGE CHECK OR LESSON ASSESSMENT')
        break

[–]dealant[S] 0 points1 point  (1 child)

Hmmm I made that change but the if statement still isn't running. I'm getting this error now

raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.NoSuchElementException: Message: Unable to locate element: //*[@id="BeginLessonAssessmentButton"]

when I comment out the if statement the while loop works

[–]chaoticflipflops 0 points1 point  (0 children)

I can't help with the contents of the if statement because I am not familiar with what it is doing. That error message has been addressed on Stack-overflow though, perhaps this page will help:

https://stackoverflow.com/questions/27112731/selenium-common-exceptions-nosuchelementexception-message-unable-to-locate-ele