mercredi 16 novembre 2016

Second class of testing.xml doesn't execute

I have created 2 separate classes to test a webpage. But, unfortunately when I add them both to the testing.xml, only one of them execute and the other doesn't. The browsers open in parallel even after setting them to preserve-order="true" parallel="false" in the XML. I'm confused as to where I'm doing it wrong.

This is my XML file:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://ift.tt/19x2mI9">
<suite name="Suite" preserve-order="true" parallel="false">
  <test name="Test">
    <classes>
      <class name="TestServiceNow.loginOne"/>
      <class name="TestServiceNow.loginTwo"/>
    </classes>
  </test> <!-- Test -->
</suite> <!-- Suite -->

loginOne is as follows:

    package TestServiceNow;

import org.testng.annotations.Test;
import ServiceNow.login;

public class loginOne extends loginTest{
    @Test
    public void test_Login(){
    //Create Login Page object
    objLogin = new login(driver);
    //login to application
    objLogin.loginGurukula("admin", "admin");
    }
}

loginTwo is as follows:

import org.testng.annotations.Test;
import ServiceNow.login;
public class loginTwo extends loginTest{
    @Test
      public void test_Login_Fail(){
          //Create Login Page object
          objLogin = new login(driver);
          //login to application
          objLogin.loginGurukula("admin", "admin1");
    }
}

The base class is as follows:

public class loginTest {
    DesiredCapabilities capabilities = DesiredCapabilities.chrome();
    File file = new File("C:/Users/gattu_000/Documents/selenium-java-3.0.0-beta2/chromedriver_win32/chromedriver.exe");
    WebDriver driver = new ChromeDriver(capabilities);
    login objLogin;

    @BeforeSuite
    public void a() {
        System.out.println("Before suite called");
    }
    @BeforeTest
    public void setup(){
        capabilities.setCapability("marionette", true);
        System.setProperty("webdriver.chrome.driver", file.getAbsolutePath());
        driver.manage().timeouts().implicitlyWait(15, TimeUnit.SECONDS);
        System.out.println("Before test called");
        driver.get("http://localhost:8080/#/login");
    }

    @AfterTest
    public void close() {
        System.out.println("After test called");
        driver.close();
    }

    @AfterSuite
    public void b() {
        System.out.println("After suite called");
    }
}

Aucun commentaire:

Enregistrer un commentaire