Receiver

The Receiver will be an abstract class called AActionKeyword that will contain empty method bodies that will be placeholders to perform the work by invoking Selenium WebDriver methods such as click(). Once again, we use an abstract class that has dummy implemented method bodies. Each individual concrete class will only implement the required methods.

We start with the abstract class with the unimplemented methods:

public abstract class AActionKeyword extends TestBase {

public AActionKeyword() throws IOException, FilloException {
super();
}
public void clickElement(String x) {
}
public WebDriver navigate(WebDriver driver2, String url) {
return null;
}
public WebDriver openBrowser(List<String> browsers) {
return null;
}
public void sendKeys(WebElement elem, String textFill) {
}

public void selectValue() {
}

}

Then comes the Concrete class with the implementations. Here, we open a Firefox driver, but we can parameterize this method to accept a string argument for the browser name:

public class OpenBrowser extends AActionKeyword {
        public WebDriver openBrowser() { WebDriver driver = new ChromeDriver(); return driver; }
}

The following code is for the sample driver script with a single execution. This script will simply open a Firefox browser for now:

public class MainClass {
public static void main(String[] args) throws IOException, FilloException {
WebDriver driver = null;
List<String> browsers = new ArrayList<String>();
browsers.add("chrome");
System.setProperty("webdriver.chrome.driver",
"src/main/resources/chromedriver.exe");
AActionKeyword actKeyword = new OpenBrowser();
ACommand command = new NewBrowser(actKeyword);
BrowserInvoker invoker = new BrowserInvoker(command);
driver = invoker.open(browsers);

}
}
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.222.196.175