package info.v2solutions.testcases;
import java.util.StringTokenizer;
import java.util.concurrent.TimeUnit;
import junit.framework.Assert;
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.firefox.FirefoxDriver;
//import org.openqa.selenium.firefox.FirefoxProfile;
import org.openqa.selenium.ie.InternetExplorerDriver;
import org.openqa.selenium.interactions.Action;
import org.openqa.selenium.interactions.Actions;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;
public class Test_Price {
WebDriver driver;
@BeforeTest
public void start(){
;
driver = new FirefoxDriver();
}
@Test
public void start1(){
driver.get("http://www.moss.com/");
driver.manage().timeouts().implicitlyWait(100, TimeUnit.SECONDS);
driver.findElement(By.xpath("//*[@id='sideNavContainer']/ul/li[1]/a")).click();
String s=driver.findElement(By.xpath("//*[@id='ContentPlaceHolder1_MyList_RegularPriceHL_0']")).getText();
System.out.println(s);
driver.findElement(By.xpath("//*[@id='ContentPlaceHolder1_MyList_ThumbnailNameHL_0']")).click();
String firstprice=driver.findElement(By.xpath("//*[@id='UnitCostSpan']")).getText();
System.out.println(firstprice);
// Assert.assertEquals(firstprice,s);
if(firstprice.equals(s))
{
System.out.println("hiiiiiiii");
}
else{
System.out.println("fail");
}
driver.findElement(By.xpath("//*[@id='ContentPlaceHolder1_QuantityTB']")).sendKeys("5");
driver.findElement(By.xpath("//*[@id='sizel5747L']/a")).click();
driver.findElement(By.xpath("//*[@id='ContentPlaceHolder1_addToCartLbtn']")).click();
System.out.println("it moved to check out");
driver.findElement(By.xpath("//*[@id='ContentPlaceHolder1_GoToCheckoutLB']")).click();
String value = driver.findElement(By.xpath("//*[@id='ContentPlaceHolder1_cart_details_rpt_item_qty_0']")).getAttribute("value");
System.out.println(value);
System.out.println("helooooooo");
System.out.println(driver.findElement(By.xpath("//*[@id='ContentPlaceHolder1_cart_details_rpt_each_amt_0']")).getText());
String ss=driver.findElement(By.xpath("//*[@id='ContentPlaceHolder1_cart_details_rpt_each_amt_0']")).getText();
String s12 = ss.replaceAll("[$,]", "");
System.out.println(s12 + " in s12 " );
int v = Integer.parseInt(value);
float priceperitem = Float.parseFloat(s12);
String total =driver.findElement(By.xpath("//*[@id='ContentPlaceHolder1_cart_details_rpt_ext_amt_0']")).getText();
String ts = total.replaceAll("[$,]", "");
System.out.println(ts + " in ts " );
float actualTotalPrice = Float.parseFloat(ts);
float expectedTotal = v * priceperitem ;
if (actualTotalPrice == expectedTotal){
System.out.println("ffffffff");
}
//String[] arr;
/*for (int i=0; i<1;i++){
///n/String[] arrv= ss.split("$");
arr[i]=ss.split("2");
}*/
// String[] arrv= ss.split("2");
// StringTokenizer arrv = new StringTokenizer(ss.substring(1));
/* String s1s=ss.substring(1);
System.out.println(s1s);
float i= Float.parseFloat(s1s);
int v = Integer.parseInt(value);
System.out.println("after parsing value of i is " + i);
System.out.println("after parsing value of v is " + v);
float m;
m = v * i;
System.out.println("m is " + m);
String total =driver.findElement(By.xpath("//*[@id='ContentPlaceHolder1_cart_details_rpt_ext_amt_0']")).getText();
System.out.println(total + "tottttlll");
String sub = total.substring(1);
System.out.println(sub + " sub is jjjj");
String a = sub.replaceAll(",", "");
System.out.println(sub + "after replace");
System.out.println(a + "a value ");
float subt = Float.parseFloat(a);
System.out.println("aftervpares "+ subt);
if (m == subt){
System.out.println("sub total matched : " + m+ " and subt is " + subt);
}
*/
}
}
import java.util.StringTokenizer;
import java.util.concurrent.TimeUnit;
import junit.framework.Assert;
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.firefox.FirefoxDriver;
//import org.openqa.selenium.firefox.FirefoxProfile;
import org.openqa.selenium.ie.InternetExplorerDriver;
import org.openqa.selenium.interactions.Action;
import org.openqa.selenium.interactions.Actions;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;
public class Test_Price {
WebDriver driver;
@BeforeTest
public void start(){
;
driver = new FirefoxDriver();
}
@Test
public void start1(){
driver.get("http://www.moss.com/");
driver.manage().timeouts().implicitlyWait(100, TimeUnit.SECONDS);
driver.findElement(By.xpath("//*[@id='sideNavContainer']/ul/li[1]/a")).click();
String s=driver.findElement(By.xpath("//*[@id='ContentPlaceHolder1_MyList_RegularPriceHL_0']")).getText();
System.out.println(s);
driver.findElement(By.xpath("//*[@id='ContentPlaceHolder1_MyList_ThumbnailNameHL_0']")).click();
String firstprice=driver.findElement(By.xpath("//*[@id='UnitCostSpan']")).getText();
System.out.println(firstprice);
// Assert.assertEquals(firstprice,s);
if(firstprice.equals(s))
{
System.out.println("hiiiiiiii");
}
else{
System.out.println("fail");
}
driver.findElement(By.xpath("//*[@id='ContentPlaceHolder1_QuantityTB']")).sendKeys("5");
driver.findElement(By.xpath("//*[@id='sizel5747L']/a")).click();
driver.findElement(By.xpath("//*[@id='ContentPlaceHolder1_addToCartLbtn']")).click();
System.out.println("it moved to check out");
driver.findElement(By.xpath("//*[@id='ContentPlaceHolder1_GoToCheckoutLB']")).click();
String value = driver.findElement(By.xpath("//*[@id='ContentPlaceHolder1_cart_details_rpt_item_qty_0']")).getAttribute("value");
System.out.println(value);
System.out.println("helooooooo");
System.out.println(driver.findElement(By.xpath("//*[@id='ContentPlaceHolder1_cart_details_rpt_each_amt_0']")).getText());
String ss=driver.findElement(By.xpath("//*[@id='ContentPlaceHolder1_cart_details_rpt_each_amt_0']")).getText();
String s12 = ss.replaceAll("[$,]", "");
System.out.println(s12 + " in s12 " );
int v = Integer.parseInt(value);
float priceperitem = Float.parseFloat(s12);
String total =driver.findElement(By.xpath("//*[@id='ContentPlaceHolder1_cart_details_rpt_ext_amt_0']")).getText();
String ts = total.replaceAll("[$,]", "");
System.out.println(ts + " in ts " );
float actualTotalPrice = Float.parseFloat(ts);
float expectedTotal = v * priceperitem ;
if (actualTotalPrice == expectedTotal){
System.out.println("ffffffff");
}
//String[] arr;
/*for (int i=0; i<1;i++){
///n/String[] arrv= ss.split("$");
arr[i]=ss.split("2");
}*/
// String[] arrv= ss.split("2");
// StringTokenizer arrv = new StringTokenizer(ss.substring(1));
/* String s1s=ss.substring(1);
System.out.println(s1s);
float i= Float.parseFloat(s1s);
int v = Integer.parseInt(value);
System.out.println("after parsing value of i is " + i);
System.out.println("after parsing value of v is " + v);
float m;
m = v * i;
System.out.println("m is " + m);
String total =driver.findElement(By.xpath("//*[@id='ContentPlaceHolder1_cart_details_rpt_ext_amt_0']")).getText();
System.out.println(total + "tottttlll");
String sub = total.substring(1);
System.out.println(sub + " sub is jjjj");
String a = sub.replaceAll(",", "");
System.out.println(sub + "after replace");
System.out.println(a + "a value ");
float subt = Float.parseFloat(a);
System.out.println("aftervpares "+ subt);
if (m == subt){
System.out.println("sub total matched : " + m+ " and subt is " + subt);
}
*/
}
}
No comments:
Post a Comment