HCL Technologies Selenium Interview Questions

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.
a
b
c
• driver.findElement(By.xpath(“//*[contains(text(),’b’)]”)).click(); or
• //div/button[contains(text(),’b’]

How to do Applet testing using selenium?

Please see below URLs:
http://docs.codehaus.org/display/FEST/Selenium
https://code.google.com/p/festselenium/
HCL Technologies Selenium Recently Asked Interview Questions Answers
HCL Technologies Selenium Recently Asked Interview Questions Answers

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.
WebDriver driver = new InternetExplorerDriver();
driver.get(“http://google.com”);
driver.close();
driver.quit();

NoAlertPresentException
When we try to perform an action i.e., either accept() or dismiss() which is not required
at a required place; gives us this exception.
try{
driver.switchTo().alert().accept();
}
catch (NoAlertPresentException E){
E.printStackTrace();
}

NoSuchWindowException
When we try to switch to an window which is not present gives us this exception:
WebDriver driver = new InternetExplorerDriver();
driver.get(“http://google.com”);
driver.switchTo().window(“Yup_Fail”);
driver.close();
In the above snippet, line 3 throws us an exception, as we are trying to switch to an
window that is not present.

Similar to Window exception, Frame exception mainly comes during switching between the frames.
WebDriver driver = new InternetExplorerDriver();
driver.get(“http://google.com”);
driver.switchTo().frame(“F_fail”);
driver.close();
In the above snippet, line 3 throws us an exception, as we are trying to switch to an
frame that is not present.

NoSuchElementException
This exception is thrown when we WebDriver doesn’t find the web-element in the DOM.
WebDriver driver = new InternetExplorerDriver();
driver.get(“http://google.com”);
driver.findElement(By.name(“fake”)).click();

TimeoutException
Thrown when a command does not complete in enough time.
All the above exceptions were handled using try catch exceptions.

How do you manage the code versions in your project?

Using SVN or other versioning tools

Latest version of Firefox and selenium in market and the version on which you are testing which you are testing.

FF Latest version till Dec,2013 for windows7,64 bit :26.0.I use FF 25.0.1 (ur ans. may differ)
Selenium web driver latest version till dec,2013- 2.39.0 I use selenium 2.37 see latest at http://www.seleniumhq.org/download/

How to know all the methods supported in web driver and its syntax.

In Org.openqa.selenium package, web driver interface has all the main methods that can be used in Selenium Web driver
HTTP://docs.seleniumhq.org/docs/03_webdriver.jsp

How do you create html test report from your test script?

I would see below 3 ways:

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

List the browsers, OS supported by the Selenium Windows Linux Mac

IE Y NA NA
FF Y Y Y
Safari Y N Y
Opera Y Y Y
Chrome Y Y Y

Can you explain Selenium Mobile Automation?

Some Good urls’s till the time i write custom document for it.
https://code.google.com/p/selenium/wiki/AndroidDriver
http://manojhans.blogspot.in/2013/08/native-android-apps-automation-with.html

How to highlight an object like qtp/uft does through selenium and java?

public void highlightElement(WebDriver driver, WebElement element) {
for (int i = 0; i < 2; i++)
{
JavascriptExecutor js = (JavascriptExecutor) driver;
js.executeScript(“arguments[0].setAttribute(‘style’, arguments[1]);”, element, “color: yellow; border: 2px solid yellow;”);
js.executeScript(“arguments[0].setAttribute(‘style’, arguments[1]);”, element, “”);
}}
Call the highlightElement method and pass webdriver and WebElement which you want to highlight as arguments.


Automation Testing Lifecycle?

Requirement Gathering
Analysis
Designing
Development
Testing
Maintenance

 What is Selenium?

Selenium is Open source tool.
Selenium supports to automate the web applications.
Selenium is a suite of Software tools. It is a not a single tool. With the help of other third-party tools will build a selenium framework.
It will support various browsers
It will support various Languages
It will support various operating Systems.

List out the Selenium Components?

IDE – Selenium Integrated Development Environment
RC- Selenium Remote Control
WebDriver
Selenium Grid

Difference between Selenium & QTP?

Selenium QTP
Open Source Paid
More Add-Ons we can use Limited add-ons Only
It will support multiple browsers It will support only Firefox, Chrome, IE
Supports different OS It will support only Windows
It will support Mobile Devices QTP Supports Mobile app test automation (iOS & Android) using HP solution called – HP Mobile Center
Can execute tests while the browser is minimized Not Possible here
Can execute tests in parallel. Can only execute in parallel but using Quality Center which is again a paid product.

What are all the collections concepts mainly will use in selenium?

List
Set

What is the difference between verification and validation?

Verification:  Are we building the application or not – to verify this approach is called as “Verification”.
Validation: Are we building the right application or not – to verify this approach is called as “Validation”.

 What are all the Testing types we can able to perform using with Automation Testing tool?

Functional Testing: Functional testing is performed using the functional specification provided by the client and verifies the system against the functional requirements.
Ex: All keyboard keys are working properly or not.

Regression Testing:  New functionality changes should not affect the existing functionality.

Advantages of Automation Framework?

Reusability of code
Maximum coverage
Recovery scenario
Low-cost maintenance
Minimal manual intervention
Easy Reporting

 How to handle Alerts in Selenium?

Will use switchTo() method. Please check the below scenarios.

void dismiss() // To click on the ‘Cancel’ button of the alert.
driver.switchTo().alert().dismiss();

void accept() // To click on the ‘OK’ button of the alert.
driver.switchTo().alert().accept();

String getText() // To capture the alert message.
driver.switchTo().alert().getText();

void sendKeys(String stringToSend) // To send some data to alert box.
driver.switchTo().alert().sendKeys(“Text”);

Explain about Framework using in your project?

You need to clearly explain the following steps:

First, you need to answer why you selected this framework.
How you are maintaining your test suites /cases.
Passing of test data to your test suite/test cases.
Object repository.
Test case execution.
Library folders.
Log files generation.
Test report generation.
Configuration files.
Interviewer cross verifies you by asking versions you are using, we should be ready to answer it.

What is TestNG Data Provider? Write a Syntax for it?

@Test method receives data from this DataProvider. dataProvider name equals to the name of this annotation.

Syntax : @DataProvider(name = “DataProvidename”)

How you will get the title of the page?

driver.getTtile();

How you will get the current URL of the page?

driver.getCurrentUrl();

How to achieve synchronization process in Selenium WebDriver?

Unconditional Synchronization
          – Thread.sleep();

Conditional Synchronization
           – Implicit Wait

           – Explicit Wait


How to handle hidden elements in Selenium WebDriver?

There is no method defined in WebDriver to handle hidden elements and hence we can not handle hidden elements in Selenium.

But through Javascript we can achieve the same.

Syntax:

JavascriptExecutor jsx=((JavascriptExecutor) driver);

jsx.executeScript(“document.getElementsByClassName(element).click();”);

List some scenarios which we cannot automate using Selenium WebDriver?

Bitmap comparison Is not possible using Selenium WebDriver
Automating Captcha is not possible using Selenium WebDriver
We can not read barcode using Selenium WebDriver
We can not automate OTP

How to Upload a file in Selenium WebDriver?

We can Upload a file in Selenium WebDriver directly by passing the Path of the file as an argument to the sendKeys() if the element contains “type=file” in the source code.

Syntax:

driver.findElement(By.xapth(“//div[@type=’file’]”)).sendKeys(“C://Downloads/Resume.html”);

If the element does not contains “type=file” in the source code then uploading a file in Selenium WebDriver can be handled by using Robot class or AutoIT.

How to set test case priority in TestNG?

We can set test case priority in TestNG by using priority attribute to the @Test annotations.

Example:

@Test(priority=2)

public void m1(){

System.out.println(“This is m1 method”);

}

@Test(priority=1)

public void m2(){

System.out.println(“This is m2 method”);

}

Output:

This is m2 method

This is m1 method.

Post a Comment

Previous Post Next Post