Advertisement |
|
||
21. How would you
make sure that a particular feature is enable or disabled in the browser
launched or how would launch a browser with some specific properties.
|
||
|
||
22. What are the
limitations with IE browser? What are the things that have to be done before
actually using the IE browser for the automation?
|
||
·
If you see issue something
like 'Unexpected error launching Internet Explorer' below, you have to set
'Enable protected mode' option in all levels with same value.
·
2. Make sure that the IE
browser zoom level is set to 100% so that the native mouse events can be set
to the correct coordinates.
·
3. It may be silly one,
But make sure you provide correct path when setting the property of Internet
explorer driver.
|
||
23. How would you
locate a Frame without ID or Name?
|
||
driver.switchTo().frame(frame);
|
||
24. Is it possible
to migrate from selenium RC to Webdriver. Can I execute the scripts written
in RC using webdriver. If yes how can we achieve the same?
|
||
Yes, it’s possible
to migrate.
The first step
when starting the migration is to change how you obtain your instance of
Selenium. When using Selenium RC, this is done like so:
Java Code:
Selenium selenium =
new DefaultSelenium(
"localhost", 4444, "*firefox",
"http://www.yoursite.com");
selenium.start();
This should be
replaced like so:
Java Code:
WebDriver driver =
new FirefoxDriver();
Selenium selenium
= new WebDriverBackedSelenium(driver, "http://www.yoursite.com");
Next Steps
Once your tests
execute without errors, the next stage is to migrate the actual test code to
use the WebDriver APIs. Depending on how well abstracted your code is, this
might be a short process or a long one. In either case, the approach is the
same and can be summed up simply: modify code to use the new API when you
come to edit it.
If you need to
extract the underlying WebDriver implementation from the Selenium instance,
you can simply cast it to WrapsDriver
Java Code:
WebDriver driver =
((WrapsDriver) selenium).getWrappedDriver();
This allows you to
continue passing the Selenium instance around as normal, but to unwrap the
WebDriver instance as required.
At some point, you’re
codebase will mostly be using the newer APIs. At this point, you can flip the
relationship, using WebDriver throughout and instantiating a Selenium
instance on demand:
Java Code:
Selenium selenium
= new WebDriverBackedSelenium(driver, baseUrl);
|
||
25. How to check
if a text is highlighted on the page?
|
||
|
||
26. WebDriver is a
class or interface? If interface name few of the methods which are part of
the webdriver interface. Name the classes which have done the implementation
from this interface.
|
||
WebDriver is
Interface.
Methods: close(),
findelememt(By by), findelemetns(By by), quit(), switchto() etc.
|
||
27. What is Page
object Model? What is page factory? How would you initialize the webelements
in Page Object Model?
|
||
·
Page Object Model is a design pattern to create Object
Repository for web UI elements.
·
Under this model, for each web page in the application there
should be corresponding page class.
·
This Page class will find the WebElements of that web page and
also contains Page methods which perform operations on those WebElements.
Advantages of POM
·
Page Object Patten says operations and flows in the UI should
be separated from verification. This concept makes our code cleaner and easy
to understand.
·
Second benefit is the object repository is independent of
testcases, so we can use the same object repository for a different purpose
with different tools. For example, we can integrate POM with TestNG/JUnit for
functional testing and at the same time with JBehave/Cucumber for
acceptance testing.
·
Code becomes less and optimized because of the reusable page
methods in the POM classes.
PageFactory
·
The PageFactory Class is an extension to the Page
Object design pattern. It is used to initialize the elements of the Page
Object or instantiate the Page Objects itself. Annotations for elements can
also be created (and recommended) as the describing properties may not always
be descriptive enough to tell one object from the other.
·
It is used to initialize elements of a Page class without
having to use ‘FindElement’ or ‘FindElements’.
PageFactory.initElements(driver,
PageName.class);
|
||
28. How would you
count the number of rows of a given table?
|
||
·
//To locate table.
WebElement
mytable = driver.findElement(By.xpath(".//*[@id='SomeID']/div[1]/table/tbody"));
·
//To locate rows of table.
List<WebElement>
rows_table = mytable.findElements(By.tagName("tr"));
·
//To calculate no of rows In table.
int rows_count
= rows_table.size();
|
||
29. Write the
sequence of steps to delete a particular row (with user name =
"xyz") in a table with multiple pages. One page contains max of 10
rows.
|
||
Steps should
include:
·
Locate the table
·
Locate the rows
·
Find a row with a user name “xyz”
·
If the user name is not present in the first page it should
navigate to the next page
·
Repeat first 3 steps again till the row with username = “xyz”
is found.
·
Delete the row.
|
||
30. Why do we need
a Maven? What is the purpose of creating our own framework when selenium has
already provided the APIs? Why do we need a framework?
|
||
Maven: Maven’s
primary goal is to allow a developer to comprehend the complete state of a
development effort in the shortest period of time. In order to attain this
goal there are several areas of concern that Maven attempts to deal with:
·
Making the build process easy
·
Providing a uniform build system
·
Providing quality project information
·
Providing guidelines for best practices development
·
Allowing transparent migration to new features
As part of the
Automation framework it’s easy to add/update tools/APIs according to the
latest versions available. We just need to configure the POM and build it.
All the required jars will be added to the framework automatically.
Framework:
Automation framework
is a way to organize your code in much meaningful manner, so that any person
who is luckily working with you should understand what each file has and what
is the purpose of adding the file.
A TEST Automation Framework is a set of guidelines like
coding standards, test-data handling, object repository treatment etc., which
when followed during automation scripting produce beneficial outcomes like
increase code re-usability, higher portability, reduced script maintenance
cost etc.
|
0 comments: