Ques.51. How to verify tooltip text using selenium?
Ans. Tooltips webelements have an attribute of type 'title'. By fetching the value of 'title' attribute we can verify the tooltip text in selenium.
Ques.52. How to locate a link using its text in selenium?
Ans. Using linkText() and partialLinkText() we can locate a link. The difference between the two is linkText matches the complete string passed as parameter to the link texts. Whereas partialLinkText matches the string parameter partially with the link texts.
Ques.53. What are DesiredCapabilities in selenium webdriver?
Ans. Desired capabilities are a set of key-value pairs that are used for storing or configuring browser specific properties like its version, platform etc in the browser instances.
Ques.54. How can we find all the links on a web page?
Ans. All the links are of anchor tag 'a'. So by locating elements of tagName 'a' we can find all the links on a webpage.
Ques.55. What are some commonly encountered exceptions in selenium?
Ans. Some of the commonly seen exception in selenium are-
Ques.56. How can we capture screenshots in selenium?
Ans. Using getScreenshotAs method of TakesScreenshot interface we can take the screenshots in selenium.
Ques.57. How to handle dropdowns in selenium?
Ans. Using Select class-
Ques.58. How to check which option in the dropdown is selected?
Ans. Using isSelected() method we can check the state of a dropdown's option.
Ques.59. How can we check if an element is getting displayed on a web page?
Ans. Using isDisplayed method we can check if an element is getting displayed on a web page.
Ques.60. How can we check if an element is enabled for interaction on a web page?
Ans. Using isEnabled method we can check if an element is enabled or not.
Ques.61. What is the difference between driver.findElement() and driver.findElements() commands?
Ans. The difference between driver.findElement() and driver.findElements() commands is-
Ques.62. Explain the difference between implicit wait and explicit wait.?
Ans. An implicit wait, while finding an element waits for a specified time before throwing NoSuchElementException in case element is not found. The timeout value remains valid throughout the webDriver's instance and for all the elements.
Whereas, Explicit wait is applied to a specified element only-
It is advisable to use explicit waits over implicit waits because higher timeout value of implicit wait set due to an element that takes time to be visible gets applied to all the elements. Thus increasing overall execution time of the script. On the other hand, we can apply different timeouts to different element in case of explicit waits.
Ques.63. How can we handle window UI elements and window POP ups using selenium?
Ans. Selenium is used for automating Web based application only(or browsers only). For handling window GUI elements we can use AutoIT. AutoIT is a freeware used for automating window GUI. The AutoIt scripts follow simple BASIC lanaguage like syntax and can be easily integrated with selenium tests.
Ques.64. What is Robot API?
Ans. Robot API is used for handling Keyboard or mouse events. It is generally used to upload files to the server in selenium automation.
Ques.65. How to do file upload in selenium?
Ans. File upload action can be performed in multiple ways-
Ques.66. How to handle HTTPS website in selenium? or How to accept the SSL untrusted connection?
Ans. Using profiles in firefox we can handle accept the SSL untrusted connection certificate. Profiles are basically set of user preferences stored in a file.
Ques.67 How to do drag and drop in selenium?
Using Action class, drag and drop can be performed in selenium. Sample code-
Ques.69. How to handle alerts in selenium?
Ans. In order to accept or dismiss an alert box the alert class is used. This requires first switching to the alert box and than using accept() or dismiss() command as the case may be.
Ques.70. What is HtmlUnitDriver?
Ans. HtmlUnitDriver is the fastest WebDriver. Unlike other drivers (FireFoxDriver, ChromeDriver etc), the HtmlUnitDriver is non-GUI, while running no browser gets launched.
Ques.71. How to handle hidden elements in Selenium webDriver?
Ques.72. What is Page Object Model or POM?
Ans. Page Object Model(POM) is a design pattern in selenium. A design pattern is a solution or a set of standards that are used for solving commonly occuring software problems.
Now coming to POM - POM helps to create a framework for maintaining selenium scripts. In POM for each page of the application a class is created having the web elements belonging to the page and methods handling the events in that page. The test scripts are maintained in seperate files and the methods of the page object files are called from the test scripts file.
Ques.73. What are the advantages of POM?
Ans. The advantages are POM are-
Ques.74. What is Page Factory?
Ans. Page factory is an implementation of Page Object Model in selenium. It provides @FindBy annotation to find web elements and PageFactory.initElements() method to initialize all web elements defined with @FindBy annotation.
Ques.75. What is an Object repository?
Ans. An object repository is centralized location of all the object or WebElements of the test scripts. In selenium we can create object repository using Page Object Model and Page Factory design patterns.