Interview Questions Flashcards
Interview Prep / Knowledge refresh
What are the limitations of Selenium
- Can only test web applications
- Limited support for image testing
- No built-in reporting
- Limited test management
What are the types of web locators
- ID
- linkText
- Name
- Tag name
- Class name
- X-Path
- CSS selector
What are the types of waits?
- Implicit: wait for a defined period of time
- Explicit: wait for a defined expected condition
- Fluent: wait for a defined expected condition and check for element with defined frequency
What are the navigation commands?
- to()
Navigates to provided URL - refresh()
Refreshes the current page - forward()
Goes to next page - back()
Goes to previous page
Difference between driver.close() and driver.quit()
- close() command closes the browser’s current window.
- quit() closes all open browser windows
How can we type text into an input box?
sendKeys()
How can we click a hyperlink?
Identify element using:
- linkText()
- partialLinkText()
How can we scroll down a page?
By using JavascriptExecutor
How to assert the title of a webpage?
getTitle() returns the title of the current webpage
How to mouse hover over an element?
moveToElement() included in the Actions class
How to retrieve CSS properties of an element?
getCssValue()
What is a Page Object Model?
A design pattern where:
- Every webpage is represented as a separate class
- Each class contains element identifiers and actions
Test cases are stores in separate classes than page object classes
Can Captcha be automated?
No
How does Selenium handle Windows bases pop-ups?
Selenium cannot handle pop ups outside of the web page. Third party tools can be integrated with Selenium to handle pop-ups
AutoIT, Robot - simulates mouse movement, keystrokes
How can we take screenshots?
TakeScreenshot and getScreenshotAs()
Can you type in a textbox without using sendKeys()?
Yes, using JavascriptExecutor
JavascriptExecutor jse = (JavascriptExecutor) driver;
jse executeScript (“document getElementById( ‘email’).value=”abc.efg@xyz.com”);
How can we select a value from a dropdown?
Using Select
What does the switchTo() function do?
Used to switch between active windows
How can we upload a file?
Using sendKeys() and file path
or Robot to simulate mouse/keys events
How can we set the window size?
Using manage()
- maximize()
- setSize()
findElement() vs findElements()
findElements() returns a list of elements
findElement() returns the first matching element
How to handle an Authentication pop-up for Login?
Using Alert class and authenticateUsing method
Single vs double slash in xPath?
Single slash creates absolute path
Double slash creates relative path
How can we find broken links?
By checking response codes
200 OK - link is valid
404 - Link Not Found
400 - Bad Request
401 - Unauthorized
500 - Internal error