package Assignments;
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;
public class FlipKartMouseOver {
public static void main(String[] args) throws InterruptedException {
WebDriver driver = new FirefoxDriver();
driver.get("http://flipkart.com");
String expRes = "Oxford English Mini Dictionary";
//Finding the respective tab
WebElement wbele = driver.findElement(By.xpath("//span[contains(text(),'Books & Media')]"));
//creating an object for actions class
Actions act = new Actions(driver);
act.moveToElement(wbele).perform();
//navigating to entrance exam section
driver.findElement(By.xpath("//a[contains(text(),'Entrance Exam')]")).click();
Thread.sleep(4000);
//finding a book with name "oxford eng mini dic"
driver.findElement(By.xpath("//a[contains(text(),'Oxford English Mini Dictionary (English) 7th Edition')]")).click();
//adding the book to cart
driver.findElement(By.xpath("//div[@class='shop-section']/div/div/div/div/div/div/form/input[@value='Add to Cart']")).click();
Thread.sleep(4000);
//navigating to cart to verify the book is added or not
driver.findElement(By.xpath("//span[contains(text(),'Cart')]")).click();
Thread.sleep(4000);
String actRes = driver.findElement(By.xpath("//span[contains(text(),'Oxford English Mini Dictionary (English) 7th')]")).getText();
if(actRes.contains(expRes))
{
System.out.println("Test case ---- PASS!!");
}
else
{
System.out.println("Test case ---- FAIL");
}
}
}
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;
public class FlipKartMouseOver {
public static void main(String[] args) throws InterruptedException {
WebDriver driver = new FirefoxDriver();
driver.get("http://flipkart.com");
String expRes = "Oxford English Mini Dictionary";
//Finding the respective tab
WebElement wbele = driver.findElement(By.xpath("//span[contains(text(),'Books & Media')]"));
//creating an object for actions class
Actions act = new Actions(driver);
act.moveToElement(wbele).perform();
//navigating to entrance exam section
driver.findElement(By.xpath("//a[contains(text(),'Entrance Exam')]")).click();
Thread.sleep(4000);
//finding a book with name "oxford eng mini dic"
driver.findElement(By.xpath("//a[contains(text(),'Oxford English Mini Dictionary (English) 7th Edition')]")).click();
//adding the book to cart
driver.findElement(By.xpath("//div[@class='shop-section']/div/div/div/div/div/div/form/input[@value='Add to Cart']")).click();
Thread.sleep(4000);
//navigating to cart to verify the book is added or not
driver.findElement(By.xpath("//span[contains(text(),'Cart')]")).click();
Thread.sleep(4000);
String actRes = driver.findElement(By.xpath("//span[contains(text(),'Oxford English Mini Dictionary (English) 7th')]")).getText();
if(actRes.contains(expRes))
{
System.out.println("Test case ---- PASS!!");
}
else
{
System.out.println("Test case ---- FAIL");
}
}
}
No comments:
Post a Comment