Question 1:
How do I implement data
driven testing using Selenium?
Answer
Selenium, unlike others
commercial tools does not have any direct support for data driven testing. Your
programming language would help you achieving this. You can you jxl library in
case of java to read and write data from excel file. You can also use Data
Driven Capabilities of TestNG to do data driven testing.
Question 2:
What is equivalent to
test step, test scenario and test suite in Selenium.
Answer
If you are using Java
client driver of Selenium then TestNG test method could be considered
equivalent to test step, a test tag could be considered as test scenario and a
suite tag could be considered equivalent to a test suite.
Question 3:
How do I get attribute
value of an element in Selenium?
Answer
You could use
getAttribute method
With Selenium 1.0 –
String var =
selenium.getAttribute("css=input[name='q']@maxlength");
System.out.println(var);
With Selenium 2.0 –
String var =
webDriver.findElement(By.cssSelector("input[name='q']")).getAttribute("maxlength")
System.out.println(var);
Question 4:
How do I do database
testing using Selenium?
Answer
Selenium does not
support database testing but your language binding does. For example while
using java client driver you can use java data base connectivity (jdbc) to
establish connection to data base, fetch/write data to data base and doing data
comparison with front end.
Question 5:
I completed test
execution and now I want to email test report.
Answer
If you are using “ant”
build tool then you can use “mail” task to deliver your test results. Similar
capabilities are available in Continuous Build Integration tools like – Hudson.
Question 6:
How do I make my tests
more comprehensible?
Answer
Selenium tests which are
written as –
selenium.click("addForm:_ID74:_ID75:0:_ID79:0:box”);
Make it tough to
understand the element which is being exercised upon.
Instead of hard coding
element locator in tests you should externalize them. For example with java you
can use properties file to contain element locators and then locator reference
is given in test script. Following this approach previous test step would look
as –
selenium.click(PolicyCheckbox);
And this is far more
comprehensible.
Question 7:
Why should I use Page
Object?
Answer
Page object is a design
pattern which distinguishes the code carrying out operations on page and code
which carries out tests (assertion/verification). While implementing page
object you abstract functioning of a page or part of it in a dedicated “Classs”
which is then used by test script to perform actions on page and reach a stage
when actual test could be performed.
No comments:
Post a Comment