Djaenk / zyBooks-Activity-Completer

Python 3 script which automatically completes assigments on the zyBooks platform.
MIT License
16 stars 14 forks source link

Canvas Connection Popup Causes Crash #11

Closed JartanFTW closed 3 years ago

JartanFTW commented 3 years ago

I was experimenting with this program on a ZyBook that is attached to Canvas. Often a popup will appear saying that grades won't be put into Canvas without going to ZyBook through Canvas. That's all fine and dandy, except it causes zyBooks-Activity-Completer to crash.

I did a small bit of fiddling and found a solution- albeit temporary and for my own personal purposes, but worth putting here in-case you want to incorporate a proper fix.

Attached I've added a zip folder simply containing a modifier complete.py (since GitHub wouldn't let me just upload the .py). See attached complete.py lines 109 to 113, and also line 8 for the surprisingly minor changes I made to get this working for me.

complete.zip

JartanFTW commented 3 years ago

After playing around with this a bit more, a seemingly much more effective solution is to just add this small block of code to the top of completeParticipationActivities

try:
    driver.find_element_by_xpath("//*[@class='zb-button secondary raised ember-view']").click()
except NoSuchElementException:
    pass

likewise you need to also import the above error:

from selenium.common.exceptions import NoSuchElementException

This pretty effectively works, because the Canvas popup only occurs at the start of a chapter, not randomly throughout it.

Djaenk commented 3 years ago

Fixed implemented. See commit 382bf13e551d8f9c3d5665f2e800de55d3c54128.