You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've bumped into some not really good logic in my objects. I tried to change it, but the results were pretty much the same. A problem: when I run my tests for some functional part on the site and if one of the tests is failed, then the others probably will be also failed, because of depending.
How to re-write this piece of code to eliminate an issue?
public HomePage LogInUser(stringname,stringpassword){if(!LoginLink)returnthis;
Find.Element(By.CssSelector(LoginLinkCss)).Click();Name=name;Password=password;
SignIn();returnthis;}publicboolLoginLink{
get {return Find.Element(By.CssSelector(LoginLinkCss)).Displayed;}}
So, an example what I need to handle:
1st test is failed for some reason (LogInUser method is processed successfully and on some step it is failed, user is still logged in)
2nd test is running (but on the LogInUser method the test is becoming failed, because it gets LoginLink first and then it's trying to find en element By.CssSelector(LoginLinkCss) and:
TestStack.Seleno.Configuration.Interceptors.SelenoReceivedException : Unable to locate element: {"method":"css selector","selector":"[href='https:/my_site/#login']"}, because the user is already logged in)
How to re-write it that even if one test is failed for some reason it will not break the others?
The text was updated successfully, but these errors were encountered:
The general way to handle this is to not make assumptions in your tests. If there is a particular context that matters for the test when starting then you should do that (e.g. if the user should start logged off then send them to the log out link as the first thing then perform login).
The second option is to use the Find.OptionalElement method, which will return null if something doesn't exist. You can use that to perform conditional logic.
Hi all,
I've bumped into some not really good logic in my objects. I tried to change it, but the results were pretty much the same.
A problem: when I run my tests for some functional part on the site and if one of the tests is failed, then the others probably will be also failed, because of depending.
How to re-write this piece of code to eliminate an issue?
So, an example what I need to handle:
1st test is failed for some reason (LogInUser method is processed successfully and on some step it is failed, user is still logged in)
2nd test is running (but on the LogInUser method the test is becoming failed, because it gets LoginLink first and then it's trying to find en element By.CssSelector(LoginLinkCss) and:
TestStack.Seleno.Configuration.Interceptors.SelenoReceivedException : Unable to locate element: {"method":"css selector","selector":"[href='https:/my_site/#login']"}, because the user is already logged in)
How to re-write it that even if one test is failed for some reason it will not break the others?
The text was updated successfully, but these errors were encountered: