虽然我可以运行此测试用例,但它将跳过一些测试用例,然后再次返回以运行该测试用例。
在该代码中也可以看到,首先它将运行forgotsubdomine(),然后运行subdomine(),并将其重定向到Login(),然后返回到deskapp()的测试用例。我不优先执行该测试用例。
package WebApplication;
import java.io.IOException;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.Select;
import org.openqa.selenium.support.ui.WebDriverWait;
import org.testng.annotations.AfterTest;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;
import CommonDetails.Driverselectiondetails;
public class TimeClockWizard extends Driverselectiondetails {
public WebDriver driver;
// Driver installation
@BeforeTest
public void insatllation() throws IOException, InterruptedException {
driver = drivernavigation();
}
// Forgotsubdominepage
@Test
public void Forgotsubdomine() throws InterruptedException {
driver.get("https://apps.timeclockwizard.com");
Forgotsubdomine bsd = new Forgotsubdomine(driver);
bsd.getlink().click();
System.out.println("forgotsubdominepage:" + driver.getTitle());
bsd.getforgotlink().sendKeys("tbs.shailesh@gmail.com");
bsd.getsendmail().click();
WebDriverWait wait = new WebDriverWait(driver, 5000);
wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("txtSubDomain")));
// bsd.getbackbutton().click();
}
// Subdominehomepage and forgot password page
@Test
public void Subdominepage() throws InterruptedException {
Subdominepage sp = new Subdominepage(driver);
sp.getsubname().sendKeys("technobrains");
sp.getbutton().click();
WebDriverWait wait = new WebDriverWait(driver, 15);
wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("aForgotPassword")));
Forpassword fp = new Forpassword(driver);
fp.getforgotpasswordlink().click();
fp.gteenteremail().sendKeys("tbs.shailesh@gmail.com");
fp.getresetpasswordbutton().click();
Thread.sleep(5000);
driver.navigate().back();
wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("btnSelfRegister")));
}
// selfregistration page
@Test
public void slefregistartion() {
SelfRegistration sr = new SelfRegistration(driver);
sr.getselfregilink().click();
sr.getenterpin().sendKeys("1234");
sr.getdonebutton().click();
WebDriverWait wait = new WebDriverWait(driver, 50);
wait.until(ExpectedConditions.visibilityOfElementLocated(
By.cssSelector("#modelSelfRegistration > div > div > div.modal-header.border_none > h4")));
System.out.println(sr.gettiltelofpage().getText());
sr.getfullname().sendKeys("prsanthkumar");
sr.getemail().sendKeys("tbs.prasanth@gmail.com");
sr.getusername().sendKeys("prasanth421");
sr.getpassword().sendKeys("tbs@67789");
sr.getconformpassword().sendKeys("tbs@67789");
sr.getdateofbirth().sendKeys("12122010");
sr.getaddress().sendKeys("India");
Select dropcon = new Select(driver.findElement(By.id("ddlCountry")));
dropcon.selectByVisibleText("India");
sr.getcity().sendKeys("India");
sr.getstate().sendKeys("india");
sr.getzip().sendKeys("12345");
sr.gethomephone().sendKeys("7382978410");
sr.getworkphone().sendKeys("1234567891");
sr.getemergencycontactname().sendKeys("prasanth");
sr.getemergencycontactnumber().sendKeys("7896541232");
sr.getcellphone().sendKeys("7896541230");
sr.getworkextension().sendKeys("2222222");
Select droptime = new Select(driver.findElement(By.id("ddlTimeZone")));
droptime.selectByIndex(5);
sr.getcapche().click();
sr.getaddbutton().click();
}
//For desktop app links
public void Desktoplink() throws InterruptedException
{
Desktopapplications dp = new Desktopapplications();
dp.getwindowsapp().click();
Thread.sleep(2000);
dp.getIOSapp();
}
// Login deatisl page
@Test
public void login()
{
LoginPage lp = new LoginPage(driver);
lp.getusername().sendKeys("ravi");
lp.getpassword().sendKeys("tbs@67789");
lp.getloginbutton().click();
}
// Closing the driver
@AfterTest
public void closingdriver() {
driver.close();
}
}
答案 0 :(得分:0)
尝试为@Test设置优先级。例如。您首先要执行的测试使用@Test(priority = 0),以此类推。