Tuesday, 22 September 2015

REAL TIME TESTNG FRAME WORK FOR SPICEJET USING SELENIUM





import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.testng.annotations.AfterClass;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
public class spicejet {



static WebDriver wd;
@BeforeClass
public void invoke()
{
wd = new FirefoxDriver();
System.out.println("invoke");
}
@AfterClass
public void close()
{
wd.close();
System.out.println("close");
}
@BeforeMethod
public void login() throws InterruptedException
{
            Thread.sleep(200l);
wd.get("http:spicejet.com");

wd.findElement(By.xpath(".//*[@id='ctl00_HyperLinkLogin']")).click();
wd.findElement(By.xpath(".//*[@id='smoothmenu1']/ul/li[9]/ul/li[3]/a")).click();
wd.findElement(By.xpath(".//*[@id='smoothmenu1']/ul/li[9]/ul/li[3]/ul/li[1]/a")).click();
wd.findElement(By.xpath(".//*[@id='ControlGroupLoginView_MemberLoginView2LoginView_TextBoxUserID']")).sendKeys("VAMSHI6699");
   wd.findElement(By.xpath(".//*[@id='ControlGroupLoginView_MemberLoginView2LoginView_PasswordFieldPassword']")).sendKeys("9177516699");
   wd.findElement(By.xpath(".//*[@id='ControlGroupLoginView_MemberLoginView2LoginView_ButtonLogIn']")).click();
Thread.sleep(5000l);

}
@AfterMethod
public void logout() throws InterruptedException
{
System.out.println("logout");
wd.findElement(By.xpath(".//*[@id='Login']")).click();
Thread.sleep(200l);
wd.findElement(By.xpath(".//*[@id='ControlGroupLoginView_MemberLoginView2LoginView_LinkButtonLogOut']")).click();
Thread.sleep(200l);
}
@Test
public void spiceadd() throws InterruptedException
{
Thread.sleep(3000l);
wd.findElement(By.xpath(".//*[@id='smoothmenu1']/ul/li[5]/a")).click();
wd.findElement(By.xpath(".//*[@id='smoothmenu1']/ul/li[5]/ul/li[4]/a")).click();
Thread.sleep(3000l);
wd.findElement(By.xpath(".//*[@id='ControlGroupRetrieveBookingView_BookingRetrieveInputRetrieveBookingView_ConfirmationNumber']")).sendKeys("007");
}
@Test
public void ticket() throws InterruptedException
{
wd.findElement(By.xpath(".//*[@id='AvailabilitySearchInputBookingListVieworiginStation1']")).sendKeys("Hyderabad(HYD)");
wd.findElement(By.xpath(".//*[@id='AvailabilitySearchInputBookingListViewdestinationStation1']")).sendKeys("Bengaluru(BLR)");
wd.findElement(By.xpath(".//*[@id='custom_date_picker_id_1']")).click();
wd.findElement(By.xpath(".//*[@id='marketDate_1']/button")).click();
wd.findElement(By.xpath(".//*[@id='ui-datepicker-div']/div[1]/table/tbody/tr[3]/td[5]/a")).click();
Thread.sleep(2000l);

}


}

SELENIUM TESTNG & SELENIUM WEBDRIVER TESTNG FRAME WORK WITH NORMAL,WEB APPLICATION EXAMPLE




No comments:

Post a Comment