“The tools of the interviewer are his questions,” notes the Harvard Business Review, and through expert use of questions, an experienced interviewer sizes up an applicant’s skills, talents, and job suitability.
In case of a job opening for a Selenium Automation Tester, recruiters know that everything from the interview to your everyday job will be circumscribed by the sense of urgency. Contemporary interviews work with limited time and yet the HR team must pick someone who can deliver on a deadline, or else, app releases are at stake.
This is especially so for intermediate and senior-level Selenium testers. For entry-level or junior posts, recruiters may ask basic Selenium interview questions. However, when interviewing someone with 4 or more years of experience, interviewers are not only exhaustive, but also detailed in their approach. As a candidate, you are tested based on the breath of your knowledge as well as your experience in troubleshooting certain finer issues.
To help you prepare for a mid-career Selenium Automation Tester job, here are 7 tricky and nuanced interview questions with appropriate answers.
1. How to handle an Authentication Pop-up using Selenium WebDriver?
Here are 3 ways how you can do that.
– Via the URL
Here, one is passing the username and password via the URL.
The syntax is: http://username:password@URL
For example,
Username: rohit
Password: P@ssword
URL: www.myurl.com
String URL = “http://” + rohit + ”:” + P@ssword + “@” + www.myurl.com;
driver.get(URL);
Alert alert = driver.switchTo().alert();
alert.accept();
– Using AutoIT
Sample AutoIT script,
WinWaitActivate(“Authentication Required”,””)
Send(“rohit{TAB}P@ssword{ENTER}”)
The AutoIT script would be passed within the Java code
– With Alerts
One can handle auth pop-ups with alerts with,
driver.switchTo().alert();
//WebDriver Java Code for entering Username and Password
driver.findElement(By.id(“userID”)).sendKeys(“userName”);
driver.findElement(By.id(“password”)).sendKeys(“myPassword”);
driver.switchTo().alert().accept();
driver.switchTo().defaultContent();
In case passing by URL does not work, one can also obtain credentials by Chrome extensions and driver.
2. The Selenium script runs in Chrome but not in IE. What can be done?
1. Using the updated Selenium IE Driver
2. Verifying that the IE driver and working environment are compatible
3. Configuring the IE driver with the setProperty method and by importing dependencies
4. Setting the same value for the ‘Enable Protected Mode’ option for all zones from the Security tab
5. Turning off the internet security settings in IE when running the script
6.Using CSS Selectors to minimise exceptions
7. Setting a registry entry
8. Avoiding declaring the driver instance as static for running scripts on browsers parallelly
9. Using the latest Selenium jars
10. Enabling Javascript on the IE browser
11. Using JavaScriptExecutor instead of native click when clicking elements
3. What is the difference between ChromeOptions and DesiredCapabilities?
ChromeOptions options = new ChromeOptions()
options.addArgument(“disable-extensions”);
ChromeDriver driver = new ChromeDriver(options);
DesiredCapabilities can also be used to manipulate a ChromeDriver session. To change individual web driver properties, DesiredCapabilities class provides key-value pairs.
But, ChromeOptions supports limited clients whereas DesiredCapabilities supports a vast number of clients. ChromeOptions is supported by Java and other languages. DesiredCapabilities is available in Java, but its use is deprecated. When working with a client library, like Selenium Ruby Client, the ChromeOption class will not be available and DesiredCapabilities will have to be used.
DesiredCapabilities are commonly used with Selenium Grid, for parallel execution of test cases on different browsers. However, one can use both DesiredCapabilities and ChromeOptions using merge:
DesiredCapabilities capabilities = new DesiredCapabilities();
options = new ChromeOptions();
options.merge(capabilities);
driver = new ChromeDriver(options);
4. Is it possible to do responsive web design testing using Selenium?
For visual validations, one can do RWD testing with Ocular library. Similarly, WAVE Evaluator can be used for check compliance with accessibility standards automatically.
5. What is the need of database automation testing? Is it possible to perform database testing with Selenium?
– Defect-free data processing
– ACID properties validation (ACID means Atomicity, Consistency, Isolation and Durability)
– Accurate storage and retrieval of values in and from the database
– Data integrity and proper data mapping
– Bugs that cannot be found in front-end testing are brought to light
Yes, it’s possible to do database testing with Selenium. First you need to make a connection between the server and the database. To do so you need a JDBC connection. JDBC is an SQL-based Java API that allows for connectivity between the Java programming language and various databases. With JDBC it is possible to connect with the database and execute queries. Once these two steps are done, one can process the results. Key components of JDBC are:
1. Driver manager
2. Driver
3. Connection
The syntax to connect with the database is:
DriverManager.getConnection(URL, “userid”, “password” )
Similarly, the code to load the JDBC driver is:
Class.forName(“com.mysql.jdbc.Driver”);
To send queries to the database one can use the Statement object. Similarly, to process the data one can use a getXXX() method.
6. Why are assertions important in Selenium? What are different types of assertions?
There are 2 types of assertions:
1. Soft assert
This type of assertion will just verify the condition and give the result, but it won’t abort the test case execution when the test case fails.
2. Hard Assert
This type of assertion checks for the expected result, and if the condition fails to match, it will abort execution and throw the “java.lang.AssertionError” exception.
The different types of hard assertions in Selenium are:
assertEquals()
assertNotEquals()
assertNull()
assertNotNull()
assertTrue()
assertFalse()
7. What is a data-driven framework? How does dataProvider help in data driven testing?
The @dataProvider annotation in TestNG, a testing framework, helps testers automate test cases and thereby achieve data-driven testing.
The annotation is:
@DataProvider(name= “searchProvider”)
The return type of the @dataProvider annotation is a 2D array. So, if the array is 3*4 objects, there will be 3 test cases, each having 4 parameters.
These 7 tricky and nuanced Selenium interview questions are sure to leave you wanting to delve deeper into core concepts and explore further the practical issues that may arise when testing. As you whet your appetite for more, have our dynamic skill assessment and machine learning algorithms vet your profile and pave the way for an automation tester job at a Fortune 500 company.
All you need to do is sign up with Talent500 today. You’ll then be the focus of companies looking for the top 10% of talent and have a way to match your skill sets to the best job openings!