Here is the list of Selenium Interview questions and answers.
How to read data from table?
You can easily read the data from table using findElements method. Find all the table cells using TD tag and then get the text inside each cell by getText() method or innerText property in HTML DOM.
What all browsers and OS are supported by Selenium?
How to handle multiple browser windows and frames?
How to drag and drop in Selenium Webdriver?
How to use Selenium Grid?
Challenges, issues and limitations of Selenium tool? How to handle Captcha?
How to read data from table?
You can easily read the data from table using findElements method. Find all the table cells using TD tag and then get the text inside each cell by getText() method or innerText property in HTML DOM.
What all browsers and OS are supported by Selenium?
Selenium supports below browsers.
- Internet Explorer
- Google Chrome
- Firefox
- Safari
- Opera
- Android browser
- iPhone Browser
Operating systems supported by Selenium are -
- All Windows OS
- Linux
- Mac (Apple OS)
- Android
- IOS
Various Synchronization methods in Selenium Webdriver - implicit wait, page load timeout, explicit wait?
There are 4 ways we can handle synchronization in Selenium.
- Implicit
- Explicit using wait and expected conditions
- Browser Navigation timeout
- Script time out
How to take screenshot in Selenium?
Selenium provides an interface called TakesScreenshot which has a method getScreenShotAs which can be used to take a screenshot of the application under test.
How to execute JavaScript in Selenium? How many arguments can be passed to executeScript method?
Selenium webdriver API provides one interface called JavascriptExecutor with a method called executeScript. This method has 2 main arguments. First argument is the javascript code you want to execute on current page and second argument is optional but important. We can pass variable number of web elements as an arguments which can be manipulated in javascript code passed in the first argument.
How to handle multiple browser windows and frames?
We can easily work with multiple windows and frames by switching to them. We can find all open windows in selenium using getWindowhandles method. We can find frame in the web page using name, id or any other method like css or xpath selectors.
How to drag and drop in Selenium Webdriver?
Selenium webdriver provides Actions class which has many methods to support complex user actions like contextClick, doubleClick, dragAndDrop.
How to use Selenium Grid?
Selenium grid is used to execute selenium scripts on various environments (OS and browsers) simultaneously and on different machines. Hub acts as a central server which sends the execution requests to the other machines called as nodes.
Hub server and node server must be up and running. Node machine must be registered with HUB. Depending upon the webdriver capabilities, HUB routes the request to appropriate node to execute the scripts.
Challenges, issues and limitations of Selenium tool? How to handle Captcha?
We can not handle captcha in Selenium. We can not also automate the Adobe Flash contents on webpages. These are some of the limitations of Selenium.
Other common issues are -
- Certificate Errors in IE
- Protect mode error
- Browser zoom error in IE
- Canvas image map
- Unsupported command line flag - ignore certificates warning in Chrome
What is the page object model in Selenium?
Page object model is an alternative way to handle automation project.
Write a complex xpath or css expression? Which one is better?
xpath and css can be used to find any element on the web page. Most of the engineers prefer writing xpath expressions as finding relative elements is very easy in xpath.
xpath and css can be used to find any element on the web page. Most of the engineers prefer writing xpath expressions as finding relative elements is very easy in xpath.
How to upload files using AUTOIT Script, Robot?
We can use AUTOIT/Robot/Sikuli code to handle the window dialogs which are not supported by web driver.
Flash automation, silverlight Automation?
Selenium has no support for these controls. We need to use third party tools to automate these apps.
How to format date and time in Selenium in Java? How to compare dates?
We can format date in selenium using DateFormat object.
How to append a data to file in Selenium?
We can use File and FileWriter class to work with files in Selenium Webdriver.
Frameworks in Selenium - Data driven, Hybrid, Keyword, BDD - Cucumber, TestNG
Frameworks are used to speed up the automation testing by developing the test data, reusable functions and reports.
Database testing in Selenium?
We can use JDBC driver to connect to any database in Java.
How to work with Excel files in Selenium?
We can use JXL or POI library to work with excel files in Selenium.
We can use JXL or POI library to work with excel files in Selenium.
Find total time of execution in Selenium?
If we are using custom library, we can log the start and end time of the execution and then find the total execution time by subtracting end time from start time.
How to schedule the Test Suite Execution?
We can schedule the test suite execution using CI tools like hudson(Jenkins), Bamboo. Alternatively, we can use windows scheduler to launch the test execution.
How to send an email stating the execution status to all stakeholders in Selenium?
We can send mail in Java using javax.mail library.
What is the difference between findElement and findElements?
findElement returns the first matching element. If element is not found, NoElementFoundException is thrown. findElements returns the list of matching web elements. If no element is found, empty list is returned. Exception is not thrown.
What is the difference between Junit and TestNG. What are the various annotations and features?
TestNG is the new generation testing framework with lot of new useful features as compared to old Junit framework. Using TestNG, we can run the tests in parallel.
Automation of Android apps and Android Browsers using Selenium possible?
We can use Appium and Selendroid tools to automate mobile applications.
We can use Appium and Selendroid tools to automate mobile applications.
How to handle Ajax calls in Selenium?
When working with Ajax calls, we must be very careful to handle StaleElementStateException. This exception occurs when we refer to the stale (Old) element on page. To handle this error, we need to find the element again after ajax load new elements in the page.
When working with Ajax calls, we must be very careful to handle StaleElementStateException. This exception occurs when we refer to the stale (Old) element on page. To handle this error, we need to find the element again after ajax load new elements in the page.
Difference between Selenium and QTP. Competitors to Selenium Webdriver?
QTP is a licensed tool supporting automation of lot of applications based on .Net, Java, Web and much more. Selenium is a free tool and supports only web application automation testing.
What is desired capabilities?
Capabilities are used to set the values of the browser attributes before we launch any browser using selenium web driver.
Version control tools like SVN, GIT?
We use version control tools like SVN to track the changes to the files in a project and work in collaboration.
Build tools - Ant, Maven?
We use these tools to manage build activities for the Java project.
CI tools - Jenkin, Bamboo?
These are continuous integration tools helping in quick deployment of applications, testing them and reporting the issues in the code before it is too late. It helps in getting the application into production quickly and with more quality confidence.
These are continuous integration tools helping in quick deployment of applications, testing them and reporting the issues in the code before it is too late. It helps in getting the application into production quickly and with more quality confidence.
How to identify the frame which does not have Id as well as name?
We can identify the frame using xpath or css selectors as well.
We can identify the frame using xpath or css selectors as well.
What is the alternative to sendkeys?
We can use JavaScriptExecutor to work with html controls.
We can use JavaScriptExecutor to work with html controls.
How to press TAB key in Selenium?
We can press any keyboard key using Keys class.
We can press any keyboard key using Keys class.
What are the Exception that may occur in Selenium Webdriver
Selenium may throw below exceptions.
What do you think on above selenium topic. Please provide your inputs and comments. You can write to me at reply2sagar@gmail.com
Selenium may throw below exceptions.
- InvalidElementStateException
- StaleElementReferenceException
- ElementNotFoundException
- ElementNotVisibleException
What do you think on above selenium topic. Please provide your inputs and comments. You can write to me at reply2sagar@gmail.com