-
-
Notifications
You must be signed in to change notification settings - Fork 513
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Exception handling in Serenity screenplay #3027
Comments
I'm not sure this is easily doable. Stack traces are tricky when you use the command pattern: the Click.on() parameter is not being directly called by the loginWithMobileNumberAndPassword() method, so it does not know what method it is being invoked from. |
it's easier with the actor by not passing the varargs steps but only one like
with the task it's similar i guess
|
is there any workaround apart from writing single interaction in step as its difficult to pin point which interaction is failing for a particular task , It would be easy to navigate to specific interaction in case of exception if task will be specified in stacktrace |
I am in the process of migrating my Page object model code to screenplay pattern but bit confused about the exception handling. How to print exception in better way so that debugging will be easier. Currently exception is printed at Step definition level, meaning , line of error from the Task class is not getting printed in stacktrace but the line from step definition is printed . Since i am clubbing 2-3 interactions in single step so it is getting hard to pin point exact interaction which has issue.
Eg.
Step definition method:
Class: LoginPageStepDef
public void isAtHomePage(String actor)
{
theActorInTheSpotlight().attemptsTo(loginTask.loginWithMobileNumberAndPassword(testData.get("mobile"),testData.get("password")));
}
LoginTask class:
public Performable loginWithMobileNumberAndPassword(String mobileNumber, String password)
{
return Task.where(
"{0} attempts to enter mobile no and password",
Click.on(LoginPage.LOGIN_BUTTON),
Click.on(LOGIN_EMAIL_NUMBER),
Enter.theValue(mobileNumber).into(LoginPage.LOGIN_EMAIL_NUMBER_EDIT_TEXT)
}
Here if exception like ElementNotFound occurs for line
Click.on(LoginPage.LOGIN_BUTTON),
then in stack trace there is not any entry of LoginTask class , it is printing that exception occurs at LoginPageStepDef class at line no X , the line which is calling methodloginWithMobileNumberAndPassword
.Can someone help in designing task so that we should get stacktrace of task class
--I have not copied code from editor due to privacy issue so might be syntax error
The text was updated successfully, but these errors were encountered: