DevLabs Alliance - WhatsApp
DevLabs Alliance Logo

Home / Blogs /Top Selenium Interv...

Top Selenium Interview Questions – 2024



DevLabs Alliance Blogs

0 mins read

Q1. What are MaxInstances Properties in Selenium Grid?

MaxInstances is defined as the number of browser instances of the same version of the browser that can run on the remote machine.

for eg.

-browser browserName=InternetExplorer,version=11,maxInstances=3,platform=WINDOWS

-browser browserName=Firefox,version=12,maxInstances=2,platform=WINDOWS

This will allow running 5 instances (3 instances of IE and 2 instances of Firefox) at the same time on a remote machine.

Q2. What are MaxSession Properties in Selenium Grid?

MaxSession is defined as a number of browsers, independent of the type & version, that can run in parallel on the remote machine.

MaxSession overrides the MaxInstances settings and hence can restrict the number of browser instances that can run in parallel.

For eg.

If maxSession=1 then only a single browser will run on a remote machine. If maxSession=2 then any two browsers can run at a time irrespective of MaxInstances that we defined. It can be either 2 Internet Explorer or 2 Firefox or 1 Internet Explorer and 1 Firefox.

browser browserName=firefox,maxInstances=5,maxSession=2

Q3. How can we handle Web-based Pop-ups or Alerts in Selenium?

Web-based alerts or popups are handled by switching to the alert window and calling Selenium WebDriver Alert API methods.

Below methods are called for various actions:

  • dismiss(): To click on the Cancel button.
  • accept(): To Click on the OK button.
  • getText(): To get the text which is present on the Alert.
  • sendKeys(): To enter the text into the alert box

Q4. What happens if you mix both Threads. Sleep and WebDriver Waits in a Selenium Script?

Thread.sleep() method is used to pause the execution of the script for a specified time in milliseconds.

If WebDriver waits are used along with Thread.sleep() method, then webdriver will hold the execution for a specified time (as mentioned in Thread.sleep()) and then will follow another wait. If we mix both the waits, then the test execution time will increase.

Q5. How can you use the Recovery Scenario in Selenium WebDriver?

Recovery Scenarios are used by using the “Try Catch” block within Selenium WebDriver Java


Q6. What is Robot Class in Selenium and what are its advantages?

Robot Class is used to control the keyboard or mouse to interact with Operating System windows like download pop-ups, alerts, print pop-ups, etc, or native OS applications like Notepad, Calculator, Skype, etc. while doing browser automation.

The various advantages of Robot Class are:

  • It simulates Mouse and Keyboard events.
  • It helps in the upload/download of files while using Selenium webdriver.
  • It gets easily integrated with the current automation framework (keyword-driven, data-driven, or hybrid framework).

Q7. What are various Robot Class internal methods and explain their usage?

Some of the Robot Class Internal methods and their usage are as follows:

  • keyPress(): eg. : robot.keyPress(KeyEvent.VK_Down) : This method will press down the arrow key of keyboard.

  • mouseMove(): eg. robot.mouseMove(point.getX(), point.getY()) : This will move the mouse pointer to specific X and Y coordinates.

  • mousePress(): eg. robot.mousePress(InputEvent.BUTTON_DOWN_MASK): This method will press the right click of mouse.

  • mouseRelease(): eg. robot.mouseRelease(InputEvent.BUTTON_DOWN_MASK): This method will release the right click of mouse.

  • keyRelease(): eg. robot.keyRelease(KeyEvent.VK_DOWN): This method will release the down arrow key of keyboard.

Q8. How to Upload a file in Selenium WebDriver?

We can upload a file in Selenium WebDriver using the AutoIT script. Follow the following steps for uploading a file with the AutoIT script:

  • Download and Install the “AutoIT”.
  • Open Eclipse and write code through Selenium WebDriver on clicking on the “Upload File” button.
  • Ensure FileUpload.exe is generated after compilation in the location where AutoIT is installed. This FileUpload.exe already contains the file(say, devLabsAlliance.docx) to be uploaded and this is pre-configured through the AutoIT editor.
  • After clicking of Upload button, the AutoIT script needs to be called, and then the control is immediately transferred to AutoIT in order to upload a file, and then the control is sent back to Selenium.

  • Syntax for calling AutoIT script:
  • Runtime.getRuntime().exec(“D:\\AutoIT\\FileUpload.exe”);

Q9. How to run Selenium test from Command Line in Selenium WebDriver?

For doing this, we need to install TestNG and need to set the classpath.

Follow the below steps:

Q10. How to connect a database in Selenium?

To connect a database in Selenium, we use the JDBC driver while using the Java Programming language.

Follow the below steps to connect the database in Selenium:

  • Load the required JDBC driver class.
  • Class.forName(“net.sourceforge.jtds.jdbc.Driver”);
  • Establish a connection to the database:
  • Connection con = DriverManager.getConnection(“DataBaseURL”, “userName”, “password”);
  • Connection URL:
  • jdbc:sqlserver://ipAddress:portNumber/dbName
  • Execute SQL Queries:
  • Statement sqlStatement = con.createStatement();
  • String sqlQuery = “SELECT * FROM table_name WHERE condition”
  • ResultSet resSet = sqlStatement.executeQuery(sqlQuery);
  • Fetching data from resultSet:
  • while ( {
  • System.out.println(resSet.getString(required_column_name));}
  • Closing the database connection. con.close();

Know Our Author

DevLabs Alliance Author Bio


DevLabs Alliance TwitterDevLabs Alliance LinkedInDevLabs Alliance Instagram

Author Bio

DevLabs Alliance conducts career transformation workshops & training in Artificial Intelligence, Machine Learning, Deep Learning, Agile, DevOps, Big Data, Blockchain, Software Test Automation, Robotics Process Automation, and other cutting-edge technologies.


Want To Know More

Email is valid


By tapping continuing, you agree to our Privacy Policy and Terms & Conditions

“ The hands-on projects helped our team put theory into practice. Thanks to this training, we've achieved seamless collaboration, faster releases, and a more resilient infrastructure. ”
DevLabs Alliance Blogs Page Review
Vijay Saxena

SkillAhead Solutions

DevLabs Alliance Footer section
DevLabs Alliance LinkedIn ProfileDevLabs Alliance Twitter ProfileDevLabs Alliance Facebook ProfileDevLabs Alliance Facebook Profile
DevLabs Alliance Logo



1603, Capitol Avenue, Suite 413A, 2659, Cheyenne, WY 82001, USA

DevLabs Alliance ISO 9001

DevLabs Alliance Footer SectionDevLabs Alliance Footer SectionDevLabs Alliance Footer SectionDevLabs Alliance Footer SectionDevLabs Alliance Footer SectionDevLabs Alliance Footer SectionDevLabs Alliance Footer SectionDevLabs Alliance Footer SectionDevLabs Alliance Footer Section

`Copyright © DevLabs Alliance. All rights Reserved`


Refund & Reschedule Policy

Privacy Policy

Terms of Use