Command 

The command, in our case, will be an abstract class that will have overloaded versions of the execute method. This has been done so that, if we want to create a concrete command class, we don't need to add code to all of the methods of the ACommand interface. The concrete command classes will have the AActionKeyword object, and there will be execute methods that are required for that particular operation. For example, if the operation is a click operation, then there will be just the usage of the no argument execute method.

Next comes the dummy class, ACommand, which has empty implementations.

The following code shows the ACommand abstract class:

public abstract class ACommand {
public void execute(String x) {
}
public void execute(WebDriver driver, String x) {
}
public void execute(WebElement element, String x) {
}
public WebDriver execute(List<String> x) {
return null;
}
public WebDriver execute() {
// TODO Auto-generated method stub
return null;
}
}

Finally, the following code shows the concrete class which creates a new browser session. In the next chapter, the no-argument execute method will be replaced by a single argument method, which includes the browser name:

public class NewBrowser extends ACommand {
private AActionKeyword actionKeyword = null;
static WebDriver driver;

public NewBrowser(AActionKeyword actKeyword) {
this.actionKeyword = actKeyword;
}

public WebDriver execute(List<String> browsers) {
driver = actionKeyword.openBrowser(browsers);
return driver;
}

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

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