Modular Framework:
The all the separated functions
are shown below along with Package name and Class name
Package name: com.Google.Common
Class name: BaseTest.Java This class
will initialize the firefox driver
package com.Google.Common;
import
java.util.concurrent.TimeUnit;
import
org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import
org.testng.annotations.AfterSuite;
import
org.testng.annotations.BeforeSuite;
public class BaseTest {
public static WebDriver driver;
@BeforeSuite
public void setUp() throws Exception {
driver = new FirefoxDriver();
driver.manage().window().maximize();
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
}
@AfterSuite
public void tearDown() throws Exception {
driver.quit();
}
}
Package name: com.Google.Common
Class name: SignOut.Java The logout
functionality is sepearted so that it can be used at any time from any screen
of application.
package com.Google.Common;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
public class SignOut {
public
void LoginToApp(WebDriver driver)
{
driver.findElement(By.xpath("//a[contains(@href,
'https://plus.google.com/u/0/me?tab=wX')]")).click();
driver.findElement(By.id("gb_71")).click();
}
}
The above two methods are the
examples for the modular driven framework. Think which part of the
functionality has chances to repeat again and again and divide the
functionalities in to small chunks which can be called later point of time
where ever required as shown above.
Note: Login functionality is also
created as separate functionality but the script is added under Data driven
because at this point of time understanding login script is little bit
confusion.
This comment has been removed by the author.
ReplyDelete