I have the following test suite to run an automation script to login to gmail then another script to click the Compose button:
TestSuite.xml
<!DOCTYPE suite SYSTEM "http://ift.tt/19x2mI9">
<suite name="Web Admin Tests" parallel="false">
<test name="BOS - Account Class">
<classes>
<class name="secondtestngpackage.GmailComposeEmail" />
<class name="secondtestngpackage.GmailLogin" />
</classes>
</test>
</suite>
When I run this test suite, the first test does not get passed the login screen in gmail, but the second test does, even though they reference the same functions. Is there a reason why this would happen? One test is able to enter the user id and password, since it is the second/last test, but when the first test is run, it is like the second test interferes with it, since its browser is now in focus.
GmailLogin.java:
@BeforeTest
public void launchBrowser() {
ReuseFunctions.OpenApp("Chrome", "https://gmail.com");
}
//Test 1: Log into Gmail
@Test(priority=1)
public void LoginToGmailAccount() {
**GmailComposeEmail.java**
@BeforeTest
public void launchBrowser() {
ReuseFunctions.OpenApp("Chrome", "https://gmail.com");
}
@Test(priority=2)
public void LoginToGmailAccount() {
Reusable Functions File:
ReuseFunctions.func_EnterCredentials("username", "password");
public class ReuseFunctions {
public static WebDriver driver;
/*Function 1: Select Browser and Open Application Function
*/
public static Object OpenApp (String Browser, String URL) {
//Receive Browser Name Function
Func_LaunchBrowser(Browser);
//Receive Website and Open Function
func_OpenURL(URL);
return driver;
}
//Select Browser
public static WebDriver Func_LaunchBrowser(String Browser) {
String driverPath = "C:/EclipseJavaDev/";
if(Browser=="Chrome"){
System.out.println("launching chrome browser");
System.setProperty("webdriver.chrome.driver", driverPath+"chromedriver.exe");
driver = new ChromeDriver();
}else if(Browser=="FF"){
driver= new FirefoxDriver();
}else if(Browser=="IE"){
System.setProperty("webdriver.ie.driver", "Drivers\\IEDriverServer.exe");
driver= new InternetExplorerDriver();
}
driver.manage().timeouts().implicitlyWait(80, TimeUnit.SECONDS);
return driver;
}
//Open URL
public static void func_OpenURL(String URL){
driver.get(URL);
driver.manage().window().maximize();
}
Aucun commentaire:
Enregistrer un commentaire