Check the below link for all Selenium Webdriver related posts:
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:
2. Difference between getwindowHandle and getwindowHandles ?
ANS:
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:
Mouse Events Using Selenium Actions Class:
5. What are the functions most commonly used in xpath, describe any 5?
ANS:
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:
- Contains
- Sibling
- Ancestor
- And OR
- Parent
- Starts with
- XPath Axes
- Following
- Preceding
Hi, Could you please update this page with more questions
ReplyDeletehttps://automationreinvented.blogspot.com/2022/07/top-selenium-interview-questions-and.html
ReplyDelete