Selenium Interview Questions - Bug Reaper

                  Bug Reaper

Lean about Automation Testing,Selenium WebDriver,RestAssured,Appium,Jenkins,JAVA,API Automation,TestNG,Maven, Rest API, SOAP API,Linux,Maven,Security Testing,Interview Questions

Monday 5 May 2014

Selenium Interview Questions

What is a Build Tool?

A build tool is a tool that automates everything related to building the software project. Building a software project typically includes one or more of these activities:
  • Generating source code (if auto-generated code is used in the project).
  • Generating documentation from the source code.
  • Compiling source code.
  • Packaging compiled code into JAR files or ZIP files.
  • Installing the packaged code on a server, in a repository or somewhere else.

Running Maven

  • When you have installed Maven and have created a POM file and put the POM file in the root directory of your project, you can run Maven on your project.
    Running Maven is done by executing the mvn command from a command prompt. When executing the mvn command you pass the name of a build life cycle, phase or goal to it, which Maven then executes. Here is an example:
    mvn install
    
    This command executes the build phase called install (part of the default build life cycle), which builds the project and copies the packaged JAR file into the local Maven repository. Actually, this command executes all build phases before install in the build phase sequence, before executing the install build phase.
    You can execute multiple build life cycles or phases by passing more than one argument to the mvn command. Here is an example:
     mvn clean install
    
    This command first executes the clean build life cycle, which removes compiled classes from the Maven output directory, and then it executes the install build phase.
    You can also execute a Maven goal (a subpart of a build phase) by passing the build phase and goal name concatenated with a : in between, as parameter to the Maven command. Here is an example:
    mvn dependency:copy-dependencies
    
    This command executes the copy-dependencies goal of the dependency build phase.

 Unit Test Execution

SampleTest.java:
01package com.javacodegeeks;
02
03import org.junit.Assert;
04import org.junit.Test;
05
06public class SimpleTest {
07
08   @Test
09   public void test() {
10      SampleExample example = new SampleExample();
11      example.addInteger(10);
12      example.addInteger(100);
13      Assert.assertEquals(example.getSize(), 2);
14   }
15}

  • In order for all units tests to be executed, we use the command:
    1mvn test
The -Dtest option specifies which unit test shall be executed:
1mvn -Dtest=SimpleTest test

Name 5 different exceptions you had in selenium web driver and mention
.

What instance you got it and how do you resolve it?

·           WebDriverException
·           NoAlertPresentException
·           NoSuchWindowException
·           NoSuchElementException
·           TimeoutException
       WebDriverException

 WebDriver Exception comes when we try to perform any action on the non-existing driver.

In TestNG I have some test's  Test1-Test2-Test3-Test4-Test5I want to run my execution order is Test5-Test1Test3-Test2-Test4.How do you set the execution order can you explain for that?

public class testngexecution {

@Test(priority=2)

public void test1()
{System.out.print("Inside Test1");
}

@Test(priority=4)
public void test2()
{System.out.print("Inside Test2");
}

@Test(priority=3)
public void test3()
{System.out.print("Inside Test3"); 
}

@Test(priority=5)
public void test4()
{System.out.print("Inside Test4");
}

@Test(priority=1)
public void test5()
{System.out.print("Inside Test5");
}

How to refresh a page without using context click?

1.Using navigate.refresh() method
driver.navigate().refresh();

2.Using get() method
driver.get(driver.getCurrentUrl());


What is the difference between driver.Close() and driver.Quit () method?

Close() - It is used to close the browser or page currently which is having the focus.
Quit() - It is used to shut down the web driver instance or destroy the web driver instance
(Close all the windows)


Ques 32) How do you simulate scroll down action ?
Ans- Use java script to scroll down-


19.   How to handle internationalisation through
 web driver?
FirefoxProfile profile = new FirefoxProfile();
profile.set Preference("intl.accept_languages","jp");
Web driver driver = new FirefoxDriver(profile); driver.get(google.com) will open google in 
Japanese Lang
24. How can we get the font size, font color, 
font type used  for a particular text on a web
page 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);

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


driver.navigate().forward();
driver.navigate().back();

No comments:

Post a Comment