Selenium Interview Questions - Chercher - Tech
Selenium Interview Questions - Chercher - Tech
Couple of years back we had only one automation giant which is QTP ( currently known as UFT ).
QTP was owned by company called Mercury, they were charging heavy for the QTP product.
After years a program was developed by Jason Huggins a programmer at ThoughtWorks (still we can
find couple of thought work pacakages in selenium webdriver if you have noticed), they wanted to
name the program as something which gives opposite meaning to QTP, later they gave name
Selenium.
Selenium is Chemical mineral which cures the wounds caused by Mercury.
What is TestNG?
TestNG is a testing framework designed to simplify a broad range of testing needs, from unit testing
to integration testing.
Explain what are the basic steps required in writing TestNG tests?
1. Write down the business logic of your test and insert TestNG annotations in your code
2. In a build.xml or testing.xml, add the information about your test
3. Run TestNG
classes – TestNG will run all the methods in the same class in the same thread, but each class will be
run in a separate thread.
methods – TestNG will run all your test methods in separate threads. Dependent methods will also
run in separate threads but they will respect the order that you specified.
instances – TestNG will run all the methods in the same instance in the same thread, but two methods
on two different instances will be running in different threads..
the attribute thread-count allows you to specify how many threads should be allocated for this
execution.
What is the time unit we specify in test suites and test cases?
We specify the time unit in test suites and test cases is in milliseconds.
How to write regular expression in testng.xml file to search @Test methods containing
"product" keyword.
Regular expression to find @Test methods containing keyword "product" Is as bellow.
<include name=".*product.*"/>
Mention different ways in which you can produce reports for TestNG results?
There are two ways to produce a report with Test NG, they are
Listeners: For a listener class to implement, the class has to implement the org.testng./TestListener
interface. These classes are informed at runtime by TestNG when the test begins, finsishes, skips,
passes or fails.
Reporters: For a reporting class to implement, the class has to implement an org.testng/Reporter
interface. When the whole suite run ends, these classes are called. When called, the object consisting
the information of the whole test run is delivered to this class.
Why do we write Webdriver driver = new FirefoxDriver(), why not SearchContext driver =
new FirefoxDriver() ?
Don't hurry to answer like, Webdriver is interface and FirefoxDriver is Class. This is right but you
need to understand the question first.
He is asking about SearchContext, which is parent interface of Webdriver, so the answer would be .
Yes, we can write like that because SearchContext is parent of all the Interfaces and classes present in
selenium.
Testcase failed saying "ElementNotVisible", but when analyzed manually element is visible
? How to Handle it ?
There are couple of things which may cause this issue.
Element may not be visible in automation due to the speed of selenium.
If you closed a hidden division pop up, and tried to perform action, then there is a chance that hidden
division popup' animation wanot over which could cause this issue.
There is could be an another element which has same xpath or locator in some other page
Example : Consider you have a element which has xpath as //button[@id='abc'] on page X, by
clicking some tab on xpage navigates the user to Y page, Now there is an element on Y page which
have xpath same as //button[@id='abc'].
But when you launch your application, application may be directly landed on page Y. So with this
scenario, if you try to perform on element on Y page it could throw an Exception.
Step by step Solution :
First verify whether it is really any of the above scenario ?
Print number of element present with that xpath using findElements method
If there is only one element please follow program 1, If there is more than 1 element follow program
2.