Page 1 of 1

How to get out of Vb.net loop

Posted: Fri Jun 21, 2013 9:03 pm
by tiara
I need to jump to the next line in excel sheet containg user names and passwords once I get invalid user for my website. How can I do it in here as Next or continue is not working in Ranorex.

Re: How to get out of Vb.net loop

Posted: Fri Jun 21, 2013 9:52 pm
by Ciege
What kind of loop are you using?

If you use a While loop based on a condition it will exit when that condition does not = true...

Furthermore, you can add you own Exit While statement if you need to use it.

Re: How to get out of Vb.net loop

Posted: Fri Jun 21, 2013 10:21 pm
by tiara
I have added the excel through data binding and its taking values from my excel sheet. I have used if else and not a loop... I want to exit if the user is not valid and jump to the next value(row) in the spread sheet... how should I do that

Re: How to get out of Vb.net loop

Posted: Fri Jun 21, 2013 10:42 pm
by Ciege
Sorry, that's a different question...

I don't use the built in Excel data binding as I find it too restrictive for my use. So I cannot specifically answer your question.

Maybe post your code here so we can have a look and make a recommendation.

Re: How to get out of Vb.net loop

Posted: Mon Jun 24, 2013 2:57 pm
by tiara
login(user,email,validity)

MyRepo.somecontainer.someAndroidelement.click
logout()
'---------------------------------

sub login(ByRef user as string,password as String,validity as Boolean)

MyRepo.loginpanel.user.textvalue = user

MyRepo.loginpanel.password.textvalue = user

if validity =True Then
System.console.WriteLine("Login Succesful")
else
System.console.WriteLine("Invalid User")

end If

MyRepo.LoginPanel.Login.click()
End Sub

The values of user and password and validity of user is taken from excel by connecting it as mentioned in ranorex. but if a user is invalid ie, the validity is false,the program is stuck there and would not take the next values from the excel sheet. How can I get next values of valid users from the sheet.

Re: How to get out of Vb.net loop

Posted: Mon Jun 24, 2013 7:36 pm
by Ciege
You can try adding an "Exit Sub" or "Return" after your Invalid User command.

Re: How to get out of Vb.net loop

Posted: Tue Jun 25, 2013 1:34 pm
by Support Team
Hi,

My guess is that you get an exception if the user is invalid and that Ranorex because of the exception ends the current test case.
If so you could set the "Error Behavior" of the test case to "Continue with iteration", since this will ensure that Ranorex will continue with the next iteration of the current test case.
For more details about the setting please take a look at the following link: Test Case Settings.

Regards,
Markus

Re: How to get out of Vb.net loop

Posted: Thu Jun 27, 2013 6:19 pm
by tiara
Thanks It helped Markus..:)