What is WebDriver? Flashcards
What is a WebDriver?
It is an interface
Why cant we do the following?
WebDriver driver = new WebDriver();
Cannot instantiate an interface
Why we wont prefer FirefoxDriver driver = new FirefoxDriver()
The FirefoxDriver instance which gets created based on above statement will be only able to invoke and act on the methods implemented by FirefoxDriver and supported by Firefox Browser only. We know that FirefoxDriver is a class and it implements all the methods of WebDriver interface. Using this statement, we can run our scripts only on Firefox Browser.
So, once you initiate a Firefox browser using FirefoxDriver driver = new FirefoxDriver(); same object cannot be used to initiate Chrome Browser (you have to rename it)
What is webdriver used for?
WebDriver is an interface used to launch different browsers such as Firefox, Chrome, Internet Explorer, Safari etc.,
What is webelement?
Web element is an interface used to identify the elements in a web page.
what is find by?
FindBy is an annotation used in Page Object Model design pattern to identify the elements.
Selenium WebDriver
allows controlling web browsers as a user would, but programmatically
What is groupID?
Organization, company, person, etc., that created the project.
What is artifactID
Unique name that identifies the project.
What is version?
Particular release of the project. By default, I recommend you use the latest version of every release.
where does Application source code (i.e., Java files) go
src/main/java
Where does Application resources files (i.e., properties, configuration files, etc.) go?
src/main/resources
Which method do you use to load a web page in the current browser.
get(String ulr)
driver.get(“google.com”);
How to get current URL loaded in the browser?
getCurrentUrl()
How to get the title <Tilte> of HTML tag?</Tilte>
getTitle()
How to find the first WebElement using a given locator in the current web page
findElement(By by)
How to find every WebElement using a given locator in the current web page
findElements(By by)
How to find the HTML source code of the current webpage
getPageSource();
How to access the browser history and navigate to a given URL
navigate()
how to get the window handle, i.e., a unique identifier for the open window in the current browser
getWindowHandle()
How to get the set of window handles currently open in the current browser
getWindowHandles()
How to select a frame or window in the current browser
switchTo()
How to Close the current window, quitting the browser if there are no more windows opened.
close()
how to Close all windows and quit the browser.
quit()
List webdriver methods?
getTitle()
quit()
close()
switchTo()
getWindowHandle()
getWindowHandles()
navigate()
getPageSource()
getCurrentUrl()
get()
List webelement methods
click()
submit()
sendKeys()
clear()
getTagName()
getDomProperty()
getDomAttribute()
getAttribute()
getAriaRole()
getAccessibleName()
isSelected()
isEnabled()
isDisplayed()
getText()