0
for(int i=0;i<=10;i++)
{
    Driver.Instance.Find Element(By.Id("id of element")).Send Keys("auto"+i);
}

I used this code but it does not work
1 to 10 numbers are printing in one attempt

I am searching for the code which dynamically increment in each run with out changing the sendkeys values again and again

1
  • Please clarify what are you trying to achieve. Commented Jun 19, 2015 at 6:30

2 Answers 2

1

Your question is not clear. Are you trying to Enter the value in 10 different Edit Boxes in a single run or you are trying to enter different values in same Edit box in multiple runs (If so you can use random class to generate random integers which will generate different values in different runs).

Random random = new Random();
int i = random.Next(0, 10);

Driver.Instance.Find Element(By.Id("id of element")).Send Keys("auto"+i);

You can increase the bucket random.Next(0, 10); to some random.Next(0, 100); to decrease the

probability

of having same no in 10 runs.

Sign up to request clarification or add additional context in comments.

2 Comments

I am trying to enter different values in same Edit box in multiple runs
when i used this random it was taking always same numbers Example- in third run it was again taking first run number
0
   Guid guid = Guid.NewGuid();
   Driver.Instance.FindElement(By.Id("tbReportName"))
        .SendKeys("report"+DateTime.Now.Millisecond); 

OR

Guid guid = Guid.NewGuid();
Driver.Instance.FindElement(By.Id("tbReportName"))
        .SendKeys("report" + guid.ToString());

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.