Вы находитесь на странице: 1из 6

SCENARIO:

1) Login to ActiTime
2) Create a customer
3) Delete a Customer
4) Verify the deletion of the customer.
package pack_WD;
import java.util.List;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.Alert;
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;
public class AlertBoxActi
{
public static void main(String[] args) throws InterruptedException
{
WebDriver driver= new FirefoxDriver();
driver.get("http://anand-hp/login.do");
// Login to acti time
driver.findElement(By.name("username")).sendKeys("admin");
driver.findElement(By.name("pwd")).sendKeys("manager");
driver.findElement(By.xpath("//input[@type='submit']")).click();
Thread.sleep(2000);
// Navigate to projects & customers page
driver.findElement(By.linkText("Projects & Customers")).click();
Thread.sleep(2000);
// Create a new customer
driver.findElement(By.xpath("//input[@value='Add New Customer']")).click();
driver.findElement(By.xpath("//input[@name='name']")).sendKeys("TestCustomer");
driver.findElement(By.xpath("//input[@type='submit']")).click();
Thread.sleep(2000);
//driver.findElement(By.linkText("TestCustomer")).click();
// login to TestCustomer Page
Select sel= new Select(driver.findElement(By.xpath("//select[@name='recordsPerPage']")));
sel.selectByVisibleText("100");
driver.findElement(By.linkText("TestCustomer")).click();
Thread.sleep(2000);
// delete the TestCustomer
driver.findElement(By.xpath("//input[@value='Delete This Customer']")).click();
// pass the driver control to alert box
Alert alt=driver.switchTo().alert();
// click 'OK' on alert box
alt.accept();
// Verify the deletion
String expectedMsg="Customer has been successfully deleted.";
String actMsg=driver.findElement(By.xpath("//span[text()='Customer has been successfully deleted.']")).getText();
if(expectedMsg.equals(actMsg))
{
System.out.println("PASS");
}
else
{System.out.println("FAIL");
}
}
}




rctc assignment(touris&travel/Bharat Darshan/know more>>>>>read text)
package WebSel;
import java.util.Iterator;
import java.util.Set;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
public class Tourist {
public static void main(String[] args) {
WebDriver d=new FirefoxDriver();
//goto irctc
d.get("https://www.irctc.co.in/eticketing/loginHome.jsf");
d.manage().timeouts().implicitlyWait(20,TimeUnit.SECONDS);
//click on Tourist Train
d.findElement(By.linkText("Tourist Train")).click();
//capture the windows id from the set
Set<String> set= d.getWindowHandles();
Iterator<String> it=set.iterator();
String window1=it.next();
String wn2=it.next();
//pass the window id to active window.
d.switchTo().window(wn2);
// click on "Know More"of Bharat Darshan.
d.findElement(By.xpath("//span/h1[text()='Bharat Darshan']/following-sibling::a[@title='Know More']")).click();
d.manage().timeouts().implicitlyWait(20,TimeUnit.SECONDS);
//close previous window
d.close();
//capture the windows id from the set
Set<String> set1=d.getWindowHandles();
Iterator<String> it1=set1.iterator();
it1.next();
//pass the control to active window
d.switchTo().window(it1.next());
//capture the text
String text=d.findElement(By.xpath("//div[@class='txt']")).getText();
//close previous window
d.close();
System.out.println(text);
//go back to parent window
d.switchTo().window(window1);
//login to irctc
d.findElement(By.name("j_username")).sendKeys("Azam");
d.findElement(By.name("j_password")).sendKeys("siddique@123");
d.findElement(By.name("submit")).click();
//close the browser
d.quit();

}
}


Open Flipkart--> Goto Book&Music--> Preorder-->Print a Book Price--> Open the Book Page-->Add to Whitelist--> Goto
Facebook--> Goto Sign-up--> Create a Facebook Account..
Code:
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.interactions.Actions;
import org.openqa.selenium.support.ui.Select;
public class Flipkart {
public static void main(String[]args) throws InterruptedException
{
WebDriver driver= new FirefoxDriver();
driver.get("http://www.flipkart.com/");
Thread.sleep(2000);
WebElement fb= driver.findElement(By.xpath("//a[@data-tracking-id='books-media']"));
Actions act= new Actions(driver);
act.moveToElement(fb).perform();
Thread.sleep(1000);
//WebElement book= driver.findElement(By.xpath("//a[contains(text(),'Pre-order')]"));
driver.findElement(By.xpath("//a[@data-tracking-id='0_Pre-Orders']")).click();
Thread.sleep(1000);
WebElement rs = driver.findElement(By.xpath("//div[div[a[contains(text(),'Pale Communion (Music, Audio
CD)')]]]/div/div/div/span"));
String s= rs.getText();
System.out.println(s);
Thread.sleep(1000);
WebElement cs= driver.findElement(By.linkText("Pale Communion (Music, Audio CD)"));
act.moveToElement(cs).perform();
act.click().perform();
Thread.sleep(2000);
WebElement ws= driver.findElement(By.linkText("Add to WISHLIST"));
Thread.sleep(1000);
act.moveToElement(ws).perform();
act.click().perform();
WebElement ff=driver.findElement(By.xpath("//a[@class='fk-button-social fb']"));
act.moveToElement(ff).perform();;
act.click().perform();
Thread.sleep(2000);
driver.findElement(By.linkText("Sign up for Facebook")).click();
String fname="Flip";
String lname="Kart";
String mail="flipkart@gmail.com";
String pass="123456789";
driver.findElement(By.name("firstname")).sendKeys(fname);
driver.findElement(By.name("lastname")).sendKeys(lname);
driver.findElement(By.name("reg_email__")).sendKeys(mail);
driver.findElement(By.name("reg_email_confirmation__")).sendKeys(mail);
driver.findElement(By.name("reg_passwd__")).sendKeys(pass);
WebElement month= driver.findElement(By.id("month"));
Select mm=new Select(month);
mm.selectByVisibleText("Aug");
WebElement day= driver.findElement(By.id("day"));
Select dd =new Select(day);
dd.selectByVisibleText("11");
WebElement year= driver.findElement(By.id("year"));
Select yy =new Select(year);
yy.selectByVisibleText("1991");
driver.findElement(By.xpath("//input[@value='2']")).click();
driver.findElement(By.name("websubmit")).click();
Thread.sleep(1000);
driver.close();
}
}


Scenario: Login to actiTIME ,Create and Verify Customer and Project of same created customer and then Logout the
application----
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.By.ByXPath;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.support.ui.Select;
public class Createcustomer {
public static void main(String[] args) throws InterruptedException {
String username="admin";
String password="manager";
String customername="ICICI";
String Projectname="testing";
String Projectstatus="Active";
String CustStatus="Active";
WebDriver driver=new FirefoxDriver();
//Login actiTIME
driver.get("http://127.0.0.1/login.do");
driver.findElement(By.name("username")).sendKeys("admin");
driver.findElement(By.name("pwd")).sendKeys("manager");
driver.findElement(By.xpath("//input[@type='submit']")).click();
Thread.sleep(2000);
//Creating customer
driver.findElement(By.linkText("Projects & Customers")).click();
Thread.sleep(2000);
driver.findElement(By.xpath("//input[@value='Add New Customer']")).click();
Thread.sleep(2000);
driver.findElement(By.name("name")).sendKeys(customername);
driver.findElement(By.xpath("//input[@value='Create Customer']")).click();
//Verify customer
Thread.sleep(2000);
Select sel=new Select(driver.findElement(By.name("selectedCustomer")));
sel.selectByVisibleText(customername);
driver.findElement(By.xpath("//input[normalize-space(@value)='Show']")).click();
Thread.sleep(2000);
driver.findElement(By.linkText(customername)).click();
Thread.sleep(2000);
String xpath1="//td[contains(text(),'selected customer')]/following-sibling::td/span";
String actcust=driver.findElement(By.xpath(xpath1)).getText();
Thread.sleep(2000);
String xpath2="//td[contains(text(),'Customer status')]/following-sibling::td/span";
String actcuststatus=driver.findElement(By.xpath(xpath2)).getText();
if(customername.equals(actcust))
{
System.out.println("PASS");
}
else
{
System.out.println("FAIL");
}
if(CustStatus.equals(actcuststatus))
{
System.out.println(actcust+ " is Active");
}
else
{
System.out.println(actcust+ " is not Active");
}
//Creating project for same customer
Thread.sleep(2000);
driver.findElement(By.linkText("Projects & Customers")).click();
Thread.sleep(2000);
driver.findElement(By.linkText("add project")).click();
Thread.sleep(2000);
Select sel1=new Select(driver.findElement(By.name("customerId")));
sel1.selectByVisibleText(customername);
driver.findElement(By.xpath("//td[contains(text(),'Project Name')]/following-sibling::td/input")).sendKeys(Projectname);;
driver.findElement(By.name("createProjectSubmit")).click();
Thread.sleep(2000);
//String xpath3="//tr[td[a[text()='ICICI']]]/following-sibling::tr[1]/td[1]/div/a[text()='Testing']";
//driver.findElement(By.xpath(xpath3)).click();
driver.findElement(By.linkText("testing")).click();
//Verifying Customer
Thread.sleep(2000);
String xpath3="//td[contains(text(),'selected project:')]/following-sibling::td/span";
String actproject=driver.findElement(By.xpath(xpath3)).getText();
String xpath4="//td[contains(text(),'Project status:')]/following-sibling::td/span";
String actprojectstatus=driver.findElement(By.xpath(xpath4)).getText();
if(Projectname.equals(actproject))
{
System.out.println("PASS");
}
else
{
System.out.println("FAIL");
}
if(Projectstatus.equals(actprojectstatus))
{
System.out.println(actprojectstatus+ " is Active");
}
else
{
System.out.println(actprojectstatus+ " is not Active");
}
//Logged out the application
Thread.sleep(2000);
driver.findElement(By.className("logoutImg")).click();
}
}

Вам также может понравиться