1
package user;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.testng.annotations.Test;
import org.testng.annotations.BeforeTest;
public class Login {
public WebDriver driver;
@Test
public void Signin() throws Exception {
driver.manage().window().maximize();
Thread.sleep(5000);
driver.navigate().refresh();
driver.findElement(By.xpath("//div[@id='header']/div/div/ul/li[6]/a")).click();
driver.findElement(By.id("Email")).sendKeys("[email protected]");
driver.findElement(By.id("password")).sendKeys("123456");
driver.findElement(By.xpath("//tr[5]/td[2]/input")).click();
Thread.sleep(5000);
}
@BeforeTest
public void BeforeTest() {
System.setProperty("webdriver.chrome.driver", "D:\\lib\\chromedriver.exe");
driver = new ChromeDriver();
driver.get("http://test.com/");
}
package user;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.testng.annotations.Test;
public class Addtocart extends Login {
public WebDriver driver;
@Test
public void Cart() throws Exception {
Thread.sleep(5000);
driver.findElement(By.xpath("//div[2]/div/div/a")).click();
driver.findElement(By.xpath("//a[contains(@href, '/Catalog/Featured')]")).click();
driver.findElement(By.id("//div[4]/div/a/img")).click();
driver.findElement(By.id("anchorAddToWishList")).click();*/
}
public static void main(String[] args) throws Exception{
Addtocart ac = new Addtocart();
ac.BeforeMethod();
ac.Signin();
ac.Cart();
}
}
当我尝试先调用父类的方法。子类方法首先调用。如何调用父类方法最初
在testng.xml文件包括这个<套件名称=“测试套件”平行=“假”保留阶=“真”> \t <测试名称= “回归测试套件”> \t \t \t \t \t <类名= “登录”/> \t \t \t <类名= “AddtoCart”/> \t \t \t –
SanjayDVG