How to get out of Vb.net loop

Class library usage, coding and language questions.
tiara
Posts: 16
Joined: Thu Jun 20, 2013 3:03 pm

How to get out of Vb.net loop

Post by tiara » Fri Jun 21, 2013 9:03 pm

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.

User avatar
Ciege
Ranorex Guru
Posts: 1335
Joined: Thu Oct 16, 2008 6:46 pm
Location: Arizona, USA

Re: How to get out of Vb.net loop

Post by Ciege » Fri Jun 21, 2013 9:52 pm

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.
If this or any response has helped you, please reply to the thread stating that it worked so other people with a similar issue will know how you fixed your issue!

Ciege...

tiara
Posts: 16
Joined: Thu Jun 20, 2013 3:03 pm

Re: How to get out of Vb.net loop

Post by tiara » Fri Jun 21, 2013 10:21 pm

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

User avatar
Ciege
Ranorex Guru
Posts: 1335
Joined: Thu Oct 16, 2008 6:46 pm
Location: Arizona, USA

Re: How to get out of Vb.net loop

Post by Ciege » Fri Jun 21, 2013 10:42 pm

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.
If this or any response has helped you, please reply to the thread stating that it worked so other people with a similar issue will know how you fixed your issue!

Ciege...

tiara
Posts: 16
Joined: Thu Jun 20, 2013 3:03 pm

Re: How to get out of Vb.net loop

Post by tiara » Mon Jun 24, 2013 2:57 pm

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.

User avatar
Ciege
Ranorex Guru
Posts: 1335
Joined: Thu Oct 16, 2008 6:46 pm
Location: Arizona, USA

Re: How to get out of Vb.net loop

Post by Ciege » Mon Jun 24, 2013 7:36 pm

You can try adding an "Exit Sub" or "Return" after your Invalid User command.
If this or any response has helped you, please reply to the thread stating that it worked so other people with a similar issue will know how you fixed your issue!

Ciege...

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: How to get out of Vb.net loop

Post by Support Team » Tue Jun 25, 2013 1:34 pm

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
.
Image

tiara
Posts: 16
Joined: Thu Jun 20, 2013 3:03 pm

Re: How to get out of Vb.net loop

Post by tiara » Thu Jun 27, 2013 6:19 pm

Thanks It helped Markus..:)