- How do you handle JavaScript alert using WebDriver?
Answer : It can be handled using alert interface. Refer this post for further details.
- What is implicitwait & explicitwait?
Answer: Implicit waits are basically your way of telling WebDriver the latency that you want to see if specified web element is not present that WebDriver looking for.
Explicit waits are intelligent waits that are confined to a particular web element. Using explicit waits you are basically telling WebDriver at the max it is to wait for X units of time before it gives up.
Refer this post
- Can I navigate browser forward & backward?
Answer : Yes, we can. Using methods available in Navigate interface we can navigate back and forth in a page.
Refer this post
- How about handling iframes?
Answer : We must switch the control to iframe before doing any operation with the elements within iframe. We can use switchTo method to switch the control to frame.
- driver.switchTo().frame("<frame name>");
- driver.switchTo().frame(frame index);
- driver.switchTo().frame(<WebElement>);
- How to handle new windows?
Answer : Refer this post
- Can we execute JavaScript using WebDriver?
Answer : Yes, we can. Refer this post
- How can you perform mouse operations using WebDriver?
Answer : Refer this post
- How can I check for an element presence?
Answer : Refer this - Method-I , Method- II
- How do you select options from dropdown?
Answer : Refer this post
- Can we capture screenshot when case failed?
Answer : Yes, we can take screenshot. Refer this post
Related Topics
WebDriver Interview Question - I
WebDriver Interview Question - II
- What are all classes implementing WebDriver interface?
Answer : All the following classes implemented WebDriver Interface. ChromeDriver, EdgeDriver, EventFiringWebDriver, FirefoxDriver, HtmlUnitDriver, InternetExplorerDriver, MarionetteDriver, OperaDriver, RemoteWebDriver, SafariDriver.
- What are all different methods available in WebDriver?
Answer : Some of the most important methods available in webDriver are
- close()
- findElement(By by)
- findElements(By by)
- get(String url)
- quit()
- How will get the title of window?
Answer : We can get window title using "getTitle()" method with is declared in WebDriver.
- What is the return type of "findElement(By by)" method?
Answer : WebElement. findElement method will return the WebElement found in that page based on specified locator. If no matching elements are found it throws NoSuchElementException
- How do you clear content of a text box?
Answer : Using "clear" method on text box we can clear the content in that.
Example : driver.findElement(By.id("username")).clear();
- What is the submit method in WebElement?
Answer : If this current element is a form, or an element within a form, then this will be submitted to the remote server. If this causes the current page to change, then this method will block until the new page is loaded.
- How will you get the text from below tag?
<div name='myDiv'>Hello</div>
Answer : We can get the text of any tag using getText() method on that element. In this case
String text = driver.findElement(By.name("myDiv")).getText();
- How do you refresh the browser?
Answer : driver.navigate().refresh();
- Can we make WebDriver to wait until elements loaded fully?
Answer : Yes, We can make WebDriver to wait until all the elements/ required elements loaded fully with some timeout condition.
- How can I type my text in input box?
Answer : Using sendKeys method we can type the required text in specified input box
example : driver.findElement(By.id("coursename")).sendKeys("Selenium-Webdriver");
Related Posts
WebDriver Interview Questions - I
- What is Selenium 2.0 ?
Answer : Selenium 2.0 is the integration of the WebDriver API & Selenium RC. WebDriver is designed to provide a simpler, more concise programming interface in addition to addressing some limitations in the Selenium-RC API.
- What are different languages it supports ?
Answer : Automation scripts can be written using WebDriver in any of the following languages. java, C#, Python, Ruby, Perl, PHP
- Is WebDriver class or interface?
Answer : WebDriver is an interface. WebDriver is the name of the key interface against which tests should be written, but there are several implementations.
- What are all different classes implemented WebDriver interface?
Answer : WebDriver implementations include
- HtmlUnitDriver
- FirefoxDriver
- InternetExplorerDriver
- ChromeDriver
- OperaDriver
- What is HtmlUnitDriver ?
Answer : It is the fastest and most lightweight implementation of WebDriver. As the name suggests, this is based on HtmlUnit. HtmlUnit is a java based implementation of a WebBrowser without a GUI.
- Which WebDriver implementation is the fastest ?
Answer : HtmlUnitDriver. Because it executes the tests without launching the browser (headless)
- How to launch firefox browser using WebDriver?
Answer : Using FirefoxDriver we can launcg firefox browser.
WebDriver driver = new FirefoxDriver(); // this will launch firefox browser
- How will you load URL in browser?
Answer : We can loan an URL in browser by calling "get" method
driver.get("http://www.google.com");
- Tell me about different types of element locators?
Answer : By mechanism used to locate elements within a document.
By.id("<Element ID>")
By.name("<Element Name>");
By.cssSelector("<css selector>");
By.xpath("<element xpath>");
By.linkText("<Full content of link text >");
By.partialLinkText("<Partial content of link text>");
- Can we load URL without using "get" method?
Answer : Yes, we can do using navigate() method.
driver.navigate().to("http://www.example.com");