switch_to_alert() calls ->alert(). alert() doesnt exists in the class, I believe its a typo. Remove the line and it all works as expected.
Merge pull request #1 from guywebber-public/master

switch_to_alert function error