package Assignments;
import java.util.List;
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;
public class Assignment {
public static void main(String[] args) {
WebDriver driver=new FirefoxDriver();
String expected="sai";
driver.get("http://hunter/login.do");
driver.findElement(By.xpath("//input[@name='username']")).sendKeys("admin");
driver.findElement(By.xpath("//input[@name='pwd']")).sendKeys("manager");
driver.findElement(By.id("loginButton")).click();
driver.manage().timeouts().implicitlyWait(20,TimeUnit.SECONDS);
driver.findElement(By.xpath("//div[contains(text(),'Tasks')]")).click();
driver.findElement(By.xpath("//a[text()='Projects & Customers']")).click();
driver.manage().timeouts().implicitlyWait(20,TimeUnit.SECONDS);
driver.findElement(By.xpath("//input[@value='Create New Customer']")).click();
driver.findElement(By.xpath("//input[@name='name']")).sendKeys("sai");
driver.findElement(By.xpath("//input[@value='Create Customer']")).click();
driver.manage().timeouts().implicitlyWait(20,TimeUnit.SECONDS);
driver.findElement(By.xpath("//input[@value='Create New Project']")).click();
Select sel=new Select(driver.findElement(By.xpath("//select[@name='customerId']")));
List<WebElement> web=sel.getOptions();
for(int i=0;i<web.size();i++){
//String actual=web.get(i).getText();
if(web.get(i).getText().equals(expected)){
sel.selectByVisibleText(web.get(i).getText());
}
}
driver.findElement(By.xpath("//input[@name='name']")).sendKeys("tiger");
driver.findElement(By.xpath("//input[@value='Create Project']")).click();
driver.findElement(By.xpath("//td[table[tbody[tr[td[a[text()='tiger']]]]]]/following-sibling::td/a")).click();
driver.manage().timeouts().implicitlyWait(20,TimeUnit.SECONDS);
driver.findElement(By.xpath("//input[@name='task[0].name']")).sendKeys("manual testing on login");
driver.findElement(By.xpath("//input[@name='task[1].name']")).sendKeys("SQL testing");
driver.findElement(By.xpath("//input[@name='task[2].name']")).sendKeys("automation testing");
driver.findElement(By.xpath("//input[@value='Create Tasks']")).click();
driver.manage().timeouts().implicitlyWait(20,TimeUnit.SECONDS);
driver.findElement(By.xpath("//a[text()='Open Tasks']")).click();
driver.findElement(By.xpath("//td[@id='cpSelector.cpButton.contentsContainer']")).click();
driver.findElement(By.xpath("//label[span[text()='sai']]/preceding-sibling::input")).click();
driver.findElement(By.xpath("//input[@id='tasksFilterSubmitButton']")).click();
String very = driver.findElement(By.linkText("automation testing")).getText();
if(act.equals(very)
{
System.out.println("PASS!");
}else{
System.out.println("FAIL!");
}
driver.findElement(By.xpath("//a[text()='Logout']")).click();
driver.quit();
}
}
import java.util.List;
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;
public class Assignment {
public static void main(String[] args) {
WebDriver driver=new FirefoxDriver();
String expected="sai";
driver.get("http://hunter/login.do");
driver.findElement(By.xpath("//input[@name='username']")).sendKeys("admin");
driver.findElement(By.xpath("//input[@name='pwd']")).sendKeys("manager");
driver.findElement(By.id("loginButton")).click();
driver.manage().timeouts().implicitlyWait(20,TimeUnit.SECONDS);
driver.findElement(By.xpath("//div[contains(text(),'Tasks')]")).click();
driver.findElement(By.xpath("//a[text()='Projects & Customers']")).click();
driver.manage().timeouts().implicitlyWait(20,TimeUnit.SECONDS);
driver.findElement(By.xpath("//input[@value='Create New Customer']")).click();
driver.findElement(By.xpath("//input[@name='name']")).sendKeys("sai");
driver.findElement(By.xpath("//input[@value='Create Customer']")).click();
driver.manage().timeouts().implicitlyWait(20,TimeUnit.SECONDS);
driver.findElement(By.xpath("//input[@value='Create New Project']")).click();
Select sel=new Select(driver.findElement(By.xpath("//select[@name='customerId']")));
List<WebElement> web=sel.getOptions();
for(int i=0;i<web.size();i++){
//String actual=web.get(i).getText();
if(web.get(i).getText().equals(expected)){
sel.selectByVisibleText(web.get(i).getText());
}
}
driver.findElement(By.xpath("//input[@name='name']")).sendKeys("tiger");
driver.findElement(By.xpath("//input[@value='Create Project']")).click();
driver.findElement(By.xpath("//td[table[tbody[tr[td[a[text()='tiger']]]]]]/following-sibling::td/a")).click();
driver.manage().timeouts().implicitlyWait(20,TimeUnit.SECONDS);
driver.findElement(By.xpath("//input[@name='task[0].name']")).sendKeys("manual testing on login");
driver.findElement(By.xpath("//input[@name='task[1].name']")).sendKeys("SQL testing");
driver.findElement(By.xpath("//input[@name='task[2].name']")).sendKeys("automation testing");
driver.findElement(By.xpath("//input[@value='Create Tasks']")).click();
driver.manage().timeouts().implicitlyWait(20,TimeUnit.SECONDS);
driver.findElement(By.xpath("//a[text()='Open Tasks']")).click();
driver.findElement(By.xpath("//td[@id='cpSelector.cpButton.contentsContainer']")).click();
driver.findElement(By.xpath("//label[span[text()='sai']]/preceding-sibling::input")).click();
driver.findElement(By.xpath("//input[@id='tasksFilterSubmitButton']")).click();
String very = driver.findElement(By.linkText("automation testing")).getText();
if(act.equals(very)
{
System.out.println("PASS!");
}else{
System.out.println("FAIL!");
}
driver.findElement(By.xpath("//a[text()='Logout']")).click();
driver.quit();
}
}
Im trying for web application of actitime, but xpath or Task fields are identifiable.
ReplyDelete