March 23, 2019

Srikaanth

Hewlett-Packard Selenium Recently Asked Interview Questions Answers

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
Hewlett-Packard Selenium Recently Asked Interview Questions Answers
Hewlett-Packard Selenium Recently Asked Interview Questions Answers

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.

What are all the challenges you have faced while doing the Automation.?

Dealing with pop-up windows:
          Selenium can sometimes fail to record common popups in web apps. To handle any kind of alert popup, you can apply a getAlert function. Before actually running the script, you                must import a package that can generate a WebDriver script for handling alerts. The efficient interface brings with it the following commands: void dismiss(), void accept (),              getText(), void sendKeys(String stringToSend). The first two basically click on the “cancel” and “OK” buttons respectively on a popup window.

No event trigger from value changes:
Because Selenium does not initiate events with a change in values, one must do it oneself using fireEvent: selenium.FireEvent(cmbCategory, “onchange”);

      Timeout resulting from synchronization problems:
One should ideally use selenium.IsElementPresent(locator) to verify that the object is in a loop with Thread.Sleep

 Testing Flash apps:
To automate flash apps with Selenium, one can use Flex Monkium. The application source code must be compiled with the swc files generated by Flex Monkium. Then the app and the Selenium IDE are connected, and the tests can be recorded with IDE.

Unexpected error launching Internet Explorer. Browser zoom level should be set to 100% by default for the IE browser to overcome this error.
Protected Mode must be set to the same value error occurs when trying to run Selenium WebDriver on a fresh Windows machine. This issue can be fixed by using capabilities as below when launching IE.

What are Exception and Error? Specify the Difference.?

Exception: Exception occurs in the programmer’s code .which can be handled and resolvable.

Ex: arithmetic exception

DivideByZeroException

NullPointerException

ClassNotFoundException

Error: Errors are not resolvable by the programmer. Error occurs due to lack of system resources.

Ex: Stack overflow

hardware error

JVM error

Why Exception Handling important in Selenium?

To continue the flow of execution.

How to find whether an element is a Multidrop down or not?

By using isMultiple()

For example:

Boolean b=driver.findElement(By.id(“year”)).isMultiple();

System.out.println(b);

It retuns true if the element is multi drop down else false

What is the difference between getText() and getAttribute() ?

getText(): It is used to retrieve the text of a Text Element from the web page

For Example:

String Text = driver.findElement(By.id(“Text”)).getText();

getAttribute(): It is used to retrieve the text from a Text Field that is already eneterd into the text field.

For Example:

String Text = driver.findElement(By.id(“username”)).getAttribute();

How to select value in a dropdown?

To handle drop down, an object to be created to the Select class.

Select dropDown= new Select(element);

The value in the dropdown can be selected using 3 ways:

Syntax:

selectByValue()
selectByVisibleText()
selectByIndex()

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

close(): This method is used to close the current active window of the browser.

quit(): This method is used to close all the associated windows of the browser that are opened.


Subscribe to get more Posts :