In selenium, when should we declare a method or variable as static or non-static..
Any criteria for that in our framework or program ?
Instructor
Ashish Thakur Replied on 03/02/2020
Please refer to module 3. We have covered in detail the difference and use of this concept.
In simple words,
static: can be accessed directly with class name
e.g. ClassName.functionName();
or ClassName.variableName;
non-static: can only be accessed with the help of an object.
e.g. Object.functionName();
or Object.variableName();
I know the difference in this and how to declare..
But my Q is when should be go for static and when to declare Non static ? Any criteria or something for this ?
Instructor
Ashish Thakur Replied on 04/02/2020
Static will return the same data everywhere whenever accessed.
NonStatic will return different data for different objects.
I would suggest you to go through the videos once and then try the concept manually to fully understand the difference.