Writing a simple function function in Selenium
I am a fresher in Selenium. I have lots of doubt about Selenium functions. I am using Selenium RC with Java and Eclipse.
I need to write one simple function for adding two numbers. Where will I write that functio开发者_如何学编程n inside the test()
?
How can I call that function if we want any other object for this function? Do we need to declare any header file for calling this function? Please help me.
I would look at this helpful tutorial part 1, part 2
Lets say the function is:
public void waitForElementExistance(final String elementLocator,
final int seconds, final boolean exists) throws Exception {
waitTimeFor(new Condition() {
@Override
public boolean verify() {
return selenium.isElementPresent(elementLocator) == exists;
}
}, 10);
}
You write this function -- for example -- just above the test()
You can call it in your test() like this:
waitForElementExistance("css=div.buttonlabel:contains(Upload)", 10, true);
精彩评论