Selenium Interview Questions And Answers
Download Selenium Interview Questions and Answers PDF
Refine your Selenium interview skills with our 66 critical questions. Each question is crafted to challenge your understanding and proficiency in Selenium. Suitable for all skill levels, these questions are essential for effective preparation. Download the free PDF now to get all 66 questions and ensure you're well-prepared for your Selenium interview. This resource is perfect for in-depth preparation and boosting your confidence.
66 Selenium Questions and Answers:
Selenium Job Interview Questions Table of Contents:
1 :: Tell me is it possible to use Selenium for multi-user Load Testing?
Yes, but it requires a LOT of hardware. We recommend you check out
BrowserMob, which does load testing with real browsers and is powered by
Selenium.
Read MoreBrowserMob, which does load testing with real browsers and is powered by
Selenium.
2 :: Do you know actual end user simulation, Is the test conducted using this tool
equivalent to an end user action?
Selenium performs actions in the background on the browser. It modifies
the DOM structure of the HTML page in order to perform actions on the
page. To be more precise it executes JavaScript on UI objects within the
webpage to perform actions like click, type, select etc. This is the
reason why you can execute tests with the browser minimized.
QTP claims to perform end user simulation, in other words executing QTP
scripts are equivalent to a person performing those steps manually on
the application.
Read Morethe DOM structure of the HTML page in order to perform actions on the
page. To be more precise it executes JavaScript on UI objects within the
webpage to perform actions like click, type, select etc. This is the
reason why you can execute tests with the browser minimized.
QTP claims to perform end user simulation, in other words executing QTP
scripts are equivalent to a person performing those steps manually on
the application.
3 :: Explain how to configure Selenium RC with eclipse to run Junit Tests?
1) Download eclipse. click here to download the software
2) Open eclipse -> Workspace Launcher window will open
3) Create a workspace by giving meaningful name
3) Click on Workbench
4) Create a project of type java
5) Create a package under src folder of the package
6) Add Junit to the build path
7) Add selenium rc java client driver to the build path
8) Now drag and drop your test script (.which is exported from Selenium
IDE) to the package created.
Read More2) Open eclipse -> Workspace Launcher window will open
3) Create a workspace by giving meaningful name
3) Click on Workbench
4) Create a project of type java
5) Create a package under src folder of the package
6) Add Junit to the build path
7) Add selenium rc java client driver to the build path
8) Now drag and drop your test script (.which is exported from Selenium
IDE) to the package created.
4 :: Explain what is the difference between Thread.Sleep() and Selenium.setSpeed()?
Selenium.setSpeed:
1. takes a single argument in string format
ex: selenium.setSpeed("2000") - will wait for 2 seconds
2. Runs each command in after setSpeed delay by the number of
milliseconds mentioned in setSpeed.
Thread.sleep:
1. takes a single argument in integer format
ex: thread.sleep(2000) - will wait for 2 seconds
2. Waits for only once at the command given at sleep.
Read More1. takes a single argument in string format
ex: selenium.setSpeed("2000") - will wait for 2 seconds
2. Runs each command in after setSpeed delay by the number of
milliseconds mentioned in setSpeed.
Thread.sleep:
1. takes a single argument in integer format
ex: thread.sleep(2000) - will wait for 2 seconds
2. Waits for only once at the command given at sleep.
5 :: Tell me what are the basic annotations used to run TestNG tests in Selenium?
The basic annotations used to run TestNG tests in Selenium RC:
1. @BeforeClass: The annotated method with @BeforeClass will be run
before the first test method in the current class is invoked.
2. @AfterClass: The annotated method with @AfterClass will be run after
all the test methods in the current class have been run.
3. @BeforeMethod: The annotated method with @BeforeMethod will be run
before each test method.
4. @AfterMethod: The annotated method with @AfterMethod will be run
after each test method.
5. @Test: Marks a class or a method @Test with as part of the test.
Read More1. @BeforeClass: The annotated method with @BeforeClass will be run
before the first test method in the current class is invoked.
2. @AfterClass: The annotated method with @AfterClass will be run after
all the test methods in the current class have been run.
3. @BeforeMethod: The annotated method with @BeforeMethod will be run
before each test method.
4. @AfterMethod: The annotated method with @AfterMethod will be run
after each test method.
5. @Test: Marks a class or a method @Test with as part of the test.
6 :: Explain does Selenium support mobile internet testing?
Selenium supports Opera and opera is used in most of the Smart phones.
So whichever Smart phone supports opera, selenium can be used to test.
So, one can use Selenium RC to run the tests on mobiles.
Read MoreSo whichever Smart phone supports opera, selenium can be used to test.
So, one can use Selenium RC to run the tests on mobiles.
7 :: Tell me what is the architecture of Selenium RC?
The Selenium Server launches and kills browsers and acts as an HTTP
proxy for browser requests.
Client libraries for various programming languages, each of which
instructs the Selenium Server in how to test the AUT by passing it your
test script’s Selenium commands.
The client libraries communicate with the Server passing each Selenium
command for execution. Then the server passes the Selenium command to
the browser using Selenium-Core JavaScript commands. The browser, using
its JavaScript interpreter, executes the Selenium command, which
effectively, runs the check you specified in your Selenese test script.
Read Moreproxy for browser requests.
Client libraries for various programming languages, each of which
instructs the Selenium Server in how to test the AUT by passing it your
test script’s Selenium commands.
The client libraries communicate with the Server passing each Selenium
command for execution. Then the server passes the Selenium command to
the browser using Selenium-Core JavaScript commands. The browser, using
its JavaScript interpreter, executes the Selenium command, which
effectively, runs the check you specified in your Selenese test script.
8 :: Explain how many testing frameworks can QA Tester use in Selenium RC?
Testing frameworks aren't required, but they can be helpful if QA Tester
wants to automate test cases. Selenium RC supports Bromine, JUnit,
NUnit, RSpec (Ruby), Test::Unit (Ruby), TestNG (Java), unittest (Python).
Read Morewants to automate test cases. Selenium RC supports Bromine, JUnit,
NUnit, RSpec (Ruby), Test::Unit (Ruby), TestNG (Java), unittest (Python).
9 :: Do you know why Selenium RC is used?
We use Selenium RC for:
Selenium-IDE does not directly support:
1. Condition statements.
2. Iteration.
3. Logging and reporting of test results.
4. Error handling, particularly unexpected errors.
5. Database testing.
6. Test case grouping.
7. Re-execution of failed tests.
8. Test case dependency.
9. Capture screen shots on test failures.
The reason behind why Selenium-IDE does not support the above mentioned
requirements is IDE supports only HTML language. Using HTML language we
cannot achieve the above mentioned requirements. Because HTML does not
support conditional, looping and external source connectives.
To overcome the above mentioned problems Selenium RC is used.
Read MoreSelenium-IDE does not directly support:
1. Condition statements.
2. Iteration.
3. Logging and reporting of test results.
4. Error handling, particularly unexpected errors.
5. Database testing.
6. Test case grouping.
7. Re-execution of failed tests.
8. Test case dependency.
9. Capture screen shots on test failures.
The reason behind why Selenium-IDE does not support the above mentioned
requirements is IDE supports only HTML language. Using HTML language we
cannot achieve the above mentioned requirements. Because HTML does not
support conditional, looping and external source connectives.
To overcome the above mentioned problems Selenium RC is used.
10 :: Suppose if a Selenium function requires a pattern argument, what five
prefixes might that argument have?
Five prefixes that Selenium pattern argument are:
glob, regexp, exact, regexpi.
Read Moreglob, regexp, exact, regexpi.
11 :: Explain if a Selenium function requires a script argument, what would that
argument look like in general terms?
StoreEval(script, variable) and storeExpression(expression, variableName).
Read More12 :: Tell me what is the difference between an assert and a verify with Selenium
commands?
Assert: Will fail and abort the current test execution.
Verify: Will fail and continue to run the test execution.
Read MoreVerify: Will fail and continue to run the test execution.
13 :: what are the Operating Systems supported by Selenium?
Operating Systems supported by Selenium are:
Selenium IDE
Works in Firefox 2+ Start browser, run tests Run tests
Operating Systems Supported:
1. Windows,
2. OS X
3. Linux
4. Solaris
5. Others whichever supports Firefox 2+
Selenium Remote Control
Used for starting browser and run tests
Operating Systems Supported:
1. Windows,
2. OS X
3. Linux
4. Solaris
5. Others
Selenium Core
Used for running tests
Operating Systems Supported:
1. Windows,
2. OS X
3. Linux
4. Solaris
5. Others
Read MoreSelenium IDE
Works in Firefox 2+ Start browser, run tests Run tests
Operating Systems Supported:
1. Windows,
2. OS X
3. Linux
4. Solaris
5. Others whichever supports Firefox 2+
Selenium Remote Control
Used for starting browser and run tests
Operating Systems Supported:
1. Windows,
2. OS X
3. Linux
4. Solaris
5. Others
Selenium Core
Used for running tests
Operating Systems Supported:
1. Windows,
2. OS X
3. Linux
4. Solaris
5. Others
14 :: Tell me which are the browsers supported by Selenium RC?
Browsers supported by Selenium RC are:
1. firefox
2. mock
3. firefoxproxy
4. pifirefox
5. chrome
6. iexploreproxy
7. explore
8. firefox3
9. safariproxy
10. googlechrome
11. konqueror
12. firefox2
13. safari
14. piiexplore
15. firefoxchrome
16. opera
17. iehta
18. custom
Read More1. firefox
2. mock
3. firefoxproxy
4. pifirefox
5. chrome
6. iexploreproxy
7. explore
8. firefox3
9. safariproxy
10. googlechrome
11. konqueror
12. firefox2
13. safari
14. piiexplore
15. firefoxchrome
16. opera
17. iehta
18. custom
15 :: What are the capabilities of Selenium WebDriver or Google WebDriver
or Selenium 2.0?
Capabilities of Selenium WebDriver or Google WebDriver or Selenium 2.0 are:
One should use WebDriver when requiring improved support for
1. Mult-browser testing including improved functionality for browsers
not well-supported by Selenium-1.0.
2. Handling multiple frames, multiple browser windows, pop-ups, and alerts.
3. Page navigation.
4. Drag-and-drop.
5. AJAX-based UI elements.
Read MoreOne should use WebDriver when requiring improved support for
1. Mult-browser testing including improved functionality for browsers
not well-supported by Selenium-1.0.
2. Handling multiple frames, multiple browser windows, pop-ups, and alerts.
3. Page navigation.
4. Drag-and-drop.
5. AJAX-based UI elements.
16 :: Which is the command used for displaying the values of a variable
into the output console or log?
The command used for displaying the values of a variable into the output
console or log–echo
If you want to display a constant string. The below mentioned command
can be used
echo <constant string>
ex: echo “The sample message”
If you want to display the value of a variable it can be written like below
echo ${<variable name>>
ex: echo ${var1}
Read Moreconsole or log–echo
If you want to display a constant string. The below mentioned command
can be used
echo <constant string>
ex: echo “The sample message”
If you want to display the value of a variable it can be written like below
echo ${<variable name>>
ex: echo ${var1}
17 :: What are the limitations of Selenium IDE?
The limitations of Selenium IDE are:
1) Selenium IDE uses only HTML language
2) Conditional or branching statements execution like using of if, select statements is not possible
3) Looping statements using is not possible directly in Selenium HTML language in ide
4) Reading from external files like .txt, .xls is not possible
5) Reading from the external databases is not possible with ide
6) Exceptional handling is not there
7) A neat formatted Reporting is not possible with ide
To eliminate the above issues we use Selenium RC
Read More1) Selenium IDE uses only HTML language
2) Conditional or branching statements execution like using of if, select statements is not possible
3) Looping statements using is not possible directly in Selenium HTML language in ide
4) Reading from external files like .txt, .xls is not possible
5) Reading from the external databases is not possible with ide
6) Exceptional handling is not there
7) A neat formatted Reporting is not possible with ide
To eliminate the above issues we use Selenium RC
18 :: How do you set user extensions in Selenium IDE?
1. Open user-extensions.js with an editor (Notepad, etc.); it's found in the selenium\core\scripts folder. If it doesn't exist, just create it.
2. If you need to, commit the user-extensions.js file (like if you use subversion).
3. Open Selenium IDE and choose the Options menu and then Options... from that menu.
4. Make sure the path to your user-extensions.js file is entered in the Selenium Core extensions field (like \selenium\core\scripts\user-extensions.js)
5. Press OK button on options
6. Restart the IDE to reflect your extensions.
Note: After reopen, Selenium IDE may show compilations errors if the user-extensions.js file has any syntax errors.
Read More2. If you need to, commit the user-extensions.js file (like if you use subversion).
3. Open Selenium IDE and choose the Options menu and then Options... from that menu.
4. Make sure the path to your user-extensions.js file is entered in the Selenium Core extensions field (like \selenium\core\scripts\user-extensions.js)
5. Press OK button on options
6. Restart the IDE to reflect your extensions.
Note: After reopen, Selenium IDE may show compilations errors if the user-extensions.js file has any syntax errors.
19 :: What is the difference between captureEntirePageScreenshot and CaptureScreenShot?
captureEntirePageScreenshot
1. This captures the AUT web page only
2. This supports only mozilla firefox
3. Accepts two arguments. one is the file name to be saved and other argument is back ground color
CaptureScreenShot
1. This captures the System screen shot
2. This supports all the browsers when you run from Selenium RC
3. Accepts one argument. That is the file name to be saved.
Read More1. This captures the AUT web page only
2. This supports only mozilla firefox
3. Accepts two arguments. one is the file name to be saved and other argument is back ground color
CaptureScreenShot
1. This captures the System screen shot
2. This supports all the browsers when you run from Selenium RC
3. Accepts one argument. That is the file name to be saved.
20 :: Which are the commands used for capturing the bitmaps?
captureEntirePageScreenshot
Saves the entire contents of the current window canvas to a PNG file. Contrast this with the captureScreenshot command, which captureS the contents of the OS viewport (i.e. whatever is currently being displayed on the monitor), and isimplemented in the RC only. Currently this only works in Firefox when running in chrome mode, and in IE non-HTA using the EXPERIMENTAL "Snapsie" utility. The Firefox implementation is mostly borrowed from the Screengrab! Firefox extension. Please see captureEntirePageScreenshot for more details
captureEntirePageScreenshotAndWait
Saves the entire contents of the current window canvas to a PNG file. Contrast this with the captureScreenshot command, which captures the contents of the OS viewport (i.e. whatever is currently being displayed on the monitor), and is implemented in the RC only. Currently this only works in Firefox when running in chrome mode, and in IE non-HTA using the EXPERIMENTAL "Snapsie" utility. The Firefox implementation is mostly borrowed from the Screengrab! Firefox extension. Please see
captureEntirePageScreenshotAndWait for details.
Note: This command runs with only mozilla firefox when you run the tests from RC. Other browsers it will not support
Read MoreSaves the entire contents of the current window canvas to a PNG file. Contrast this with the captureScreenshot command, which captureS the contents of the OS viewport (i.e. whatever is currently being displayed on the monitor), and isimplemented in the RC only. Currently this only works in Firefox when running in chrome mode, and in IE non-HTA using the EXPERIMENTAL "Snapsie" utility. The Firefox implementation is mostly borrowed from the Screengrab! Firefox extension. Please see captureEntirePageScreenshot for more details
captureEntirePageScreenshotAndWait
Saves the entire contents of the current window canvas to a PNG file. Contrast this with the captureScreenshot command, which captures the contents of the OS viewport (i.e. whatever is currently being displayed on the monitor), and is implemented in the RC only. Currently this only works in Firefox when running in chrome mode, and in IE non-HTA using the EXPERIMENTAL "Snapsie" utility. The Firefox implementation is mostly borrowed from the Screengrab! Firefox extension. Please see
captureEntirePageScreenshotAndWait for details.
Note: This command runs with only mozilla firefox when you run the tests from RC. Other browsers it will not support
21 :: How to capture bitmaps in Selenium?
Bitmaps are captured using the Selenium set of commands. There are two modes of capturing the bitmaps
1) Capture the bitmap for the entire page - it captures the browser main page area of AUT
2) Capture the bitmap for the screen shots - it captures the entire screen shot like the print scree that you give from your keyboard
Selenium doesn't support bitmap capturing for an element on AUT.
Read More1) Capture the bitmap for the entire page - it captures the browser main page area of AUT
2) Capture the bitmap for the screen shots - it captures the entire screen shot like the print scree that you give from your keyboard
Selenium doesn't support bitmap capturing for an element on AUT.
22 :: When to use Accessors in Selenium?
Accessors are mostly used for storing the value in a variable.
The variable can be used for following reasons:
1) To get the value from an element and comparing with some dynamic value
2) To take a logical decision to execute the test steps
ex: if the value of the variable true execute step1 and step2 else step3 and step4
3) To execute some statements in a loop based on the value returned by the element
Read MoreThe variable can be used for following reasons:
1) To get the value from an element and comparing with some dynamic value
2) To take a logical decision to execute the test steps
ex: if the value of the variable true execute step1 and step2 else step3 and step4
3) To execute some statements in a loop based on the value returned by the element
23 :: What is an Accessor in Selenium?
Accessor is one of the type of Selenese.
I. Accessors are used for storing the value of a target in a variable.
Ex:
1) storeTitle - Stores the title of a window in a variable
2) storeText - Stores the target element text in a variable
II. Accessors are also used for evaluating the result and storing the result in a variable
Ex: storeTextPresent - Evaluates whether the text is Present in the current window. If the text is present storestrue in the variable else stores false
Ex: storeEementPresent - Evaluates whether the element is present in the current window. If the element is present stores true in the variable else stores false
Read MoreI. Accessors are used for storing the value of a target in a variable.
Ex:
1) storeTitle - Stores the title of a window in a variable
2) storeText - Stores the target element text in a variable
II. Accessors are also used for evaluating the result and storing the result in a variable
Ex: storeTextPresent - Evaluates whether the text is Present in the current window. If the text is present storestrue in the variable else stores false
Ex: storeEementPresent - Evaluates whether the element is present in the current window. If the element is present stores true in the variable else stores false
24 :: When to use Assert, Verify and WaitFor in Selenium?
1) assert - If the expected value is mandatory to continue with the next set of steps we will use Assert. As Assert aborts the test, if the expected value doesn't match. It is good to use for any mandatory checks.
2) verify - If the expected value is optional to continue with the next set of steps we will use Verify. As Verify continues executing with the next set of steps, if the expected value doesn't match. It is good to use for any optional checks.
3) waitFor - If your test needs to wait, if the expected value is not matching we use waitFor. We normally use waitFor for AJAX kind of controls loading within a page.
Read More2) verify - If the expected value is optional to continue with the next set of steps we will use Verify. As Verify continues executing with the next set of steps, if the expected value doesn't match. It is good to use for any optional checks.
3) waitFor - If your test needs to wait, if the expected value is not matching we use waitFor. We normally use waitFor for AJAX kind of controls loading within a page.
25 :: What are the types of Assertions there in Selenium?
Selenium Assertions can be used in 3 modes:
1) assert - When an “assert” fails, the test will be aborted. If you are executing test suite, the next state case will start
2) verify - When a “verify” fails, the test will continue execution, logging the failure.
3) waitFor - “waitFor” commands wait for some condition to become true (which can be useful for testing Ajax applications). They will succeed immediately if the condition is already true. However, they will fail and halt the test if the condition does not become true within the current timeout setting.
Read More1) assert - When an “assert” fails, the test will be aborted. If you are executing test suite, the next state case will start
2) verify - When a “verify” fails, the test will continue execution, logging the failure.
3) waitFor - “waitFor” commands wait for some condition to become true (which can be useful for testing Ajax applications). They will succeed immediately if the condition is already true. However, they will fail and halt the test if the condition does not become true within the current timeout setting.