Собственно базовый класс:
package HotelsWithMe;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import com.thoughtworks.selenium.*;
public class BaseTestClass extends SecurityManager {
protected Selenium selenium = null;
protected String delay = "";
@BeforeMethod(alwaysRun=true)
public void init() throws Exception {
delay = Config.getProperty( "delay" );
selenium = new DefaultSelenium( Config.getProperty( "host" ) , new Integer( Config.getProperty( "port" ) ) , Config.getProperty( "browser" ) , Config.getProperty( "url" ) );
selenium.start();
}
}
@AfterMethod(lastTimeOnly=true)
public void stop() throws Exception {
selenium.stop();
}
}
А это класс с тестом:
package HotelsWithMe;
import HotelsWithMe.Pages.facebookPage;
import com.thoughtworks.selenium.*;
import org.testng.annotations.*;
import static org.testng.Assert.*;
import java.util.regex.Pattern;
import org.testng.Assert;
import org.testng.annotations.Test;
public class Test1LondonSearching extends BaseTestClass {
private Selenium selenium=null;
public void LogIn() //Метод Логин пришлось поместить сюда, но по задумке все методы хочу вынести в базовый класс
{
selenium.open("http://www.facebook.com/HotelsWithMe?app_data=dev=true");
selenium.waitForPageToLoad("30000");
selenium.type("//input[@id='email']", "stesterov@gmail.com");
selenium.type("//input[@id='pass']", "123");
selenium.click("//label[@id='loginbutton']");
selenium.waitForPageToLoad("50000");
selenium.waitForCondition("selenium.isElementPresent(\"link=New trip\")","30000");
}
@Test
public void test1LondonSearching() throws Exception {
NewTrip();
SmplSearching("New York, NY, USA");
assertTrue(selenium.isElementPresent("//div[b=\"New York, NY, USA\"]"));
}
}