2

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.

Taher A. Ghaleb
  • 5,120
  • 5
  • 31
  • 44
Asraful Haque
  • 1,109
  • 7
  • 17

1 Answers1

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