I am confused with this. Basically when we create an object of a class, then we can access property
or method
. Up to I am fine. But what when we are creating an object of WebDriver
class in Selenium
and setting URL through driver.navigate().to()
. So Why are here two things navigate()
and to()
after the Selenium object driver
.
Asked
Active
Viewed 996 times
2

Taher A. Ghaleb
- 5,120
- 5
- 31
- 44

Asraful Haque
- 1,109
- 7
- 17
-
1see this https://stackoverflow.com/questions/21180269/how-to-achieve-method-chaining-in-java – murali selenium Dec 26 '18 at 16:02
-
@Asraful Haque, should I add more explanation to my answer? – Moshe Slavin Dec 31 '18 at 13:15
1 Answers
2
Navigate is an interface to navigate through the browser:
Navigate is a way of interacting with the browser.
The method .to()
is a function of the interface to get a URL.
The shorter way to do driver.navigate().to()
is driver.get()
With navigate
you have more methods like: driver.navigate().forward();
and driver.navigate().back();
Hope this helps you!
PS:
As @muraliselenium has commented if your question is about "method chaining" you can read more about it here

Moshe Slavin
- 5,127
- 5
- 23
- 38