Selenium FAQS asked in Interviews


1. What is data driven framework?
This frame work is used when an application is test with multiple sets of data. The
data is passed to the scripts from data files like excel files, csv files, ODBC (Open
Database Connectivity) and ADO (ActiveX Data Objects) objects.
Data driven framework is a systematic approach to test an application. It may
contain all the structured information like data driven files, library functions, and
user defined functions. Using the driver script, we can import theses files as a input
to the application and test it. This is called data driven frame work. Data driven
approach is being by most of the industries
2 what is keyword, hybrid framework?
Frame Work is the model or structure we follow for a Project. It is the approach that
we follow to automate the Project. There are so many types of framework in QTP.
1. Data driven frame work
2. Keyword driven frame work
3. Module driven framework
4. Hybrid driven frame work
The framework you choose depends on the model of your Project. Usually most of
projects fall under hybrid driven frame work.
Data driven framework:
Keyword driven framework:
Module driven frame work:
Hybrid Frame work:
This will be the combination of the any frameworks like Keyword
driven+DataDriven or Data driven + modular driven. we will divide entire
project in to modules and write functions or procedures for each and every
module and automate the project. Hybrid driven framework: it is combination
of Data driven and module driven framework.Firstly we should add the objects
to repository ( Shared repository is preferable) Then we can generate/write
scripts for each functionality and save them as the library files ( .vbs
files)Then we have to associate all these library files(which are generated to
test different functionalities) to Quick Test. Here we divide the entire project in to
modules and start automation by writing data driven scripting for each one of them.
Subbu
We will have test data either in excel sheet or flat files or from database...we will
pass that test data in to the script and perform data driven testing.
3 what is iframe?
An <iframe></iframe> element allows the placement of an inline frame within an
HTML document, which allows the display of another, separate document. Any
content between the start and close tag of the <iframe> element is ignored.
There are various ways of selecting an IFrame with selenium and accessing data
within the IFrame: By Name:selenium.selectFrame("mainFrame"); //name of the
IFrame
By DOM:
Remember index starts at 0, so "index=1″ will select the second IFrame. We
can call the selectFrame() function multiple times to select the nested
IFrames:
selenium.selectFrame("index=1″);
selenium.selectFrame("index=1″); will select the second IFrame within the
second IFrame from the root
4 what is difference b/w xpather and xpath checker?
Firebug - the right-click "copy XPath" command copies the path as all
lower-case, and some XML parsers (like the MXSML parser used in Final
Builder) are case-sensitive - so you'll need to correct the casing of your
Firebug-copied XPath statement otherwise your parser won't find any
matching nodes.
XPather
...generates
The XPather is a simple
selenium.selectFrame("dom=window.frames[1]"); //second IFrame By
Index: selenium.selectFrame("index=1″); //second IFrameXPaths while browsing or
inspecting HTML/XML/*ML documents; evaluates your XPaths and inspects the
results; extracts the content.Firefox extension that integrates both with the
browser and its DOMInspector. Thus, is't very lightweight and cross-platform. It is
valuable mainly as a web/XML-app development and hacking tool.XPath
Checker XPather
String-match Patterns
Subbu
Feature rich XPath generator, editor, inspector and simple extraction tool...
5 what is diff b/w Firefox and chrome and ie?
 Selenium scripts will run very fast in Firefox when we compare with the IE.
6 .how can u capture the entire pages, one page in single window? How it use I mean that
cmd?
captureEntirePageScreenshot ( filename,kwargs )
 filename - the path to the file to persist the screenshot as. No filename extension will be
appended by default. Directories will not be created if they do not exist, and an exception
will be thrown, possibly by native code.
 kwargs - a kwargs string that modifies the way the screenshot is captured. Example:
"background=#CCFFDD" . Currently valid options:
background
the background CSS for the HTML document. This may be useful to set for
capturing screenshots of less-than-ideal layouts, for example where
absolute positioning causes the calculation of the canvas dimension to fail
and a black background is exposed (possibly obscuring black text).
 
7. How many types of pattern matching, list of it? Like regular expressions, group
exp,exact expressions?
Various Pattern syntaxes are available for matching string values:
glob:
Match a string against a "glob" (aka "wildmat") pattern. "Glob" is a kind of
limited regular-expression syntax typically used in command-line shells. In a
glob pattern, "*" represents any sequence of characters, and "?" represents
any single character. Glob patterns match against the entire string.
regexp:
Match a string using a regular-expression. The full power of JavaScript
regular-expressions is available.
exact:
Match a string exactly, verbatim, without any of that fancy wildcard stuff.
If no pattern prefix is specified, Selenium assumes that it's a "glob" pattern.
8 what is diff b/w wait for page to load, thread. Sleep, set speed?
Subbu
Sleep, suspends the current thread for a period of time.
The expiration of that time is what will make the thread runnable.
Wait, suspends the current thread until some event has done.
9 what are the different startup modes in selenium RC
 Mainly we had 2 types to startup modes in selenium RC.
you can launch Selenium Remote Control server using following command ( Make sure
that you are into directory where selenium-server.jar is located or this directory is in your
path variable ) -
java -jar selenium-server.jar
This command should start Selenium Server on your machine and your automation scripts
are ready to interact with your web application using this server. You can leave this server
up and running while you are developing and executing your automation scripts. If you
wish, you can also start Selenium Remote Control in interactive mode and start playing
with its various commands on command prompt itself. In order to do that, you need to
supply a command line option called interactive.
java -jar selenium-server.jar -interactive
Apart from this there are many command line options that you can specify while starting
selenium RC.
-port :
-timeout : an integer number of seconds before we should give up
-interactive:
-singleWindow:
-profilesLocation:
-forcedBrowserMode : sets the browser mode to a single argument (e.g. "*iexplore") for
all sessions, no matter what is passed to getNewBrowserSession
-forcedBrowserModeRestOfLine :
-userExtensions :
-browserSessionReuse:
-firefoxProfileTemplate <dir>:
-debug: puts you into debug mode, with more trace information and diagnostics on the
console
-browserSideLog:
Subbu
-ensureCleanSession:
-trustAllSSLCertificates:
-log :
-htmlSuite :
-proxyInjectionMode:
-dontInjectRegex :
-userJsInjection :
-userContentTransformation :
10 how to automate flash based application?
Both selenium RC and selenium Webdriver can be used for flash/flex application testing.
Procedure is same for testing flash and flex applications using selenium. FlashSelenium
API in Selenium RC helps us to test flash/flex based applications using RC. While in
webdriver, you need to make your own custom Javascript Execution functions in order to
test flash applications using Selenium. But in order to test such appications, you need to
make sure that you have the access to source code of the application. This means that you
cannot just go and test any flash application present on the internet.
To test flash application u need to add below flash jar file to the eclipse.
"Flashselenium-java-client-extension.jar"
 While writing the code u need to import the flash lib
import com.thoughtworks.selenium.FlashSelenium;
a regular expression which is matched against all test HTML content; the second is a string
which will replace matches. These flags can be used any number of times. A example of
how this could be useful: if you add "-userContentTransformation https http" then all
"https" strings in the HTML of the test application will be changed to be "http". specifies a
JavaScript file which will then be injected into all pagesan optional regular expression that
proxy injection mode can use to know when to bypss injection puts you into proxy
injection mode, a mode where the selenium server acts as a proxy server for all content
going to the test application. Under this mode, multiple domains can be visited, and the
following additional flags are supported: Run a single HTML Selenese (Selenium Core)
suite and then exit immediately, using the specified browser (e.g. "*firefox") on the
specified URL (e.g. http://www.google.com"). You need to specify the absolute path to
the HTML test suite as well as the path to the HTML results file we'll generate. writes lots
of debug information out to a log file Forces the Selenium proxy to trust all SSL
certificates. This doesn't work in browsers that don't use the Selenium proxy. If the
browser does not have user profiles, make sure every new session has no artifacts from
Subbu
previous sessions. For example, enabling this option will cause all user cookies to be
archived before launching IE, and restored after IE is closed. enables logging on the
browser side; logging messages will be transmitted to the server. This can affect
performance. normally, we generate a fresh empty Firefox profile every time we launch.
You can specify a directory to make us copy your profile directory instead. stops
re-initialization and spawning of the browser between tests
-avoidProxy: By default, we proxy every browser request; set this flag to make the
browser use our proxy only for URLs containing '/selenium-server' indicates a JavaScript
file that will be loaded into selenium sets the browser mode to all the remaining tokens on
the line (e.g. "*custom /some/random/place/iexplore.exe") for all sessions, no matter
what is passed to getNewBrowserSession Specifies the directory that holds the profiles
that java clients can use to start up selenium. Currently supported for Firefox only. puts
you into a mode where the test web site executes in a frame. This mode should only be
selected if the application under test does not use frames.puts you into interactive mode.
See the tutorial for more details the port number the selenium server should use (default
4444) stringregexp pattern
Saves the entire contents of the current window canvas to a PNG file. Contrast this with
the captureScreenshot command, which captures the contents of the OS viewport (i.e.
whatever is currently being displayed on the monitor), and is implemented in the RC only.
Currently this only works in Firefox when running in chrome mode, and in IE non-HTA
using the EXPERIMENTAL "Snapsie" utility. The Firefox implementation is mostly
borrowed from the Screengrab! Firefox extension. Please see http://www.screengrab.org
and http://snapsie.sourceforge.net/ for details.
Arguments:
An interactive editor for XPath expressions