Mindtree Selenium Recently Asked Interview Questions Answers

What is the difference between “/” and “//”

Single Slash “/” – Single slash is used to create XPath with absolute path i.e. it locates the element from the root node.

Example:

/html/body/div[2]/div[4]/table/tbody/tr[4]/td/span

Double Slash “//” – Double slash is used to create XPath with relative path i.e.  it locates the element from the current node.

Example:

//input[@name=’email’]
Mindtree Selenium Recently Asked Interview Questions Answers
Mindtree Selenium Recently Asked Interview Questions Answers

What is the difference between Assert and Verify in Selenium?

There is no difference between Assert and Verify in a positive scenario.

Assert: If the assert condition is true then the program control will execute the next test step but if the condition is false, the execution will stop and further test step will not be executed.

Verify: If the verify condition is true then the program control will execute the next test step but if the condition is false, the execution of the current step will be skipped and further test step will be executed.

What is the super interface of WebDriver?

SearchContext  is the super interface of WebDriver

How many ways can we load a web page?

We can load a webpage(url) in two ways:

driver.get(“URL”);
driver.navigatr().to(“URL”);

How can we maximize browser window and delete cookies in Selenium?

To maximize browser window in selenium we use maximize() method.

Syntax:

driver.manage().window().maximize();

To delete cookies we use deleteAllCookies() method.

Syntax:

driver.manage().deleteAllCookies();

How to Handle 2 Frames?

     to switchto a frame:

     driver.switchTo.frame(“Frame_ID”);

     to switch to the default again.(parent)

     driver.switchTo().defaultContent();

Explain About Maven concept?

     Maven simplifies the code handling and process of building the project. Most of the projects follow maven structure.

     Download all dependencies provided the dependencies are available in maven central repository. If any of the dependency is not available in maven central repository then you have to       add repository path in pom.xml explicitly.

    There are many other build tools available in like ant. But it is better to use maven while dealing with different versions and different dependencies. Maven even can manage the dependencies of dependencies. Other tools may not provide such flexibility like maven

Why Jenkins and Selenium?

Running Selenium tests in Jenkins allows you to run your tests every time your software changes and deploy the software to a new environment when the tests pass.
Jenkins can schedule your tests to run at specific time.
You can save the execution history and Test Reports.
Jenkins supports Maven for building and testing a project in continuous integration.

How to capture the color of Web Element or text color in WebDriver?

You can get the element color(Background color of element) by:

     element.getCssValue(“background-color”);

You can get the element text/caption color by:

     element.getCssValue(“color”);

How to handle 2 windows or explain window handling.

driver.getWindowHandle();  – Single Window

       driver.getWindowHandles();  – Multiple windows

Difference between ANT and MAVEN?

Ant Maven
Ant doesn’t has formal conventions, so we need to provide information of the project structure in build.xml file. Maven has a convention to place source code, compiled code etc. So we don’t need to provide information about the project structure in pom.xml file.
Ant is procedural. You need to provide information about what to do and when to do through code. You need to provide order. Maven is declarative, everything you define in the pom.xml file.
There is no life cycle in Ant. There is life cycle in Maven.
It is a tool box. It is a framework.
It is mainly a build tool. It is mainly a project management tool.
The ant scripts are not reusable. The maven plugins are reusable.
It is less preferred than Maven. It is more preferred than Ant.

What is latest version of Selenium WebDriver?

3.11

How to Upload the file in selenium?

Using with SendKeys
RobotClass
AutoIT

List out some TestNG Annotations.?

@BeforeSuite – Before Suite will always execute prior to all annotations or tests in the suite.
@BeforeTest – Before Test will always execute prior to Before Class, ,Before Method and Test Method
@BeforeClass – Before Class will always execute prior to Before Method and Test Method
@BeforeMethod – Before Method will execute before every test method
@AfterMethod – After Method will execute after every test method
@AfterClass – After Class will always execute later to After Method and Test method
@AfterTest – After Test will always execute later to After Method, After Class
@AfterSuite  – After suite will always execute at last when all the annotations or test in the suite have run
@Test – Mandatory annotation.

How you will share your output to managers?

TestNG – Emailable Report or XSLT Report.

How to merge all your team members’ code and how you will run?

Git Repository or SVN

How to read and Write the Data from Excel Sheet?

Read Excel Data : FileInputStream.

         Write Excel data : FileOutStream

What is the difference between xpath and css selector?

CSS selectors perform far better than Xpath. Majorly in IE Browser.

Xpath : powerful selection of the DOM
CSS : looks simpler. consistent support across browsers
XPATH: no native support for xpath in IE (WebDriver uses a 3rd party library)
CSS: Tests may need to be updated with UI changes
Xpath engines are different in each browser, hence make them inconsistent
IE does not have a native xpath engine, therefore selenium injects its own xpath engine for compatibility of its API. Hence we lose the advantage of using native browser features that WebDriver inherently promotes.
Xpath tend to become complex and hence make hard to read

Explain Testng.xml structure. ( Suite-> Test> Classes>Class)?

 Example:

<?xml version=”1.0″ encoding=”UTF-8″?>

<suite name=”example suite 1″ verbose=”1″ >

 <test name=”Regression suite 1″ >

   <classes>

     <class name=”com.first.example.demoOne”/>

     <class name=”com.first.example.demoTwo”/>

     <class name=”com.second.example.demoThree”/>

   </classes>

</test>

</suite>

We need to specify the class names along with packages in between the classes’ tags.

Post a Comment

Previous Post Next Post