Do you know we can return object in Java, for example, if you want to use WebDriver object created in a method in someother method in someother class, you can return that object.
Syntax:
Public Classname methodname(){
Classname obj= new Classname();
return obj;
}
The above example tells us how to create method to return an object. Below is live example of WebDriver object:
Public WebDriver methodname(){
WebDriver object= new ChromeDriver();
return object;
}
When you call above method in other class like:
WebDriver object1= methodname();
object1.url("https://www.google.com");
It will still trigger google website.
No comments:
Post a Comment