Thursday 14 November 2019

Selenium Webdriver most asked Interview Question? Top 5 selenium Interview Qus?Most asked Selenium webdriver question?

In this post we will go through the MOST asked Top 5 selenium Interview questions:

1. What are the types of locators used to identify object?

ANS:

  •     ID
  •     Name
  •     Class Name
  •     Tag Name
  •     Link Text & Partial Link Text
  •     Link Text
  •     CSS Selector
  •     DOM (Document Object Model)
  •     XPath


2. Difference between getwindowHandle and getwindowHandles ?

ANS:
driver.getWindowHandle() return a String of alphanumeric window handle and is mainly used to get the window handle of the current window.
driver.getWindowHandles() return a set of window handles and is mainly used to get the window handle of all the current windows.


3. How to handle popup and alerts in selenium?

ANS:  

Alert alert = driver.switchTo().alert();

alert.accept(); //it will click on "ok"

alert.dismiss();  //it will click on "cancel"

4. How to handle mouse and key board events using selenium?

 Keyboard Events Using Selenium Actions Class:
  • sendKeys(keysToSend) : sends a series of keystrokes
  • keyDown(theKey) : Sends a key press without release it. (example: Keys.ALT, Keys.SHIFT, or Keys.CONTROL)
  • keyUp(theKey): Performs a key release

Mouse Events Using Selenium Actions Class:

  • click ():  click on element

  • doubleClick (): Double clicks on Element

  • contextClick() : Performs a context-click (right click) 

  • clickAndHold(): Clicks at the present mouse location 

  • dragAndDrop(source, target): Invokes click-and-hold at the source location and moves to the location of the target element before releasing the mouse. source – element to grab, target – element to release
     
  • dragAndDropBy(source, xOffset, yOffset) : Performs click-and-hold at the source location, shifts by a given offset, then frees the mouse. xOffset – to shift horizontally, yOffset – to shift vertically
     
  • moveByOffset(x-offset, y-offset): Shifts the mouse from its current position (or 0,0) by the given offset. x-offset – Sets the horizontal offset (negative value – shifting the mouse to the left), y-offset – Sets the vertical offset (negative value – shifting the mouse to the up)
     
  • moveToElement(toElement): It shifts the mouse to the center of the element

  • release(): Releases the depressed left mouse button at the existing mouse location

5. What are the functions most commonly used in xpath, describe any 5?

ANS: 

No comments:

Post a Comment

All Time Popular Posts

Most Featured Post

API Status Codes with examples for QA-Testers

  🔺 LinkedIn: https://www.linkedin.com/in/sidharth-shukla-77b53145/ 🔺 Telegram Group:  https://t.me/+FTf_NPb--GQ2ODhl 🏮In API testing, it...