Top Selenium Interview Questions and Answers asked in MNC companies

I am giving most top Selenium Interview Questions and Answers asked in MNC companies,which will helps you to get job in companies as Selenium Automation tester with Selenium WebDriver questions also.Please read it carefully until end questions and practice coding as i have given (Interview Questions) ,this questions are asked in my interview.

1.What is Selenium Webdriver?

Selenium is a open source automation testing tool which is used to test web applications,it's not support desktop means windows applications.Selenium support for 
n tier environment ,it support many programming languages those are Java,ruby,python,C# etc.Selenium supports all different browsers i.e Google Chrome,FireFox ,Internet Explorer,
Opera,Safari etc.

2.What are the components of Selenium?

Selenium is a package which will have Selenium IDE , Selenium RC(Selenium 1),Selenium Grid , Selenium WebDriver.Selenium IDE is a Firefox addon i.e plugin simply download
Selenium IDE plug in from firefox addons which is used for record and playback the application under test.

3.What is the use of Selenium IDE as record and Playback?

Selenium IDE is a firefox plugin which is used to record and playback the scripts in order to learn the selenium scripts easily with different languages.
Recorded script can convert Java,ruby,python etc languages in Selenium IDE,it has most useful commands which is useful in verification purpose.

4.What is the difference Between Selenium RC and Selenium Web Driver?

Selenium RC is a Selenium Remote Control which is used to test the application under test where we have to start the server each time before test excution.
Selenium Web driver which is not require any server to start before execution of test scripts application under test.
Selenium RC is a semi object oriented tool where Selenium web driver is a fully object oriented tool.
Selenium RC doesn't support listeners
Selenium Webdriver supports listeners for implementation on test scripts.

5.What are the problems you faced while testing with Selenium?

As per the question most of the people explain about exception faced while test script execution like Nosuch elements present etc.But here question indicates that
selenium limitations those are

1.Selenium doesn't support captha/Barcode functionalities.
2.Selenium doesn't support java applets
3.Selenium doesn't support mobile applications testing.
4.Selenium doesn't have inbuilt Reports generation for Test Results.We have to use for third party plugins.
5.In case face any problems need to communicate with Selenium community in order to resolve the problems ,there is no other communities to proper help.
6.For creating test cases we have to use for JUNIT or TEST NG framework ,there no built in frameworks. 
7.Tester should have any programming language.ex:java,ruby,python,php etc.

6.How you will handle AJAX controls using Selenium?

Ajax controls means loading ,waiting icons when we search the data it is taking some time to diaply results from the database at that time we will see icons as please wait,loading.
This type of ajax loading we can control by Implicit wait or Thread.Sleep()
Ex: driver.manage().timouts().implicitWait(30,Timunits.SECONDS);
eX:Thread.Sleep(3500) means 3.5 seconds

7.What is the difference between Thread.Sleep() and implicitwait()?

Both are wait types which will perform same operations or actions in test scripts but it has some major difference i.e Implicit wait only works first of the test script execution
but Thread.Sleep() will work every time you execute the script.It will wait untill thread.sleep(2500) 2.5 seconds but implicit wait will wait first time then second tim eonwards it will
not wait properly because i have faced same problem in script execution,this one i have observed closely.Implicit wait is wait untill time specific but some times it will not work as expected.

8.What is Assert in Selenium?

Assert is a verification point in Selenium which is used to verify the condition in Test script but Assert execute the test results untill it get success but once test case is fail
then it will stop test excution in selenium.

Example: 
String baseball = "10"
Assert.asserttrue(baseball.isEvenNumber(10));

9.What is Verify in Selenium ? 

Verify is a verification point in selenium which is helpful in verify the condition in Test script ,where verify execute the test cases in case it is fail or pass.It will not stop the
test excution if test case is fail.

Example:
VerifyTestPresent();
try {
      assertEquals(driver.getTitle(), "Google");
    } catch (Error e) {
      verificationErrors.append(e.toString());
    }

10.What are the different locators in Selenium?

Locators is used to identify the objects in Webpages just like Properties of web elements.In Selenium different types of Locators are present those are

1.ID
2.Name
3.ClassName
4.Xpath : Xpath is a XML path (Extendable Markup Language)
5.tagname : Ex: for link 'a'
6.LinkText : Ex: Home
7.Css selectors
8.DOM
9.PartialLinkText

11.How to count links in a webpage using Selenium?

In order to count the links of webpage we will use below script.

@Test
public void links(){

driver.get("http://www.google.co.in");
List<WebElement> alllinks = (List<WebElement>) driver.findElements(Bi.tagName("a"))

int countlinks=alllinks.size();
System.out.println("Total Number of links in a Webpage is :"+countlinks);

}

Output Is:
Total Number of links in a Webpage is : 176

12.How to find element is displayed on screen?

We can use isDisplayed() method to verify element is displayed in a webpage as below example.

public class example{

public static void main(String[] args){

WebDriver driver = new FirefoxDriver();
driver.get("http://www.wikishown.com");
String textele = driver.findElement(By.LinkText("All Questions"));

if(textele.isDisplayed()){
driver.findElement(By.LinkText("All Questions")).Click();
System.out.println("All Questions link is displayed in a webpage");

}else{
System.out.println("All Questions link is not displayed in a webpage");
}

}

}

13.How to handle alerts in a Selenium?

Alerts in a webpage can be handle by below code

Alert alert = driver.switchTo().alert();
alert.accept();


14.How to handle Frames in a selenium ? 

Frames in a webpage can be handle by three methods those are

1.Frame(int args); Selecting a frame with its index number i.e in case one webpage has more than one frame then first frame will be at index 0, and second  fraame at index 1.
2.Frame(String args);Here we can select a frame using name or id of particular frames.
3.Frame(WebElement args);

15.How to handle Mouse hover using Selenium ? 

Most of the time in our applications mouse hover menus would be there for examples My Account etc.Let's see the details below
We can use Actions method and WebElement to handle mouse hover in a webpage .

Example:

@Test
public void mousehove(){
driver.get("http://www.wikishown.com");
Thread.sleep(2500);
//Using Actions method

Actions action = new Actions();
WebElement element = driver.findElement(By.id("name"));
action.moveToElement(element).build()action;
action.perform();
action.click();
}

No comments:

Post a Comment