Why String and Array are not Primary data type in Java ?

The term "data type" and "primitive data type" are often used interchangeably. Primitive data types are predefined types of data, which are supported by the programming language.

For example, integer, character, and string are all primitive data types. Programmers can use these data types when creating variables in their programs.

For example, a programmer may create a variable called "lastname" and define it as a string data type. The variable will then store data as a sequence of characters.

Non-primitive data types are not defined by the programming language, but are instead created by the programmer.

They are sometimes called "reference variables," or "object references," since they reference a memory location, which stores the data.

In the Java programming language, non-primitive data types are simply called "objects" because they are created, rather than predefined.

While an object may contain any type of data, the information referenced by the object may still be stored as a primitive data type.

Array and String are not predefined data types, these are created by the user because of this Array and String are not primitive data types.

How to exclude a particular test method from a test case execution?

We can exclude a particular testcase by adding the exclude tag in the testng.xml or by setting enabled attribute to false

							  <class name="TestCaseName">
								   <exclude name="TestMethodNameToExclude"/>

Explain methods in Interface ?

YES, we can have private methods in interface in java 9, private methods could be static or non-static. In both cases, the private method is not inherited by sub-interfaces or implementations.

They are mainly there to improve code re-usability within same interface only – thus improving encapsulation.

Using private methods in interfaces have four rules :

1. Private interface methods cannot be abstract.
2. Private method can be used only inside interface.
3. Private static method can be used inside other static and non-static interface methods.
4. Private non-static methods cannot be used inside private static methods.

Interfaces can below item in interface in Java9 (aka JDK 1.9) :

1. Constant variables
2. Abstract methods
3. Default methods
4. Static methods
5. Private methods
6. Private Static methods

										package frames;

										interface ISam {
											public static final String name = "Java9";
											public void testAbstract();
											default void testDefault(){
												// call non-static method from another non-static method.
												// call static method from non-static method
												System.out.println("Default method");
											public static void testStatic(){
												System.out.println("static method");
											private void testPrivateNonStatic(){
												System.out.println("private non-static method");
											private static void testPrivateStatic(){
												System.out.println("private static method");

										public class Sample implements ISam{
											public void testAbstract() {
												System.out.println("Overridden 'testAbstract' method");
											public static void main(String[] args) {
												System.out.println("constant variable value : "+ name);
												// access static method
												// create object for Sample class
												Sample sam = new Sample();
												// we can access default method using object
												// call abstract method (implementation in Sample class)



											constant variable value : Java9
											static method
											private non-static method
											private static method
											Default method
											Overridden 'testAbstract' method
Check If An Element Exists?

You may need to perform a action based on a specific web element being present on the web page.
You can use below code snippet to check if a element with id 'element-id' exists on web page.

                        				System.out.println("Element exists");
                        			System.out.println("Element donot exists");

What is TestNG?

TestNG is a testing framework designed to simplify a broad range of testing needs, from unit testing to integration testing.

What are the advantages of TestNG?

1. TestNG provides parallel execution of test methods

2. TestNG uses more OO (object-oriented) and Java features

3. It allows to define dependency of one test method over other method

4. It supports testing integrated classes

5. It allows to assign priority to test methods

6. Separate compile time test code from data info /run time configuration

7. Flexible plug-in API

8. It allows grouping of test methods into test groups

9. Multi-threaded testing support

10. It has support for parameterizing test cases using @Parameters annotation

11. For the same test class TestNG support for multiple instances

12. It allows data driven testing using @DataProvider annotation

13. For logging no dependencies, default JDK functions for logging and run-time

15. It has different assertions that helps in checking the expected and actual results

16. Detailed (HTML) reports

Explain what are the basic steps required in writing TestNG tests?

1. Write down the business logic of your test and insert TestNG annotations in your code 2. In a build.xml or testing.xml, add the information about your test 3. Run TestNG

What are the annotations available in TestNG?












How to create and run testng.xml ?

In TestNG framework, we need to create testng.xml file to create and handle multiple test classes. We do configure our test run, set test dependency, include or exclude any test, method, class or package and set priority etc in the xml file.

What is the importance of testng.xml file?

In a Selenium TestNG project, we use testng.xml file to configure the complete test suite in a single file. Some of the features are as follows. 1. testng.xml file allows to include or exclude the execution of test methods and test groups

2. It allows to pass parameters to the test cases

3. Allows to add group dependencies

4. Allows to add priorities to the test cases

5. Allows to configure parallel execution of test cases

6. Allows to parameterize the test cases

What is TestNG Assert and list out common TestNG Assertions?

TestNG Asserts help us to verify the condition of the test in the middle of the test run. Based on the TestNG Assertions, we will consider a successful test only if it is completed the test run without throwing any exception. Some of the common assertions supported by TestNG are 1. assertEqual(String actual,String expected)

2. assertEqual(String actual,String expected, String message)

3. assertEquals(boolean actual,boolean expected)

4. assertTrue(condition)

5. assertTrue(condition, message)

6. assertFalse(condition)

7. assertFalse(condition, message)

What is Soft Assert / Verify in TestNG?

Soft Assert collects errors during @Test. Soft Assert does not throw an exception when an assert fails and would continue with the next step after the assert statement.

If there is any exception and you want to throw it then you need to use assertAll() method as a last statement in the @Test and test suite again continue with next @Test as it is.

What is Hard Assert in TestNG?

Hard Assert throws an AssertException immediately when an assert statement fails and test suite continues with next @Test

What is exception test in TestNG?

TestNG gives an option for tracing the Exception handling of code. You can verify whether a code throws the expected exception or not. The expected exception to validate while running the test case is mentioned using the expectedExceptions attribute value along with @Test annotation.

How to set test case priority in TestNG?

We use priority attribute to the @Test annotations. In case priority is not set then the test scripts execute in alphabetical order

									import org.testng.annotations.*;
									public class PriorityTestCase{
										public void testCase1() {											
											system.out.println("Test Case 1");
										public void testCase2() { 	 
											system.out.println("Test Case 2");

How to run test cases in parallel using TestNG?

we can use “parallel᾿ attribute in testng.xml to accomplish parallel test execution in TestNG The parallel attribute of suite tag can accept four values:

tests – TestNG will run all the methods in the same tag in the same thread, but each tag will be in a separate thread. This allows you to group all your classes that are not thread safe in the same and guarantee they will all run in the same thread while taking advantage of TestNG using as many threads as possible to run your tests.

classes – TestNG will run all the methods in the same class in the same thread, but each class will be run in a separate thread.

methods – TestNG will run all your test methods in separate threads. Dependent methods will also run in separate threads but they will respect the order that you specified.

instances – TestNG will run all the methods in the same instance in the same thread, but two methods on two different instances will be running in different threads..

the attribute thread-count allows you to specify how many threads should be allocated for this execution.

							<suite name="Regression" parallel="methods">

How to disable a test case in TestNG ?

To disable the test case we use the parameter enabled = false to the @Test annotation.

						@Test(enabled = false)


How to Ignore a test case in TestNG?

To ignore the test case we use the parameter enabled = false to the @Test annotation.

						@Test(enabled = false)


what are @Test attributes ?

@Test - Marks a class or a method as part of the test.

alwaysRun - If set to true, this test method will always be run even if it depends on a method that failed.

dataProvider - The name of the data provider for this test method.

dataProviderClass - The class where to look for the data provider. If not specified, the data provider will be looked on the class of the current test method or one of its base classes. If this attribute is specified, the data provider method needs to be static on the specified class.

dependsOnGroups - The list of groups this method depends on.

dependsOnMethods - The list of methods this method depends on.

description - The description for this method.

enabled - Whether methods on this class/method are enabled.

expectedExceptions - The list of exceptions that a test method is expected to throw. If no exception or a different than one on this list is thrown, this test will be marked a failure.

groups - The list of groups this class/method belongs to.

invocationCount - The number of times this method should be invoked.

invocationTimeOut - The maximum number of milliseconds this test should take for the cumulated time of all the invocationcounts. This attribute will be ignored if invocationCount is not specified.

priority - The priority for this test method. Lower priorities will be scheduled first.

successPercentage - The percentage of success expected from this method

singleThreaded - If set to true, all the methods on this test class are guaranteed to run in the same thread, even if the tests are currently being run with parallel="methods". This attribute can only be used at the class level and it will be ignored if used at the method level. Note: this attribute used to be called sequential (now deprecated).

timeOut - The maximum number of milliseconds this test should take.

threadPoolSize - The size of the thread pool for this method. The method will be invoked from multiple threads as specified by invocationCount. Note: this attribute is ignored if invocationCount is not specified

What is the time unit we specify in test suites and test cases?

We specify the time unit in test suites and test cases is in milliseconds.

List out the advantages of TestNG over Junit?

Advantages of JUnit over TestNG includes

1. Compare to JUnit annotations, TestNG are easy to understand

2. Unlike JUnit, TestNG does not require to declare @BeforeClass and @AfterClass

3. Method name constraint is not there in TestNG

4. TestNG allows you the grouping of test cases easily which is not possible in JUnit

5. TestNG supports following three additional setup: @Before/AfterSuite, @Before/AfterTest and @Before/AfterGroup

6. TestNG does not need to extend any class

7. In TestNG, it is possible to run selenium test cases in parallel

8. Based on group TestNG allows you to execute the test cases

9. TestNG allows you to determine the dependent test cases; each test case is autonomous to other test case

Explain what is Time-Out test in TestNG?

The Time-Out test in TestNG is nothing but time allotted to perform unit testing. If the unit test fails to finish in that specific time limit, TestNG will abandon further testing and mark it as a failed.

How to write regular expression in testng.xml file to search @Test methods containing "product" keyword.

Regular expression to find @Test methods containing keyword "product" Is as bellow.

															     <include name=".*product.*"/>

Explain what is exception test?

TestNG gives option for tracing the Exception handling of code. You can test whether a code throws the expected results or not. The expectedExceptions parameter is availed along with @Test annotation.

Explain what is parametric testing?

Parameterized testing allows developers to execute the same test over and over again using different values. In two different ways TestNG allows you to pass parameters directly to your test methods. 1. With testng.xml 2. With Data Providers

Explain how can you run the JUnit tests using TestNG?

You can run the JUnit tests using TestNG by 1. Placing JUnit library on the TestNG classpath, so it can locate and use JUnit classes

2. Change your test runner from JUnit to TestNG in Ant and then run TestNG in “mixed mode᾿ . This will bring all your test in the same

3. This approach also enables you to convert your existing JUnit test to TestNG

What does @Test(invocationCount=?) and (threadPoolSize=?) indicates?

@Test (threadPoolSize=?): The threadPoolSize attributes tell TestNG to form a thread pool to run the test method through multiple threads. With threadpool, the running time of the test method reduces greatly.

@Test(invocationCount=?): The invocationcount tells how many times TestNG should run this test method

Mention different ways in which you can produce reports for TestNG results?

There are two ways to produce a report with Test NG, they are

Listeners: For a listener class to implement, the class has to implement the org.testng./TestListener interface. These classes are informed at runtime by TestNG when the test begins, finsishes, skips, passes or fails.

Reporters: For a reporting class to implement, the class has to implement an org.testng/Reporter interface. When the whole suite run ends, these classes are called. When called, the object consisting the information of the whole test run is delivered to this class.

How to pass parameter with testng.xml file to use It In test case?

We can define parameter in testng.xml file using syntax like bellow.

                        		<parameter name="browser" value="FFX" />

Here, name attribute defines parameter name and value defines value of that parameter. Then we can use that parameter In selenium webdriver test case using bellow given syntax.

                        		@Parameters ({"browser"})

Explain in what ways does TestNG allows you to specify dependencies?

TestNG allows you to specify dependencies in two ways

1. Using attributes dependsOnMethods in @Test annotations

2. Using attributes dependsOnGroups in @Test annotations

What is the default priority of test cases in TestNG?

The default priority of test when not specified is integer value 0. So, if we have one test case with priority 1 and one without any priority then the test without any priority value will get executed first .

What is difference between @Factory and @DataProvider annotation?

@Factory method creates instances of test class and run all the test methods in that class with different set of data.

Whereas, @DataProvider is bound to individual test methods and run the specific methods multiple times.

How To Check If An Element Is Visible With WebDriver?

The above mentioned method may be good to check if aelemet exists on page.
However sometimes a element may be not visible, therefore you can not perform any action on it.

You can check whether an element is visible or not using below code.

                        		WebElementelement  =driver.findElement(By.id("element-id"));
														if(element instanceofRenderedWebElement) {
															System.out.println("Element visible");
														} else {
															System.out.println("Element Not visible");


How to Wait For Element To Be Available?

The application may load some elements late and your script needs to stop for the element to be available for next action.
You can perform this check using below code.

In below code, the script is going to wait maximum 30 seconds for the element to be available. Feel free to change the maximum number per your application needs.

                        	WebDriverWait wait = new WebDriverWait(driver, 30);
													WebElement element = wait.until(ExpectedConditions.elementToBeClickable(By.id("id123")));

How to Focus On A Input Element On Page ?

Doing focus on any element can be easily done by clicking the mouse on the required element.
However when you are using selenium you may need to use this workaround instead of mouse click you can send some empty keys to a element you want to focus.

                        	WebElementelement  =driver.findElement(By.id("element-id"));
													//Send empty message to element for setting focus on it.


How to Overwrite Current Input Value in editable field On Page?

The sendKeys method on WebElement class will append the value to existing value of element.
If you want to clear the old value. You can use clear() method.

                        	WebElement element = driver.findElement(By.id("element-id"));
													element.sendKeys("new input value");

How to Mouseover Action To Make Element Visible Then Click?

When you are dealing with highly interactive multi layered menu on a page you may find this useful.
In this scenario, an element is not visible unless you click on the menu bar.

So below code snippet will accomplish two steps of opening a menu and selecting a menu item easily.

                        	Actions actions = new Actions(driver);
													WebElement menuElement = driver.findElement(By.id("menu-element-id"));

How to Extract CSS Attribute Of An Element

This can be really helpful for getting any CSS property of a web element.
For example, to get background color of an element use below snippet

                        	String bgcolor = driver.findElement(By.id("id123")).getCssValue("background-color");
													// and to get text color of an element use below snippet

													String textColor = driver.findElement(By.id("id123")).getCssValue("color");


How to Find All Links On The Page?

A simple way to extract all links from a web page.

                        	List<WebElement> link = driver.findElements(By.tagName("a"));


How to Execute A JavaScript Statement On Page?

If you love JavaScript, you are going to love this. This simple JavascriptExecutor can run any javascript code snippet on browser during your testing.

In case you are not able to find a way to do something using web driver, you can do that using JS easily.

Below code snippet demonstrates how you can run a alert statement on the page you are testing.

                        	JavascriptExecutor jsx = (JavascriptExecutor) driver;


How to take a screenshot with Selenium WebDriver?

                        		Import org.apache.commons.io.FileUtils;

														WebDriver driver = new FirefoxDriver();


														File scrFile = ((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE);

														// copy screen shot to your local machine

														FileUtils.copyFile(scrFile, new File("c:\\path\\screenshot.png"));

How to Get HTML Source OfA Element On Page?

If you want to extract the HTML source of any element, you can do this by some simple Javascript code.

                        		JavascriptExecutorjsx = (JavascriptExecutor) driver;
														String elementId = "element-id";
														String html =(String) jsx.executeScript("return document.getElementById('" + elementId + "').innerHTML;");

How To Switch Between Frames In Java Using Webdriver?

Multiple iframes are very common in recent web applications. You can have your webdriver script switch between different iframes easily by below code sample

                        		WebElement frameElement = driver.findElement(By.id("id-of-frame"));


What is the difference between "GET" and "NAVIGATE" to open a web page in selenium web driver? ?

Get method will get a page to load or get page source or get text that's all whereas navigate will guide through the history like refresh, back, forward.

For example if we want to move forward and do some functionality and back to the home page this can be achieved through navigate() only.

driver.get() will wait till the whole page gets loaded and driver.navigate will just redirect to that page and will not wait

What is the basic use of Firefox profiles and how can we use them using selenium? ?

A profile in Firefox is a collection of bookmarks, browser settings, extensions, passwords, and history; in short, all of your personal settings. We use them to change user agent, changing default download directory, changing versions etc.

How to handle internationalisation through web driver?

                        	FirefoxProfile profile = new FirefoxProfile();
													Webdriver driver = new FirefoxDriver(profile);
													// will open google in Japanese Lang

How to overcome same origin policy through web driver?

                        	Proxy server.
													DesiredCapabilities capability=new DesiredCapabilities.firefox();
													capability.setCapability(CapabilityType.PROXY,"your desire proxy")
													WebDriver driver=new FirefoxDriver(capability);


Difference between flex and flash application.?

In flash there is no code just based on creativity(design) we will complete the work(time consuming process) whereas flex contain some small functions which is integrated with mxml,PHP..(no tool is there to develop flex we want to use the properties of css and style sheet)

How can we get the font size, font color, font type used for a particular text on a webpage using Selenium web driver?

                        	driver.findelement(By.Xpath("Xpath ").getcssvalue("font-size);
													driver.findelement(By.Xpath("Xpath ").getcssvalue("font-colour);
													driver.findelement(By.Xpath("Xpath ").getcssvalue("font-type);
													driver.findelement(By.Xpath("Xpath ").getcssvalue("background-colour);

How to prepare Customized html Report using TestNG in hybrid framework ?

Below are the 3 ways:

1. Junit: with the help of ANT.
2. TestNG: using inbuilt default to get the HTML report. Also XST reports from ANT,Selenium, TestNG combination.
3. Using our own customized reports using XSL jar for converting XML content to HTML.

Which java collection can be used to store Test Data ?

Preferebly Map : Java Map Collection provides the ability to call a particular value irrespective of the position of the element from stored set of elements.

For Example : You have stored username and password of your test logins in a Map, Now if you want to retrieve password for a specific user, you just need to give a call like
String password = map.get(username);

Also Properties files works on principle of HashTable, Maps are nothing but improved version of HashTable.
You can find how to convert Map to Properties File and Properties file into Java Map on selenium-webdriver website
So prefer Map collection over other collections to store your data in selenium webdriver

How to stop Page Loading, when element is loaded ?

We can stop page loading by sending Keys.ESC to body element in selenium webdriver. driver.findElement(By.tagName("body")).sendKeys(Keys.ESC);

How to mouse hover on an element?

                        	Actions action = new Actions(webdriver);
													WebElement we = webdriver.findElement(By.xpath("html/body/div[13]/ul/li[4]/a"));

How to switch between the windows?

                        		private void handlingMultipleWindows(String windowTitle) {
															Set windows = driver.getWindowHandles();
															for (String window : windows) {
																if (driver.getTitle().contains(windowTitle)) {

Is there a way to click hidden LINK in web driver?

                        		String Block1 = driver.findElement(By.id("element ID"));
														JavascriptExecutor js1=(JavascriptExecutor)driver;

Differences between jxl and ApachePOI. ?

0. jxl does not support XLSX files
1. jxl exerts less load on memory as compared to ApachePOI
2. jxl doesn't support rich text formatting while ApachePOI does.
3. jxl has not been maintained properly while ApachePOI is more up to date.
4. Sample code on Apache POI is easily available as compare to jxl.

How to disable cookies in browser ?

                        	FirefoxProfile profile = new FirefoxProfile();
													Webdriver driver = new FirefoxDriver(profile);
													// will open google in Japanese Lang

What is default port no?


Does Selenium support https protocols?


Difference between assert and verify in selenium web driver?

When an 'assert' fails, the test will be aborted. Assert is best used when the check value has to pass for the test to be able to continue to run log in.

Where if a 'verify' fails, the test will continue executing and logging the failure.
Verify is best used to check non critical things. Like the presence of a headline element.

I want to find the location of ""b"" in the below code, how can I find out without using xpath, name, id, csslocator, index ?



Name 5 different exceptions you had in selenium web driver ?

1. NoSuchElementException - When no element could be located from the locator provided.

2. ElementNotVisibleException - When element is present in the dom but is not visible.

3. NoAlertPresentException - When we try to switch to an alert but the targetted alert is not present.

4. NoSuchFrameException - When we try to switch to a frame but the targetted frame is not present.

5. NoSuchWindowException - When we try to switch to a window but the targetted window is not present.

6. UnexpectedAlertPresentException - When an unexpected alert blocks normal interaction of the driver.

7. TimeoutException - When a command execution gets timeout.

8. InvalidElementStateException - When the state of an element is not appropriate for the desired action.

9. NoSuchAttributeException - When we are trying to fetch an attribute's value but the attribute is not correct

10. WebDriverException - When there is some issue with driver instance preventing it from getting launched.

How to refresh a page without using context click?

1. Using sendKeys.Keys method
2. Using navigate.refresh() method
3. Using navigate.refresh() method
4. Using get() method
5. Using sendKeys() method

Why do we go for automation testing ?

1. Manual testing of all work flows, all fields, all negative scenarios is time and cost consuming.
2. It is difficult to test for multi lingual sites manually.
3. Automation does not require human intervention, We can run automated test unattended(noghtly regressions).
4. Automation increases speed of test execution.
5. Automation helps increase test coverage.
6. Manual testing can become boring and hence error prone.

How to handle colors in web driver?

Use getCssValue(arg0) function to get the colors by sending 'color' string as an argument.

                        		String col = driver.findElement(By.id(locator)).getCssValue("color");

Is there a way to click hidden LINK in web driver?

                        		String Block1 = driver.findElement(By.id("element ID"));
														JavascriptExecutor js1=(JavascriptExecutor)driver;

What Class Extends Web Driver ?

AndroidDriver, ChromeDriver, EventFiringWebDriver, FirefoxDriver, HtmlUnitDriver, InternetExplorerDriver, IPhoneDriver, PhantomJSDriver, RemoteWebDriver, SafariDriver

How to disable cookies in browser ?

                        	FirefoxProfile profile = new FirefoxProfile();
													Webdriver driver = new FirefoxDriver(profile);
													// will open google in Japanese Lang

How to overcome same origin policy through web driver?

Using deleteAllVisibleCookies() in selenium

How to change user agent in Firefox by selenium webdriver?

FirefoxProfile profile = new FirefoxProfile();
profile.setPreference("general.useragent.override", "some UA string");
Web Driver driver = new FirefoxDriver(profile);

What is Selenese??

Selenese is HTML language based command, which is used in Selenium IDE.

Suppose developer changed the existing image to new image with same xpath. Is test case pass or fail?


What are the different types of driver implementation??

AndroidDriver, AndroidWebDriver, ChromeDriver, EventFiringWebDriver, FirefoxDriver, HtmlUnitDriver, InternetExplorerDriver, IPhoneDriver, IPhoneSimulatorDriver, RemoteWebDriver, SafariDriver, WebDriverBackedSelenium

How to handle alerts and confirmation boxes.?

Confirmation boxes and Alerts are handled in same way in selenium.

													var alert = driver.switchTo().alert();
													alert.dismiss();  //Click Cancel or Close window operation
													alert.accept();   //Click OK
													Handle Confirmation boxes via JavaScript,
													driver.executeScript("window.confirm = function(message){
														return true;

Code for Opening Firefox browser?

Webdriver driver=new FireFoxdriver();

What is the order of fastest browser implementation for WebDriver?

HTMLUnitDriver is the fastest browser implementation as it does not involves interaction with a browser, This is followed by Firefox driver and then IE driver which is slower than FF driver and runs only on Windows.

Is there any difference in XPath implementation in different WebDriver implementations?

Since not all browsers (like IE) have support for native XPath, WebDriver provides its own implementation for XPath for such browsers. In case of HTMLUnitDriver and IEDriver, html tags and attributes names are considered lower cased while in case of FF driver they are considered case in-sensitive.

So do I need to follow these Design patterns while writing my tests?

Not at all, these Design Patterns are considered best practices and you can write you tests without following any of those Design Patterns, or you may follow a Design Pattern which suites your needs most.

How do I implement data driven testing using Selenium?

Selenium, unlike others commercial tools does not have any direct support for data driven testing. Your programming language would help you achieving this. You can you jxl library in case of java to read and write data from excel file. You can also use Data Driven Capabilities of TestNG to do data driven testing.

What are the important phases of Selenium Test Process?

1. Test Planning 2. Write Basic Tests 3. Enhance Tests 4. Running & Debugging Tests 5. Reporting and Tracking Defects

How to get typed text from a textbox?

Use get Attribute (“value᾿) method by passing arg as value.
String typedText = driver.findElement(By.xpath(“xpath of box᾿)).getAttribute (“value᾿));

How do you clear the contents of a textbox in selenium?

Use clear () method. driver.findElement (By.xpath (“xpath of box᾿)).clear ();

What are the prerequisites to run selenium WebDriver?

JDK, WebDriver (selenium standalone jar file), browser, application to be tested.

What are the web page Elements in Web Applications?

Link Button Image, Image Link, Image Button Text box Edit Box Text Area Check box Radio Button Drop down box List box Combo box Web table /HTML table Frame

3) Why should Selenium be selected as a test tool?

1. is free and open source
2. have a large user base and helping communities
3. have cross Browser compatibility (Firefox, chrome, Internet Explorer, Safari etc.)
4. have great platform compatibility (Windows, Mac OS, Linux etc.)
5. supports multiple programming languages (Java, C#, Ruby, Python, Pearl etc.)
6. has fresh and regular tool developments
7. supports distributed testing nothing but parallel testing

What is the difference between driver.close() and driver.quit command?

close(): WebDriver’s close() method closes the web browser window that the user is currently working on or we can also say the window that is being currently accessed by the WebDriver. The command neither requires any parameter nor does is return any value.

quit(): Unlike close() method, quit() method closes down all the windows that the program has opened. Same as close() method, the command neither requires any parameter nor does is return any value.

Can Selenium handle windows based pop up?

Selenium is an automation testing tool which supports only web application testing. Therefore, windows pop up cannot be handled using Selenium.

But With certain third party tools(like autoit, sikuli) we can automate window based pop up in selenium environment

How can we handle web based javascript pop up?

WebDriver offers the users with a very efficient way to handle these pop ups using Alert interface. There are the four methods that we would be using along with the Alert interface.

void dismiss() – The dismiss() method clicks on the “X᾿ button as soon as the pop up appears, please donot believe that alert.dismiss() will click cancel.

void accept()
– The accept() method clicks on the “Ok᾿ button as soon as the pop up window appears.

String getText() – The getText() method returns the text displayed on the alert box.

void sendKeys(String stringToSend) – The sendKeys() method enters the specified string pattern into the alert box.

                        Alert alert = driver.switchTo().alert();
												// to accept the alert
												// to dismiss ( of to press 'X') icon
												// to get text from the alerts
												// to send keys to prompt only works with prompt
												alert.sendKeys("selenium Webdriver");

Return Javascript execution result ?

We need to return from your javascript snippet to return a value, so: js.executeScript(“document.title᾿); will return null, but: js.executeScript(“return document.title᾿); will return the title of the document.

To generate pdf reports mention what Java API is required?

To generate pdf reports, you need Java API IText.

What are the types of Listeners in TestNG?

1. IAnnotationTransformer 2. IAnnotationTransformer2 3. IConfigurable 4. IConfigurationListener 5. IExecutionListener 6. IHookable 7. IInvokedMethodListener 8. IInvokedMethodListener2 9. IMethodInterceptor 10. IReporter 11. ISuiteListener 12. ITestListener

Why do you need Session Handling while working with Selenium?

While working with Selenium, you need Session Handling. This is because, during test execution, the Selenium WebDriver has to interact with the browser all the time to execute given commands.

At the time of execution, it is also possible that, before current execution completes, someone else starts execution of another script, in the same machine and in the same type of browser. So to avoid such situation you need Session Handling.

Is there a way to do drag and drop in Selenium Webdriver?

                        		Actions action = new Actions(driver);
														WebElement startPoint = driver.findElement(By.cssSelector(“source᾿)); 
														WebElement endPoint = driver.findElement(By.cssSelector(“target᾿)); 

Testcase failed saying "ElementNotVisible", but when analyzed manually element is visible ? How to Handle it ?

There are couple of things which may cause this issue.

1. Element may not be visible in automation due to the speed of selenium.

2. If you closed a hidden division pop up, and tried to perform action, then there is a chance that hidden division popup' animation wanot over which could cause this issue.

3. There is could be an another element which has same xpath or locator in some other page

Example : Consider you have a element which has xpath as //button[@id='abc'] on page X, by clicking some tab on xpage navigates the user to Y page, Now there is an element on Y page which have xpath same as //button[@id='abc']. But when you launch your application, application may be directly landed on page Y. So with this scenario, if you try to perform on element on Y page it could throw an Exception.

Step by step Solution :
1. First verify whether it is really any of the above scenario ?
2. Print number of element present whth that xpath using findElements method
3. If there is only one element please follow program 1, If there is more than 1 element follow program 2.

Program 1 : Using Explicit wait (Wait for the element to be visible): 1. Open the url (please change according to your application).
2. Create object for WebdriverWait set wait time as 60 seconds.

                        		WebDriverWait wait = new WebDriverWait(driver, 60 /*seconds*/);

3. Use visibilityOfElementLocated method present in Expected conditions class


Complete Program 1 with Explicit wait (Wait for the element to be visible)
public class ElementNotVisibleIssueWait {
	public static void main(String[] args) {
		// set the geckodriver.exe property
		System.setProperty("webdriver.gecko.driver", "C:/path/geckodriver.exe");
		// open firefox
		WebDriver driver = new FirefoxDriver();
		// set implicit wait to 1 minute
		driver.manage().timeouts().implicitlyWait(1, TimeUnit.MINUTES);
		// open webpage
		// set the webdriver Wait as 60 seconds
		WebDriverWait wait = new WebDriverWait(driver, 60 /*seconds*/);
		String buttonXpath = "//button[@id='abc']";
		// wait for the element to be visible, max wait time is 60 seconds
		// clicks the button which has xpath = //button[@id='abc']

Program 2 : Using findElements And IsDisplayed:
1. Open the url (please change according to your application).
2. Set implicitly wait for 1 minute

                        		// set implicit wait to 1 minute
		driver.manage().timeouts().implicitlyWait(1, TimeUnit.MINUTES);

.3. Find all the elements which matches the xpath and store them

                        			String buttonXpath = "//button[@id='abc']";
		// find all the elements with that xpath match
		List elements = driver.findElements(By.xpath(buttonXpath));

4. iterate over the element we stored

                        		for (WebElement webElement : elements) {}

5. verify if the element is displayed ot not
6. Click element if displayed or ignore

                        		if (webElement.isDisplayed()) {
				// if displayed click the element and break the loop.

7. Once element is clicked breake the loop.

Complete Program 2 : findElements And IsDisplayed:
public class ElementNotVisibleIsDisplayed {
	public static void main(String[] args) {
		// set the geckodriver.exe property
		System.setProperty("webdriver.gecko.driver", "C:/path/geckodriver.exe");
		// open firefox
		WebDriver driver = new FirefoxDriver();
		// set implicit wait to 1 minute
		driver.manage().timeouts().implicitlyWait(1, TimeUnit.MINUTES);
		// open webpage
		String buttonXpath = "//button[@id='abc']";
		// find all the elements with that xpath match
		List elements = driver.findElements(By.xpath(buttonXpath));
		// iterate over the elements
		for (WebElement webElement : elements) {
			// check whether element is displayed or not,
			if (webElement.isDisplayed()) {
				// if displayed click the element and break the loop.

Write a code to wait for a particular element to be visible on a page?

Webdriver wait can be used to apply conditional wait (Expected condition is visibility of an element on a page)

                        		public void waitForElementVisible(){

															WebDriverWait wait = new WebDriverWait(driver, 30/*seconds*/);



Write a code to wait for an alert to appear?

Waiting for an alert to appear on a page can be performed using explicit wait in Selenium WebDriver.

															WebDriverWait wait = new WebDriverWait(driver, 30/* 30 seconds*/);


Can Selenium handle windows based pop up?

Selenium is an automation testing tool which supports only web application testing. Therefore, windows pop up cannot be handled using Selenium.

How to retrieve css properties of an element?

The values of the css properties can be retrieved using a getCassValue() method:

													driver.findElement(By.id(�id�)).getCssValue('name of css property');
													// gets font size

What are Junit annotations?

Below are few annotations presnt in Junit:

@Test: lets the system know that the method annotated as @Test is a test method in Junit. There can be multiple test methods in a single test script.
@Before: lets the system know that this method shall be executed every time before each of the test method in Junit.
@After: lets the system know that this method shall be executed every time after each of the test method in Junit.
@BeforeClass: lets the system know that this method shall be executed once before any of the test method in Junit.
@AfterClass: lets the system know that this method shall be executed once after any of the test method in Junit.
@Ignore: lets the system know that this method shall not be executed in Junit.

What are the advantages of Automation framework in selenium webdriver?

Below are few benefits of framework in selenium webdriver 1. Reusability of code
2. Maximum coverage
3. Recovery scenario
4. Low cost maintenance
5. Minimal manual intervention
6. Easy Reporting
7. Logging for debugging
8. Easy Coding

What is an XPath?

Xpath or XML path is a query language for selecting nodes from XML documents. XPath is one of the locators supported by selenium webdriver.
Selenium webdriver supports only Xpath 1.0 ,selenium doesnot support Xpath 2.0

What are the different mouse actions that can be performed?

1. click(WebElement element)
2. doubleClick(WebElement element)
3. contextClick(WebElement element)
4. mouseDown(WebElement element)
5. mouseUp(WebElement element)
6. mouseMove(WebElement element)
7. mouseMove(WebElement element, long xOffset, long yOffset)

Write the code to double click an element in selenium?

                        		Actions action = new Actions(driver);
														WebElement element=driver.findElement(By.id("elementId"));

Write the code to right click an element in selenium?

                        		Actions action = new Actions(driver);
														WebElement element=driver.findElement(By.id("elementId"));

How to fetch the current page URL in selenium?

Using getCurrentURL() command we can fetch the current page URL-


How to verify tooltip text using selenium?

Tooltips webelements have an attribute of type 'title'. By fetching the value of 'title' attribute we can verify the tooltip text in selenium.

                        		String toolTip = driver.findElement(By.id("")).getAttribute("title");

How can we find all the links on a web page?

All the links are formed using anchor tag 'a' and all links will have href attribute with url value. So by locating elements of tagName 'a' we can find all the links on a webpage.

                        		List linksWithTag = driver.findElements(By.tagName("a"));
                        		List linksWithXpath = driver.findElements(By.xpath("//a"));
                        		List linksWithXpath = driver.findElements(By.xpath("//*[@href]"));
                        		List linksWithCSS = driver.findElements(By.cssSelector("a"));

How can we check if an element is getting displayed on a web page?

Using isDisplayed method we can check if an element is getting displayed on a web page.

                        		if(driver.findElement(By locator).isDisplayed()){
                        			System.out.println("Element Displayed");

How to handle HTTPS website in selenium? or How to accept the SSL untrusted connection?

Using profiles in firefox we can handle accept the SSL untrusted connection certificate. Profiles are basically set of user preferences stored in a file.

                        		FirefoxProfile profile = new FirefoxProfile();
														WebDriver driver = new FirefoxDriver(profile); 

QualiTest Interview Questions

1.Write a optimized code to swap below string.
2. What are boolean methods in Selenium
3. How to return driver to other classes.
4. Write a query for list all employees who names having more than 4 characters
5. Write a code and explain for sql database connection
6. Explain your framework
7. What are the type framework and explain
8. Explain cucumber framework(full explanation with the scenarios)
9. Why java not other languages
10. What is nested function write one query for the same
11. Explain rest api
12. What are the https methods
13. What are the error codes in api and explain
14. Explain Page object model

Infosys Interview Questions [Added on 09-04-2018]

1.Brief Description about yourself
2.How Selenium Differes from UiPath
3.Selenium IDE ?
4.How will you handle pop-up.
5.Which framework you are using in your project & why.
6.How will you handle java script pop-up.
7.How will you handle SSL issue
8.How will you take screenshot.
9.How will you handle AJAX?Explain it with code.
10.Explain your framework.
11.What is STLC,Test Plan & Defect Life Cycle(Procedure to file a defect)
12.traceability matrix
13.Selenium Grid concepts with code ?RC
14.Project Description
15.Diff between Implicitly Wait and Explicitly Wait
16. When will you stop testing
17.Thread 7 Synchronization in java
1. What difficulty you faced in Automation?
2. What you do with your code when a new version of browser is launched?
3. What are the features in your automation code?
4. How to integrate HPALM/HPQC with Selenium?
5. How you are sending the emails from framework, as .rar files are blocked in most of the companies?
6. How code review is done for your code?

PWC Selenium interview question recent [Added on 09-04-2018]

1.what is collection in java.
2.play with any of the collections.
3.search a letter in string?
4.reverse a number?
5. sorting ana array?
6 .What is page object model?
7between css and xpath which one is faster?
8.what is exception.tell some exception.
9.tell some exception you get while writing code.
10.how to handle exception ?
11.is it agood approche to throw an exception?
14.how to generate a report?
15.how many testcase you have automated.
16.how many test case you run in a batch execution?
17.what is the minimum time to run a batch execution?
18.tell me complex secnarion of your application?
19.challenges you faced in automation.
20.how to upload file other than Autoit?
21.negative testcase for a pen?
22.how to run a test 3times if the test fail ?

Mind Tree Selenium Interview Questions [Added on 09-04-2018]

1. How to handle dynamic object
2. How to work with button which is in div tag and and u have to click without using xpath
3. JVM is dependent or independent platform
4. How many Test script you write in day
5. Describe your framework
6. How to parameterized your junit
7. How to handle ssl security
8. How to handle window pops
9. Difference between implicit and explicit
10. What are the types of assertion and what are assertion in junit

1. JVM is dependent or independent platform
2. Difference between hashmap and hash set, set and linkedlist, arraylist and vector list , linkedhash set and hashset
3. Abstract and interface
4. Throw and throws
5. How to split a String
6. Checked and unchecked exception
7. How to work with azax aplication
8. Why sring is immutable
9. What is the retrun type of getwindowhandles();
10. What are the types of assertion and what are assertion in java

IBM Interview Questions on Selenium

1.Explain your framework?
2.How to do grouping?with code?
3.How to handle different pop ups?
4.Diffrence between string and string buffer?
5.What is difference between abstract class and interface?
6.Diffrence between final,finaly,finalize?
7.Diffrence between normal class and final class?
8.How to handle frames without having any attributes?
9.Diffence between smoke and sanity testing?
10.QA process you follows?
11.Adapter design in java?

Wells Fargo Selenium webdriver Interview Questions

1. What is system.out.println ? and use of it ?
2. What is Webdriver, Name methods which donot have the implementation ?
3. Write code to print Fibonacci series ?
4. What are the exception are resent in selenium ?
5. Why do we use finally and how it differs from final keyword ?
6. Can we use multiple catch, When can we use multiple catch ?
7. Different between POI and JXL ?
8. Why main method is static ?
9. What is the use of static variables ?
10.Different betten smoke and sanity test ?
12. Different between checked and unchecked exception ?
13. Different between /and // in xpath ?
14. How do you handle Alert in Selenium

Verizon Selenium interview Questions

1. Why we use framework in Selenium webdriver
2. Do you automate smoke test cases in your project ?
3. When we design framework, When we will get to which framework to use ?
4. Sort a string based on alphabets present in string.
5. How to handle Child Browser popup
6. Program to check whether integer and string is palindrome or not

JVP Software Company Selenium interview Questions

1.Briefly explain about yourself
2.Experience in testing with selenium 4.What is Framework
5.Why we use framework
6.How to handle authentication popup in selenium
7.If you want to enter username password in that authentication popup, how will you achieve it
8.Locators and reliable locators
9.What is Start with end with, following sibling in xpath
10.Webdriver architecture
11.Waits in Selenium
12. What is String and its properties
13.Different between string buffer and string
14.Wrapper class and its use in Collections
17. If we use robot class and if system gets locked then it may not work... So what is the approach to handle this kind of authentication.
18. Which version Selenium You are using, what ares issues we face in Selenium 3.0
19. Which is default browser for Webdriver.

Webdriver interview Questions asked in CapGemini

1. Difference b/w Abstract class & Interface.
2. Write a program to swap numbers without 3rd variable.
3. Write a program to reverse string without using StringBuffer class
4. Write a program to find string in another string.
5. Why static is used in main method
6. Difference between static binding & dynamic binding.
7. Write a xpath of an element present in table by using its adjacent element
8. various annotations used in Testng.
9. What methods can be inherited by child class.
10. Is it possible to override main method?.

Amazon Interview Questions on Selenium Webdriver

1. Write all end-end test scenarios for MobileApp-Navigation-Map
2. Test data enumeration for Navigation Map
3. you have joined in Amazon for mobile app testing but app is already in production and there are no releases in feature/enhancements so how u will be helpful for ur team
4. Did u missed any functionality/bug in your project If yes how did u rectified.

1. Automation project work -flow
2. WAP to get all upper-case letters in a given String.
3. WAP to find give triangle is isosceles triangle or not

1. Automation framework architecture
2. How will you do automation for Amazon search feature ( If search with some category how will you validate only those products)

PwC selenium Interview Questions

1. Explain your current project framework
2. How much do you rate yourself in java out of 5 and selenium out of 5
3. WAP to swap two numbers without using temp variable
4. WAP to find whether the number is prime or not
5. With an example explain method overloading and overriding and how you used this concept in your framework
6. How do you take screenshot in selenium
7. Tell me some annotations in TestNG
8. Do you know exceptions? Tell some exceptions in selenium
9. Different types of xpath - she was expecting following sibling and preceding sibling
10. Which is preferred... absolute or relative xpath - what is / and //
11. Different ways of selecting object from Dropdown
12. What are limitations/drawbacks of selenium - she was expecting inability to detect captcha

Persistent interview questions on Selenium

Explain framework used in your project?
Benefits of hybrid framework?
How do you handled exceptions in framework.
Explain data providers and how do you take data to run test cases?
Explain selenium grid and node
How do you handle reporting in your framework?
How to group set of test cases to run in different browsers on testing?

Java questions :
String mutable and immutable
Overloading and overriding with real examples.
difference between Interfaces and abstraction
Collection architecture in java
Difference between arraylist and array
Explain hashmap ?
Write program to reverse a string
Explain checked and unchecked exception

Bizviz Interview questions

1. Explain ur current project framework
2.There is a refresh button...There is a link which is inactive...There is download button... Continuously click on refresh button until link gets enabled and then click download button and handle download popup
3. Java program to count number of occurrences of a digit in an array and print max occurrence of a number
4. SQL query to remove duplicate rows from table
5. There is array of 0 s and 1s...WAP to move 0s to left and 1s to right
6. There is webelement displaying scores which is fully dynamic...How do you handle it
7. How do you handle dynamic waits
8. How do you identify objects on webpage...Tell me different ways

AllState interview Question on selenium

1.what is selenium grid
2.Command for hub and NODE in selenium grid?
3.xpath and css
4.Explain Hybrid framework
5.Pagefactory in POM class
6. How to handle exception
7. How to make finally block should not execute?
8. code for find duplicate in a array
9. code to print only alphabet in a string (abcd_@234)
10. What is smoke testing and sanity
11. what is regression
12. what is tracebility matrix
13. what are things you add while writing test cases
14. how to test water bottle
15. Is manual tester can do automation testing good or not?

Sony Telephonic interview questions

Sony Telephonic : 1. what is construtor
2. Explain oops concepts
3. Explain xpath
4. Explain framework
5. why do we use testng?

Sony technical round 1. Which protocol used in selenium to interact with browser
2. Selenium internal architecture
3. List of selenium Api's
4. Explain framework architecture
5. What is remotewebdriver
6. Does python supports multiple inheritance

Ola Interview questions on selenium

1. Tell me about yourself
2. Explain your project
3. Segregate 0's and 1's in a given integer array.
4. Write a method using java which can create only 5 objects
5. What are the different types of testing you did in your project and explain?
6. Explain what kind of testing you are doing in your current project?
7. What is Stack ?
8. Explain Method overidding and overloading
9. Write a program for balanced equation.
10.Explain what is 404 and 406 pages and when do you get, how to handle those ?
11. Write a program in java for random number generation

Dell Interview Questions in Selenium

1.How to integrate with TFS (People may use Git, SVN, BitBucket)?
2.Benefits of Selenium?
3.Benefits of Oops??
4.What is polymorphism??
5.What is dictionary (Map) ??
6.How to handle AJAX elements?
7.What is synchronisation?
8.Difference between implicit wait and explicit wait?
9.What is automation life cycle?
10.What is framework?
11.What is Nunit? Explain the capabilities of Nunit (related to C#) ?
12.Write a script to open the Firefox without using FirefoxDriver class
13.How to take the screen shot of webelement?
14.How to verify to verify whether the element is present or not using findElements method
15.Write a script to verify whether the check box is selected or not.
16.How to verify whether the list box is dropdown list or multi-select list.
17.Difference between arraylist and linked list?
18.Explain the vector??
19.Difference between abstraction and encapsulation?
20.Difference between protected and default access specifiers?
21.What is single ton class ?
22.Why do we use POM ?
23.How to handle windows popup ?

Thomson Reuters interview questions on selenium webdriver automation

1.difference between list and set
2. Write a program for fibinocis series
3.he wrote some program we have to find which type of inheritence
4.difference between abstract class and interface
5.can we change public static like static public
6.can we override main method
7.what is constructor
8. He gave one program which contain static and non static block and constructor. Write output
9. Lot of programs we have to write output
10.what is the latest version of selenium
11. What is difference between selenium 2 and 3
12.write a code set property for Firefox driver
13.what are methods available in action class
14.drag and drop selenium.

KPMG interview Questions

1. Explain about our project
2. Mouse event in selenium
3. Independent and dependent concept in xpath
4. How to handle dynamic element using xpath
5. Explain testng and POM
6. How will you compare integers
7. what is Marker interface

Interview Questions asked in Softway Solutions

JAVA : 1. what is constructor? use of constructor in class ?
2. why we need to compile a program ?
3. upcasting in java ?
4. What is polymorphism
5. Write singleTon class
6. Explain method overloading

Selenium :
1. what is testng?use of testng in framework?
2. how to handle alert,file upload popups
3. method overloading examples in Selenium?
4. access modifiers public,private,protected use in selenium
5. What is POM.XML
6. difference between .xml & .html
7. handling frames in selenium

why we go for webdriver insted of selenium rc?


what is desired capabilities?


What is the use of properties file in selenium ?


What is jexel and Apache POI


What exactly Webdriver drives?


What does POM class has? What are it's uses?


What does POM. xml(Maven) contains?


How do you read more rows in excel?


What is the jar file used get data from Excel


How do you set path for Chrome, Firefox and IE driver


what is firefoxprofile?


what is javascript executor?


If a test set has 1000 TCs then how will you plan your test schedule where in it�s a critical bug fix and close to delivery date


How often do you run your automation test?


what is getAttribute and getText?


write a script to print the multiples of 5?


How do change the run time property values of the element?


where do you store element locators


where do you store objects?


what is ANT?


How to add selenium jar file to Eclipse?


How to execute failed test case


In TestNG where we really use @Suite annotation?


If any issues we find in @Suite , do the system will execute remain code or suspend the execution?


If we find issue/defect in @Suite do we login the same the defect tool?


Is it possible to do Parallel Testing / cross browser by using testNG?, if yes by which using which annotation?


How to execute failed test case with different values of data


Locators available in selenium? which one you prefer?


Difference between findelement and findelements?


What is origin policy in selenium.


Difference between apache poi and jxl?


how to handle broken links in selenium webdriver?


How to get all the values in a dropdown?


How to achieve grouping in TestNG?


How to extract links present inside mutliple frames of a web page?


What are the different exceptions that you came across?


How to get the default value of edit box?


How to get the row count of a web table?


Difference between Web browser and web portal?


Define overriding and overloading from selenium perspective ?


How u will perform constructor overloading in selenium.?


Give me an example of encapsulation you have done in selenium.?


Should use factory model or abstract model in selenium ? What about singleton in selenium.?


Can listeners be overridden multiple times, if its then how and how you will implement listeners without listener tag in testng ?


How u will do code optimization in automation.


One Check Box is having two possible boolean values(checked or unchecked) and what are the combination of values for two check boxes.


Difference between HTML and HTML5.


How will you wait until all the elements in a page gets loaded, the page is completely dynamic and you may not know which will be the last element to load.


When tests run in parallel how will Webdriver know that it has to work on a particular Browser window only?


How to perform Security Testing in web application??


Have you do retesting on failed scripts manually or rerun automatically??


After automation testing is completed assume that new requirements have been added how will you handle this in automation??


What is the folder structure of Automation Framework


Write a program to write your name into the notepad.


What's the difference between @findby annotation and findElement? Why don't we use driver.findElement in POM?


How do you resolve conflict in Git-hub version control, i.e. if two people are committing the code push, how to resolve the code conflict?


A page has 20-30 webelements. All are completely dynamic. How to find out the type of last webElement?


How to handle browser notification in selenium?


What are the java annotations?? That we can use with selenium web driver??


Do we have any benefits if we declare page objects as Public instead of private


what is mutability and non mutability.


What is access specifiers of data members in interface


Can you create object for abstract class


What is constant pool and non constant pool.what they contain In which area of JVM they are present.


what is encapsulation explain with a example


what is generics.is it compile time or run time


How do you initialize POM


Difference between webelement and webdriver ?


what is use of robot framework


What is karate framework


How to get the text of disabled element in selenium webdriver.


Automation Feasibility?


Why specifically you used POM class in your framework ?


Uses of Tags in TestNG ?


The process flow in Agile(Scrum) ?


What all you cant test using Selenium WebDriver ?


How you will test image in Selenium ?


What is branch in and branch out in Git Hub ?


What different application you tested as part of Integration testing ?


How you decide whether you can test particular web page or not ?


What are contents of Test Plan ? What is Risk?


What is the procedure you followed if defect is deferred ?


How to pick a particular date from calendar popup?


How to read database make a connection with a database and execute a query in Selenium ?


If 10 images is present on webpage then how we know that any particular image is broken


Can we handle google maps(API) using selenium webdriver ??


What exactly Webdriver drives?


Where do you execute your test case?


How to handle download of file in IE11?

Using Robot class

How to find out the length of the string without using length function


Difference between webdriver listener and TestNG listener?


Default port used in selenium ?


Why do we upcaste to WebDriver, why not RemoteWebdriver.

Webdriver is parent interface of RemoteWebDriver, so it is always safe to upcate to the higher level.

Which protocol we use for Selenium


Difference between priority and @dependsOnMethods. How the TC execution differs when we are using this?


Is 100% automation possible?


Why we use set interface in Window handles ?

When we click a link it may open few windows like Win1, win2, win3 but when you click the same link in another session it may open in the order of win2, win3, win1.

Basically we cannot predict the order, we use List interface to access the elements which follow sequence in all time because List store in index based mode.

But Set interface stores the element in the random order, and this behaviour matches with multiple window opening. So they are returning Set rather than List

How to export data from webtable to excel?


Selenium code to find number of drop downs in a webpage

List dropdowns = driver.findElement(By.xpath("//Select")); S.o.P(dropdowns.size());

What is Sprint zero in Agile?


How do you set path for Chrome, Firefox and IE driver


What does POM. xml contains?


What does POM class has? What are it's uses?


Write a JavaScript to find the total number of hyperlinks


How to delete excel data using Apache poi?


How to get screenshot of an alert??


what is Return type of findElement


what is Return type of findElement


what is Return type of findElement

1. Return type of findElement -- >Webelement

2. Return type of findElements-->List<WebElement>

3. Return type of dataProvider-->Two Dimentional Object Array

Do we use any constructor in webdriver


How to write web table in table format in Excel through selenium?


How to find the number of alerts in a page?

People usually create alerts using either inline javascript or external javascript, if all the alerts are made of external javascript you cannot find how many alerts are present.

But if alerts are formed using inline Javascript you can count them, but there is no direct way to count them, Still you can follow below method:

1.Get page source
2.Count "alert(' string in the page source code which will give you the count of how many alerts are present

What are the questions to be addressed before starting automating a web application using selenium?

1- Automation feasibility analysis :

In this section you have to think from different perspective. The main objective of this phase will be to check feasibility of automation.

So your main focus will be on below points.

1- Which test case can be automated and how we can automate them

2- Which module of your application can be tested and which can not be automated

3- Which tools we can use for our application (like Selenium,QTP,Sahi,OATS, Telrik etc) and which tools will be best of our application

4- Take following factors into consideration like Team size,Effort and cost involved for tools which we will use.

2- Test Plan/Test Design This phase plays very important role in Automation test life cycle. In this phase you have to create a Test plan by considering below point into considerations.

1- Fetch all the manual test case from test management tool that which TC has to automate.

2- Which framework to use and what will be advantage and disadvantage of the framework which we will use.

3- Create a test suite for Automation test case in Test Management tool.

4- In test plan you can mention background, limitation, risk and dependency between application and tools.

5- Approval from client/ Stack holders.

3- Environment Setup/Test lab setup

By name itself you can understand that we need to setup machine or remote machine where our test case will execute.

1- In this section you can mention how many machine you want.

2- What should be the configuration in terms of hardware and software.

4-Test Script development/ Automation test case development

In this phase you have to start develop automation script and make sure all test script is running fine and should be stable enough.

1- Start creating test script based on your requirement

2- Create some common method or function that you can reuse throughout your script

3- Make your script easy, reusable,well structured and well documented so if third person check your script then he/she can understand your scripts easily.

4- Use better reporting so in case of failing you can trace your code

5- Finally review your script and your script should be ready before consumption.

5-Test script execution

Now its time for execution of test scripts, in this phas you have to execute all your test script.

Some points to remember while execution:

1- Your script should cover all the functional requirement as per testcase.

2- Your script should be stable so it should run in multiple environment and multiple browsers (depends on your requirement)

3- You can do batch execution also if possible so it will save time and effort.

4- In case of failure your script should take screen shots.

5- If test case is failing due to functionality, you have to raise a bug/defect.

6- Generate test result / Analyses of result

This is the last phase of Automation test life cycle in which we will gather test result and will share with team/client/stack holders.

1- Analyze the output and calculate how much time it take to complete the testcase

How we will get background colour in selenium Webdriver?


How to automate captcha in selenium


How to delete all cookies

public class Demosept201 { static{ System.setProperty("webdriver.chrome.driver","./drivers/chromedriver.exe"); } public static void main(String[] args) { WebDriver driver=new ChromeDriver(); driver.manage().deleteAllCookies(); } }

What is same origin policy?


Which is best locator ?


Write binary Search using recursion


How to create an instance of a class withouto using new keyword.


How to have user defined annotation in TestNG


How we will check the cookies in selenium ?


Difference between selenium RC and webdriver?


What is the Difference between final,finally,finaliz


Difference between throw & throws


How to handle SSl ?


How to export data to notepad using selenium?


How to check if a webpage is completely loaded or not ?

while(true) { JavascriptExecutor js = (JavascriptExecutor)driver; String value=js.executeScript("return document.readyState").tostring(); if(value.equals("complete") { break; } else { } }

Can we have multiple catch block for one try block.


What is staleElementReferencException, Why do we get this exception.


How to validate the pages are broken using selenium?


Can we do API check in Selenium ? or How to Integrate API in Selenium?


Where the Singleton class/pattern and Abstract design pattern we are using in framework?


What is private constructor ?


i18N and l10N testing explain . How you indentify other language in your web page?


How you will extract data from DB and put into text box. Write a code for that.


what is code complete?


How do you perform compatibility testing in selenium?


Difference between automation and performance testing?


what is the difference between smoke and sanity testing?


what is assert?


what is the difference between float and double in java selenium?


14. which is the latest version of selenium webdriver and which version you used?


What is polymarphism ? do we use it in selenium ?


Whar is the use of ANT


What is the advantage of using locators like ID ,NAME over XPATH?


How the testng class's execution happen?


How do u handle dynamic elements without using xpath


What are the different types of driver implementation?


Which repository you have used to store the test scripts?


Which repository you have used to store the test scripts?


What is final method in java


How do you handle https website in selenium


Selenium function used for retrieving the attribute or value?


How do you differentiate check box if more than one check box is existed in your application?


Count the number of links in a page without using xpath


How to check all checkboxes in a page

for (WebElement chkBox : allChkBoxes) { chkBox.click(); } for(int i=0;i<=allChkBoxes.size();i++){ allChkBoxes.get(i).click(); }

How do you handle elements present inside frame?


Example for method overload in WebDriver

driver.get("String str") driver.get(URI uri)

How do you simulate browser back and forward?


What is the difference between ‘/’ and ‘//’


How do you achieve synchronization in WebDriver?


How do you handle untrusted certificates?


12. Is it possible to interact with hidden elements using WebDriver?


What are the prerequisites to run selenium webdriver?


How to handle multiple windows in selenium webdriver?


How many browsers are supported by Selenium IDE?


Can Selenium test an application on Android browser?


Use of following-sibling ?


How to get the number of frames on a page?


How do you simulate scroll down action?


How do you verify that the given list of numbers on a web page is sorted in ascending order?


How to verify that the image changes on mouse hover?


How to check if a text is highlighted on the page?


How to run the tests without a browser or with HTML unit driver in selenium webdriver?


How do u get the width of the textbox?


How to check whether a text is underlined or not?


How to check the cursor type changes on hovering on a link?


How to verify that the font-size of a text is 12px?


How to verify that an image is to the right of text?


Is WebElement an interface or a class?


Which is the super interface of webdriver?


How to type text in a new line inside a text area?


How to switch back from a frame?


What is Polymorphism? What are the different types of Polymorphism?


In which type of Collection Dupplicate values are not allowed?


what is the difference between array & arrayList?


What is Type Casting? Give example?


why we can not use CSS selector instead of xpath.


Explain about Diamond problem in Java.


why string is not primitive


. difference between default and protected


how to avoid any variable to serialize


Join My Facebook Group
Join Group

About Author

Myself KarthiQ, I am the author of this blog, I know ways to write a good article but some how I donot have the skills to make it to reach people, would you like help me to reach more people By sharing this Article in the social media.

Share this Article Facebook interview question
Comment / Suggestion Section
Point our Mistakes and Post Your Suggestions
  • Vasista
    Nice collection
    • karthiQ [ admin]
      Thanks Vasista, for your feedback
  • sush
    Hi Sir,
    Thank you so much for providing such a wonderful questions and answers.
    Also provide some API(rest and soup) interview questions please
    • karthiQ [ admin]
      Thanks for the comment, we would definitely write API testing articles very soon
    Selenium-Webdriver.Com [Group]
    Facebook Group · 801 members
    Join Group
    Learn Selenium Webdriver Concepts and Interview Questions Learn and code
    Copyright © CherCher Tech