9 Answers, 1 is accepted
0
Asta
Top achievements
Rank 1
answered on 08 Feb 2013, 01:13 PM
Yes, by using try catch
try{
// Some code } catch (NullReferenceException) { s.Write("Element not found"); }0
Anton
Top achievements
Rank 1
answered on 08 Feb 2013, 01:18 PM
Hello Asta,
I know this way, but it applicable only for one FindElement.
I want to catch all exceptions.
For example:
I know this way, but it applicable only for one FindElement.
I want to catch all exceptions.
For example:
AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler( OnException);public static void OnException(object sender, UnhandledExceptionEventArgs e) { Exception exception = (Exception)e.ExceptionObject; Console.Error.WriteLine(exception.Message); Environment.Exit(1); }0
Asta
Top achievements
Rank 1
answered on 08 Feb 2013, 01:39 PM
There you go...
And google could help you Click Here
DoAction(Action action){try{ action();}catch{ a.Write("Errror!");}}[Test]public void Add(){DoAction(Add);}And google could help you Click Here
0
Anton
Top achievements
Rank 1
answered on 08 Feb 2013, 02:49 PM
Probably did you mean smth like this?
It's work but i need to rewrite all my tests and it's not a global handling. I can also use try{} catch{} in main test but it's not solving my problem.
I'm searching in google but found only Application.ThreadException event wich available only for WebForms.
AppDomain.CurrentDomain.UnhandledException as i wrote above handle only Gallio(MbUnit) exceptions.
public static void DoAction(Action action) { try { action(); } catch(NullReferenceException e) { Console.WriteLine("adfadfaf"); } }[Test] public void Test0001() { DoAction(Test001WrongLogin); }[Test] public void Test001WrongLogin() { ActiveBrowser.NavigateTo(Configuration.Instance.Url); Find.ByExpression<HtmlInputText>(LoginActions.LoginField).Text = "asd321"; }It's work but i need to rewrite all my tests and it's not a global handling. I can also use try{} catch{} in main test but it's not solving my problem.
I'm searching in google but found only Application.ThreadException event wich available only for WebForms.
AppDomain.CurrentDomain.UnhandledException as i wrote above handle only Gallio(MbUnit) exceptions.
0
Asta
Top achievements
Rank 1
answered on 08 Feb 2013, 02:51 PM
Be smart.. Use google :)
0
Anton
Top achievements
Rank 1
answered on 08 Feb 2013, 03:38 PM
Seriously? )
I'm google it for a 5 hours and i didn't find solutions even for Selenium or another tool.
I'm find some solutions for Nunit using EventListener but i'm using Gallio.
I'm google it for a 5 hours and i didn't find solutions even for Selenium or another tool.
I'm find some solutions for Nunit using EventListener but i'm using Gallio.
0
Asta
Top achievements
Rank 1
answered on 11 Feb 2013, 07:46 AM
What Gallio have that NUnit don't have?
0
Anton
Top achievements
Rank 1
answered on 11 Feb 2013, 09:12 AM
Asta, I think that it is not place for "holly war".
I have few thousand of tests and Framework written with MbUnit using XML data binding and other feautures.
I thnik swith to NUnit and rewrite framework and tests is not good for first solution.
I have few thousand of tests and Framework written with MbUnit using XML data binding and other feautures.
I thnik swith to NUnit and rewrite framework and tests is not good for first solution.
0
Asta
Top achievements
Rank 1
answered on 11 Feb 2013, 09:40 AM
You can create script whose will refactor the code.