I am new to RobotFramework (actually evaluating it for a new test automation project).
In the past, I always created my own little framework using Java and page objects however this time I am wondering whether I can use an existing framework. I am evaluating Spock and Robot Framework.
My requirement is to test web application, windows objects and mobile apps so Robot definitely has an edge over Spock. Also I would prefer Python over Groovy any day.
I usually extend WebElement in my framework with following code. I am wondering whether it would be possible to do such things in Robot Framework.
//importing webdriver and other selenium libraries
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebDriverException;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.interactions.internal.Coordinates;
import org.openqa.selenium.internal.Locatable;
import org.openqa.selenium.internal.WrapsElement;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.FluentWait;
import org.openqa.selenium.support.ui.Wait;
//interface that will be implemented by my custom web element
interface MyElement extends WebElement, WrapsElement, Locatable {
}
//my custom web element class
public class MyWebElement implements MyElement {
private WebElement element;
//private constructor for my web element class
private MyWebElement(WebElement element) {
this.element = element;
}
//public factory method for my web element class
public static MyWebElement getInstance(By by) {
WebElement element = MyWebDriver.getInstance().findElement(by);
MyWebElement myWebElement = new MyWebElement(element);
return myWebElement;
}
//overriding WebElement method click
@Override
public void click() {
waitUntilClickable();
element.click();
}
//adding method waitUntilClickable to my web element
public MyWebElement waitUntilClickable() {
return waitUntilClickable(MyWebDriver.getTimeoutElementInMilliseconds(),
MyWebDriver.getPollingElementInMilliseconds());
}
//adding helper method to implement waitUntilClickable
public MyWebElement waitUntilClickable(long timeOutInMilliseconds,
long pollingIntervalInMilliseconds) {
Wait<WebDriver> wait = new FluentWait<WebDriver>(MyWebDriver.getInstance())
.withTimeout(timeOutInMilliseconds, TimeUnit.MILLISECONDS)
.pollingEvery(pollingIntervalInMilliseconds, TimeUnit.MILLISECONDS);
wait.until(ExpectedConditions.elementToBeClickable(element));
return this;
}
//other additional and overriding methods
//.........................
//.........................
Robot Framework looks good so far, I like python too.. however I don't know whether I would be able to extend the libraries like selenium2library to have my own custom methods, like I used to do in java in above examples.