Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Method to fill form fields with retry #34

Open
Piedone opened this issue Apr 20, 2020 · 0 comments
Open

Method to fill form fields with retry #34

Piedone opened this issue Apr 20, 2020 · 0 comments

Comments

@Piedone
Copy link

Piedone commented Apr 20, 2020

FillInWith() helps but still form fields might not always be filled. So I propose adding a method something like the one I'm presenting below to retry if the fill didn't work the first time.

        public static IWebElement SafelyFillInWith(
            this IWebElement element,
            string text,
            int waitBetweenTriesSeconds = 1,
            int maxRetryCount = 5)
        {
            var i = 0;
            IWebElement modifiedElement;
            do
            {
                modifiedElement = element.FillInWith(text);
                var z = modifiedElement.GetValue();
                if (modifiedElement.GetValue() != text) Thread.Sleep(1000);
                else break;
            } while (++i < maxRetryCount);

            return modifiedElement;
        }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant