我在這兩個類中創建了2個具有3個方法/測試的類。第一類和第三類方法/測試中的2個方法/測試在第二類中。但是,當我運行這些使用XML第一類運行測試和測試通過作爲方法/測試在第二課跳過。使用xml在Testng中運行2個類時跳過的第二個類中創建的方法
XML:
<?xml version="1.0" encoding="UTF-8"?>
<suite name= "Expedia Call Tracker">
<test name="Expedia Home Smoke Testcases">
<classes>
<class name="ExpediaCallTracker.Expedia"/>
<class name="ExpediaCallTracker.ExpediaCreateSale" />
</classes>
</test>
</suite>
First Class :
package ExpediaCallTracker;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.support.ui.Select;
import org.testng.annotations.Test;
public class Expedia {
public String e;
WebDriver expedia = new FirefoxDriver();
@Test(priority=1)
public void ExpediaLogin()
{
expedia.manage().window().maximize();
expedia.get("http://fedev.teleperformanceusa.com/Expedia/ExpediaCallTracker/Account/Login");
expedia.findElement(By.id("UserName")).sendKeys("kochhar.5");
expedia.findElement(By.id("Password")).sendKeys("Password11");
expedia.findElement(By.xpath(".//*[@id='loginForm']/form/fieldset/p/input")).click();
}
@Test(priority=2)
public void ExpediaDashSale()
{
expedia.findElement(By.linkText("Sale - HWW/EAN")).click();
}
}
Second Class :
package ExpediaCallTracker;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.ui.Select;
import org.testng.annotations.Optional;
import org.testng.annotations.Parameters;
import org.testng.annotations.Test;
public class ExpediaCreateSale {
private static final WebDriver d = null;
public ExpediaCreateSale()
{
}
WebDriver expedia = d;
@Test
public void ExpediaCreate(WebDriver d)
{
expedia.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
Select LineOfBusiness = new Select(expedia.findElement(By.id("lineOfBusiness")));
LineOfBusiness.selectByIndex(1);
expedia.findElement(By.id("sourceCode")).sendKeys("abcdefgh");
WebElement Upsell = expedia.findElement(By.xpath("html/body/div[1]/section[2]/form/fieldset/div[6]/input[1]"));
Upsell.click();
WebElement SaleCall =expedia.findElement(By.xpath("html/body/div[1]/section[2]/form/fieldset/div[8]/input[1]"));
SaleCall.click();
expedia.findElement(By.id("checkInDate")).sendKeys("09/14/2016");
Select numberOfNights = new Select(expedia.findElement(By.id("numberOfNights")));
numberOfNights.selectByIndex(1);
WebElement PaymentMethod = expedia.findElement(By.xpath("html/body/div[1]/section[2]/form/fieldset/div[9]/div[6]/input[1]"));
PaymentMethod.click();
Select currency = new Select(expedia.findElement(By.id("currency")));
currency.selectByIndex(70);
expedia.findElement(By.id("grossBooking")).sendKeys("123456");
expedia.findElement(By.id("itineraryNumber")).sendKeys("123456789");
expedia.findElement(By.id("remark")).sendKeys("Itinery number saved.");
expedia.findElement(By.xpath(".//*[@id='body']/section[2] /form/fieldset/p/input[1]")).click();
}
}
任何人都可以建議我應該嘗試做?
你可以分享你的'testng.xml' – Paras
<?XML版本= 「1.0」 編碼= 「UTF-8」?> <套件名稱= 「Expedia的呼叫跟蹤器」> <測試名稱=「Expedia的主頁抽菸測試用例 「> <類名=」 ExpediaCallTracker.Expedia 「/> <類名=」 ExpediaCallTracker.ExpediaCreateSale 「> <! - \t \t \t \t <包括名稱=」 ExpediaCreate」 /> \t \t \t \t \t \t \t \t \t \t \t \t \t <排除名稱= 「testMakeOrder」/> \t \t \t \t \t \t \t - > \t \t –
它看起來不錯,你可以編輯你的問題,並把兩個類的代碼。 – Paras