Skip to main content
Updated answer
Source Link
undetected Selenium
  • 194.5k
  • 44
  • 304
  • 387

From SeleniumSelenium's perspective, the WebDriver InterfaceWhat is the difference between ChromeDriver and WebDriver in selenium? interface is similar like a agreement which the 3rd party Browser Vendors like Mozilla, Chrome, Internet Explorer, Safari, etc have to adhere and implement the same. This would in-turn help the end-users to use the exposed APIs to write a common code and implement the functionalities across all the available Browsersbrowsers without any change.

Through WebDriver driver = new FirefoxDriver(); wethe line of code:

WebDriver driver = new FirefoxDriver(); 

We are creating an instance of the WebDriver Interface interface and casting it to FirefoxDriver ClassFirefoxDriver class. All the Browser Drivers like FirefoxDriver, ChromeDriver, InternetExplorerDriver, PhantomJSDriver, SafariDriver etc implemented the WebDriver interface (actually the RemoteWebDriver class implements WebDriver InterfaceWebDriver Interface and the Browser Driversbrowser drivers extends RemoteWebDriverRemoteWebDriver). So if we use WebDriver driver, then we can use the already initialized driverdriver instance (as common object variable) for all browsers we want to automate e.g. Mozilla, Chrome, InternetExplorer, PhantomJS, Safari.

A WebElementWebElement is an abstraction used to identify the Element nodes and are simply known as elements when it is transported via the protocol, between remote and local ends. The web element identifier is the string constant expressed as:

From Selenium perspective, the WebDriver Interface is similar like a agreement which the 3rd party Browser Vendors like Mozilla, Chrome, Internet Explorer, Safari, etc have to adhere and implement the same. This would in-turn help the end-users to use the exposed APIs to write a common code and implement the functionalities across all the available Browsers without any change.

Through WebDriver driver = new FirefoxDriver(); we are creating an instance of the WebDriver interface and casting it to FirefoxDriver Class. All the Browser Drivers like FirefoxDriver, ChromeDriver, InternetExplorerDriver, PhantomJSDriver, SafariDriver etc implemented the WebDriver interface (actually the RemoteWebDriver class implements WebDriver Interface and the Browser Drivers extends RemoteWebDriver). So if we use WebDriver driver, then we can use the already initialized driver (as common object variable) for all browsers we want to automate e.g. Mozilla, Chrome, InternetExplorer, PhantomJS, Safari.

A WebElement is an abstraction used to identify the Element nodes and are simply known as elements when it is transported via the protocol, between remote and local ends. The web element identifier is the string constant expressed as:

From Selenium's perspective, the What is the difference between ChromeDriver and WebDriver in selenium? interface is similar like a agreement which the 3rd party Browser Vendors like Mozilla, Chrome, Internet Explorer, Safari, etc have to adhere and implement the same. This would in-turn help the end-users to use the exposed APIs to write a common code and implement the functionalities across all the available browsers without any change.

Through the line of code:

WebDriver driver = new FirefoxDriver(); 

We are creating an instance of the WebDriver Interface and casting it to FirefoxDriver class. All the Browser Drivers like FirefoxDriver, ChromeDriver, InternetExplorerDriver, PhantomJSDriver, SafariDriver etc implemented the WebDriver interface (actually the RemoteWebDriver class implements WebDriver Interface and the browser drivers extends RemoteWebDriver). So if we use WebDriver driver, then we can use the already initialized driver instance (as common object variable) for all browsers we want to automate e.g. Mozilla, Chrome, InternetExplorer, PhantomJS, Safari.

A WebElement is an abstraction used to identify the Element nodes and are simply known as elements when it is transported via the protocol, between remote and local ends. The web element identifier is the string constant expressed as:

Added text
Source Link
undetected Selenium
  • 194.5k
  • 44
  • 304
  • 387

Why WebDriver driver = new FirefoxDriver();WebDriver driver = new FirefoxDriver();

Through WebDriver driver = new ChromeDriverFirefoxDriver(); we are creating an instance of the WebDriver interface and casting it to ChromeDriverFirefoxDriver Class. All the Browser Drivers like FirefoxDriver, ChromeDriver, InternetExplorerDriver, PhantomJSDriver, SafariDriver etc implemented the WebDriver interface (actually the RemoteWebDriver class implements WebDriver Interface and the Browser Drivers extends RemoteWebDriver). So if we use WebDriver driver, then we can use the already initialized driver (as common object variable) for all browsers we want to automate e.g. Mozilla, Chrome, InternetExplorer, PhantomJS, Safari.

 

From Selenium perspective, WebElementWebElement represents an HTML element. Generally, all the operations to do with interacting with a page will be performed through this interface.

You can find a detailed discussion in Values returned by webdrivers

Each browsing context has an associated list of known elements. When the browsing context is discarded, the list of known elements is discarded along with it.

You can find a detailed discussion in Why return type of findElement(By by) is WebElement?

Some of the commonly used associated methods are as folllowsfollows:

Why WebDriver driver = new FirefoxDriver();

Through WebDriver driver = new ChromeDriver(); we are creating an instance of the WebDriver interface and casting it to ChromeDriver Class. All the Browser Drivers like FirefoxDriver, ChromeDriver, InternetExplorerDriver, PhantomJSDriver, SafariDriver etc implemented the WebDriver interface (actually the RemoteWebDriver class implements WebDriver Interface and the Browser Drivers extends RemoteWebDriver). So if we use WebDriver driver, then we can use the already initialized driver (as common object variable) for all browsers we want to automate e.g. Mozilla, Chrome, InternetExplorer, PhantomJS, Safari.

From Selenium perspective, WebElement represents an HTML element. Generally, all the operations to do with interacting with a page will be performed through this interface.

Each browsing context has an associated list of known elements. When the browsing context is discarded, the list of known elements is discarded along with it.

Some of the commonly used associated methods are as folllows:

WebDriver driver = new FirefoxDriver();

Through WebDriver driver = new FirefoxDriver(); we are creating an instance of the WebDriver interface and casting it to FirefoxDriver Class. All the Browser Drivers like FirefoxDriver, ChromeDriver, InternetExplorerDriver, PhantomJSDriver, SafariDriver etc implemented the WebDriver interface (actually the RemoteWebDriver class implements WebDriver Interface and the Browser Drivers extends RemoteWebDriver). So if we use WebDriver driver, then we can use the already initialized driver (as common object variable) for all browsers we want to automate e.g. Mozilla, Chrome, InternetExplorer, PhantomJS, Safari.

 

From Selenium perspective, WebElement represents an HTML element. Generally, all the operations to do with interacting with a page will be performed through this interface.

You can find a detailed discussion in Values returned by webdrivers

Each browsing context has an associated list of known elements. When the browsing context is discarded, the list of known elements is discarded along with it.

You can find a detailed discussion in Why return type of findElement(By by) is WebElement?

Some of the commonly used associated methods are as follows:

Source Link
undetected Selenium
  • 194.5k
  • 44
  • 304
  • 387

WebDriver Interface

From Selenium perspective, the WebDriver Interface is similar like a agreement which the 3rd party Browser Vendors like Mozilla, Chrome, Internet Explorer, Safari, etc have to adhere and implement the same. This would in-turn help the end-users to use the exposed APIs to write a common code and implement the functionalities across all the available Browsers without any change.


Why WebDriver driver = new FirefoxDriver();

Through WebDriver driver = new ChromeDriver(); we are creating an instance of the WebDriver interface and casting it to ChromeDriver Class. All the Browser Drivers like FirefoxDriver, ChromeDriver, InternetExplorerDriver, PhantomJSDriver, SafariDriver etc implemented the WebDriver interface (actually the RemoteWebDriver class implements WebDriver Interface and the Browser Drivers extends RemoteWebDriver). So if we use WebDriver driver, then we can use the already initialized driver (as common object variable) for all browsers we want to automate e.g. Mozilla, Chrome, InternetExplorer, PhantomJS, Safari.

WebDriver driver = new FirefoxDriver(); driver = new ChromeDriver(); driver = new FirefoxDriver(); driver = new SafariDriver(); 

You can find a detailed discussion in:

WebElement Interface

From Selenium perspective, WebElement represents an HTML element. Generally, all the operations to do with interacting with a page will be performed through this interface.

A WebElement is an abstraction used to identify the Element nodes and are simply known as elements when it is transported via the protocol, between remote and local ends. The web element identifier is the string constant expressed as:

"element-6066-11e4-a52e-4f735466cecf" 

Each element has an associated web element reference that uniquely identifies the element across all browsing contexts. The web element reference for every element representing the same element must be the same. It must be a string, and should be the result of generating a UUID.

An ECMAScript Object represents a web element if it has a web element identifier own property.

Each browsing context has an associated list of known elements. When the browsing context is discarded, the list of known elements is discarded along with it.

Some of the commonly used associated methods are as folllows:

  • clear()
  • click()
  • findElement(By by)
  • findElements(By by)
  • getAttribute(java.lang.String name)
  • getCssValue(java.lang.String propertyName)
  • getLocation()
  • getRect()
  • getSize()
  • getTagName()
  • getText()
  • isDisplayed()
  • isEnabled()
  • isSelected()
  • sendKeys(java.lang.CharSequence... keysToSend)
  • submit()