Selenium interview questions - Part 6

51) Explain the difference between single and double slash in X-path?
  • Single slash ( / ) start selection from the document node. It allows you to create ‘absolute’ path expressions.
  • Double slash ( // ) start selection matching anywhere in the document. It enables to create ‘relative’ path expressions.

52) Explain what is the difference between find elements () and find element () ?
  • find element(): It finds the first element within the current page using the given “locating mechanism”.  It returns a single WebElement
  • findElements() : Using the given “locating mechanism” find all the elements within the current page.  It returns a list of web elements.

53) Explain how you can login into any site if it’s showing any authentication popup for password and username?
Pass the username and password with url.
e.g.- http://username:password@example.com


54) Explain how to assert text of webpage using selenium 2.0 ?
WebElement we = driver.findElement(By.id(“ElementID”))

//get test from element and stored in text variable
String text = we.getText();

//assert text from expected
Assert.assertEquals(“Element Text”, text);


55) How to switch between the frames?
To switch between frames webdrivers [driver.switchTo().frame()] method takes one of the possible arguments
  • Number by its (zero-based) index.
  • Frame by its name or ID.

56) Mention 5 different exceptions you had in Selenium web driver?
The 5 different exceptions you had in Selenium web drivers are
  • WebDriverException
  • NoAlertPresentException
  • NoSuchWindowException
  • NoSuchElementException
  • TimeoutException

57) How you can perform double click using webdriver?
You can perform double click by using following syntax.
Actions action = new Actions(driver);
action.moveToElement(driver.findElement(By.id("Name"))).doubleClick().build().perform();


58) How you can perform right click using webdriver?
You can perform right click by using following syntax
Actions action= new Actions(driver);
action.contextClick(MyLink).build().perform();

59) How will you use Selenium to upload a file?
Please refer following link.
https://selenium-vinod.blogspot.in/p/how-to-upload-files-in-selenium-using.html


60) Which web driver implementation is fastest?
HTMLUnit Driver implementation is fastest, HTMLUnitDriver does not execute tests on browser. It is far quick faster than launching a browser and executing tests.


<-- Previous || Next -->

No comments:

Post a Comment