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.
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.
Most Common Exceptions Which We Notice In Selenium WebDriver?
NoSuchElementException: An element could not be located on the page using the given search parameters.
NoSuchFrameException: A request to switch to a frame could not be satisfied because the frame could not be found.
StaleElementReferenceException: An element command failed because the referenced element is no longer attached to the DOM.
Firefox Not Connected Exception: Firefox browser upgraded to new version.
ElementIsNotSelectable Exception: An attempt was made to select an element that cannot be selected.
unknown command Exception: The requested resource could not be found, or a request was received using an HTTP method that is not supported by the mapped resource.
ElementNotVisible Exception: An element command could not be completed because the element is not visible on the page.
InvalidElementState Exception: An element command could not be completed because the element is in an invalid state (e.g. attempting to click a disabled element).
UnknownError Exception: An unknown server-side error occurred while processing the command.
javascript error Exception: An error occurred while executing JavaScript code.
XPathLookupError Exception: An error occurred while searching for an element by XPath.
Timeout Exception: An operation did not complete before its timeout expired.
NoSuchWindow Exception: A request to switch to a different window could not be satisfied because the window could not be found.
InvalidCookieDomain Exception: An illegal attempt was made to set a cookie under a different domain than the current page.
UnableToSetCookie Exception: A request to set a cookie’s value could not be satisfied.
UnexpectedAlertOpen Exception: A modal dialog was open, blocking this operation
NoAlertOpenError Exception: An attempt was made to operate on a modal dialog when one was not open.
ScriptTimeout Exception: A script did not complete before its timeout expired.
InvalidElementCoordinates Exception: The coordinates provided to an interactions operation are invalid.
InvalidSelector Exception: Argument was an invalid selector (e.g. XPath/CSS).
Explain the difference between Absolute XPath and relative XPath?
Types of X-path
There are two types of XPath:
1) Absolute XPath.
2) Relative XPath.
Absolute XPath:
It is the direct way to find the element.
It will start with the single forward slash(/) – which means you can select the element from the root node.
Ex : html/body/div[1]/section/div[1]/div/div/div/div[1]/div/div/div/div/div[3]/div[1]/div/h4[1]/b
Disadvantage:
If there are any changes made in the path of the element then that XPath gets failed.
Relative XPath:
It will starts from the middle of the HTML. It starts with the double forward slash (//).
It which means it can search the element anywhere on the webpage.
Ex : //*[@class=’featured-box’]//*[text()=’Testing’]
How to Priority your tests in TestNG?
Ex: @Test (priority=1).
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
Computer Sciences Corporation 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.
Most Common Exceptions Which We Notice In Selenium WebDriver?
NoSuchElementException: An element could not be located on the page using the given search parameters.
NoSuchFrameException: A request to switch to a frame could not be satisfied because the frame could not be found.
StaleElementReferenceException: An element command failed because the referenced element is no longer attached to the DOM.
Firefox Not Connected Exception: Firefox browser upgraded to new version.
ElementIsNotSelectable Exception: An attempt was made to select an element that cannot be selected.
unknown command Exception: The requested resource could not be found, or a request was received using an HTTP method that is not supported by the mapped resource.
ElementNotVisible Exception: An element command could not be completed because the element is not visible on the page.
InvalidElementState Exception: An element command could not be completed because the element is in an invalid state (e.g. attempting to click a disabled element).
UnknownError Exception: An unknown server-side error occurred while processing the command.
javascript error Exception: An error occurred while executing JavaScript code.
XPathLookupError Exception: An error occurred while searching for an element by XPath.
Timeout Exception: An operation did not complete before its timeout expired.
NoSuchWindow Exception: A request to switch to a different window could not be satisfied because the window could not be found.
InvalidCookieDomain Exception: An illegal attempt was made to set a cookie under a different domain than the current page.
UnableToSetCookie Exception: A request to set a cookie’s value could not be satisfied.
UnexpectedAlertOpen Exception: A modal dialog was open, blocking this operation
NoAlertOpenError Exception: An attempt was made to operate on a modal dialog when one was not open.
ScriptTimeout Exception: A script did not complete before its timeout expired.
InvalidElementCoordinates Exception: The coordinates provided to an interactions operation are invalid.
InvalidSelector Exception: Argument was an invalid selector (e.g. XPath/CSS).
Explain the difference between Absolute XPath and relative XPath?
Types of X-path
There are two types of XPath:
1) Absolute XPath.
2) Relative XPath.
Absolute XPath:
It is the direct way to find the element.
It will start with the single forward slash(/) – which means you can select the element from the root node.
Ex : html/body/div[1]/section/div[1]/div/div/div/div[1]/div/div/div/div/div[3]/div[1]/div/h4[1]/b
Disadvantage:
If there are any changes made in the path of the element then that XPath gets failed.
Relative XPath:
It will starts from the middle of the HTML. It starts with the double forward slash (//).
It which means it can search the element anywhere on the webpage.
Ex : //*[@class=’featured-box’]//*[text()=’Testing’]
How to Priority your tests in TestNG?
Ex: @Test (priority=1).
Post a Comment