-1

I have c# code like the following to loop through rows to get new code in this case the loop not finished but code created

 for (int i = 1; i < 100; i++)
 { 
      driver.FindElement(By.Id("Code"))
          .SendKeys(data.ExcelFile(i, 1));

      driver.FindElement(By.Id("Code")).Click();
  }

I try to use break with if statement and assertion but not work
how can I make the test pass also

shaimaa
  • 1
  • 1
  • 4

1 Answers1

0

Please structure your questions better as it is hard to understand what you are wanting.

In saying that you should be using a foreach loop, with your current setup you are relying on the fact there will always be <100 rows within your excel spreadsheet. Using the foreach loop will exit the loop once all rows have been 'processed'

In regards to how you can make tests pass? You can't make tests pass, tests will pass if the assertion is successful

  • Your answer is what I mean by using for loop it will exit once all rows processed , I need this test pass if the driver lines sucseful I try using assertion in this case but also fail – shaimaa Feb 28 '18 at 06:56
  • Awesome glad my answer helped, You shouldn't need to assert the loop as if it doesn't pass it will fail within the loop. Structure your method to return a bool and wrap the loop in a try catch, within the catch you can return false, and outside of the catch return a true so when the loop completes it will return true. You can then assert the method. Please mark my original reply as 'answered' if it has answered your question :) – anArchLolz Feb 28 '18 at 21:35