added maxRetries to taking a screenshot