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.