Subversion Repositories SmartDukaan

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
8614 kshitij.so 1
package com;
2
import java.io.BufferedWriter;
3
import java.io.File;
4
import java.io.IOException;
5
 
6
import com.thoughtworks.selenium.*;
7
 
8
//import static com.unitedinternet.portal.selenium.utils.logging.LoggingAssert.assertEquals;
9
//import static com.unitedinternet.portal.selenium.utils.logging.LoggingAssert.assertTrue;
10
import org.testng.annotations.AfterClass;
11
import org.testng.annotations.BeforeClass;
12
import org.testng.annotations.Test;
13
//import org.openqa.selenium.server.SeleniumServer;
14
 
15
//import java.util.regex.Pattern;
16
 
17
public class Buyproductonshop2020_specialdeals extends SeleneseTestBase {
18
 
19
 
20
	String url = "";
21
	private Selenium selenium= null;
22
 
23
@BeforeClass
24
public void startBrowser() {
25
    selenium= new DefaultSelenium("localhost", 4444, "*firefox", "http://saholic:shop2020@shop2020.in:8080/");
26
	selenium.start();
27
	//selenium.open(url);
28
	selenium.windowMaximize();
29
}
30
 
31
 
32
 
33
	@Test(description="Special Deals")
34
	public void testBuyproductonprod() throws Exception {
35
		Thread.sleep(10000);
36
		selenium.setContext("Specialdeals");
37
		selenium.setTimeout("60000");
38
		selenium.open("/");
39
		//selenium.windowMaximize();
40
		//com.unitedinternet.portal.selenium.utils.logging.LoggingAssert.assertEquals("Page Title Mobile Phone Reviews and Best Deals in India | saholic.com not Found","Mobile Phone Reviews and Best Deals in India | saholic.com", selenium.getTitle(),selenium);
41
		assertEquals("Mobile Phone Reviews and Best Deals in India | shop2020.in", selenium.getTitle());
42
		assertTrue("Logo not present",selenium.isElementPresent("css=img[alt=\"Shop2020\"]"));
43
		assertTrue("Search all not found",selenium.isTextPresent("Search"));
44
		assertTrue("Element searchButton not found ",selenium.isElementPresent("id=searchButton"));
45
		assertEquals("BEST DEALS", selenium.getText("css=div.home-listing-common-header-text > span.left"));
46
		assertTrue("//div[@id='products']/div[2]/div/div/span not found",selenium.isElementPresent("//div[@id='products']/div[2]/div/div/span"));
47
 
48
		assertTrue("css=span.common-widget-top-bar-text-right not found",selenium.isElementPresent("css=span.common-widget-top-bar-text-right"));
49
		assertTrue("css=#browsehistory > div.common-widget-top-bar > div.common-widget-top-bar-text > span.common-widget-top-bar-text-right not found",selenium.isElementPresent("css=#browsehistory > div.common-widget-top-bar > div.common-widget-top-bar-text > span.common-widget-top-bar-text-right"));
50
		System.out.println(selenium.getText("//div[@id='products']/div[3]/div/div/span"));
51
		assertTrue("BEST SELLERS not found",selenium.isTextPresent("BEST SELLERS") );
52
		assertTrue("LATEST ARRIVALS not found",selenium.isTextPresent("LATEST ARRIVALS") );
53
		assertTrue("css=div.home-listing-common-content.best-sellers not found",selenium.isElementPresent("css=div.home-listing-common-content.best-sellers"));
54
		assertTrue("css=div.home-listing-common-content.latest-arrivals not found",selenium.isElementPresent("css=div.home-listing-common-content.latest-arrivals"));
55
		assertTrue("css=div.home-listing-common-content.best-deals not found",selenium.isElementPresent("css=div.home-listing-common-content.best-deals"));
56
		Thread.sleep(16000);
57
		selenium.click("link=Special Deals");
58
		selenium.waitForPageToLoad("60000");
59
		Thread.sleep(30000);
60
		//com.unitedinternet.portal.selenium.utils.logging.LoggingAssert.assertEquals("Best Mobile Phone Deals | saholic.com not Found","Best Mobile Phone Deals | saholic.com", selenium.getTitle(),selenium);
61
		assertEquals("Best Mobile Phone Deals | shop2020.in", selenium.getTitle());
62
 
63
		//assertTrue("css=div.cart-middle not found",selenium.isElementPresent("css=div.cart-middle"));
64
 
65
        assertTrue("css=div.common-widget-top-bar-text not found",selenium.isElementPresent("css=div.common-widget-top-bar-text"));
66
        assertTrue("css=#browsehistory > div.common-widget-top-bar > div.common-widget-top-bar-text > span.common-widget-top-bar-text-right not found",selenium.isElementPresent("css=#browsehistory > div.common-widget-top-bar > div.common-widget-top-bar-text > span.common-widget-top-bar-text-right"));
67
        //verifyTrue(selenium.isElementPresent(""));
68
        for(int i=1;i<15;i++)
69
		{
70
			System.out.println("abc"+i+"");
71
			selenium.isElementPresent("dom=document.images["+i+"]");
72
			System.out.println("dom=document.images["+i+"]");
73
			assertTrue("Not able to buy Product",selenium.isElementPresent("dom=document.images["+i+"]"));
74
		selenium.click("dom=document.images["+i+"]");
75
		Thread.sleep(30000);
76
		selenium.waitForPageToLoad("60000");
77
		Thread.sleep(8000);
78
		assertTrue("Product detail element not found",selenium.isElementPresent("id=productDetail"));
79
		//selenium.captureScreenshot(screenshotresultPath+"/"+"ErrorPage"+".png");
80
		//com.unitedinternet.portal.selenium.utils.logging.LoggingAssert.assertTrue("Failed assert",selenium.isElementPresent("id=productDetail"),selenium);
81
		//com.unitedinternet.portal.selenium.utils.logging.LoggingAssert.assertTrue("Cart Summary not displayed",selenium.isElementPresent("css=div.cart"),selenium);
82
 
83
		//assertTrue("Cart Summary not displayed",selenium.isElementPresent("css=div.cart-top"));
84
		//verifyTrue(selenium.isElementPresent("css=#accessories > div.common-widget-top-bar > div.common-widget-top-bar-text"));
85
		assertTrue("Add to card button not present",selenium.isElementPresent("id=addToCart"));
86
 
87
		assertTrue("css=div.common-widget-top-bar-text not found",selenium.isElementPresent("css=div.common-widget-top-bar-text"));
88
		assertTrue("css=#myresearch > div.common-widget-top-bar > div.common-widget-top-bar-text not found",selenium.isElementPresent("css=#myresearch > div.common-widget-top-bar > div.common-widget-top-bar-text"));
89
		assertTrue("css=#browsehistory > div.common-widget-top-bar > div.common-widget-top-bar-text > span.common-widget-top-bar-text-right not found",selenium.isElementPresent("css=#browsehistory > div.common-widget-top-bar > div.common-widget-top-bar-text > span.common-widget-top-bar-text-right"));
90
       // assertTrue("id=Image1 not found",selenium.isElementPresent("id=Image1"));
91
		verifyEquals("Look n Feel", selenium.getText("//ul[@id='sideNav']/li[2]/a/span"));
92
		verifyEquals("Introduction", selenium.getText("css=a.vt > span"));
93
		assertTrue(selenium.isElementPresent("css=span.common-widget-top-bar-text-right"));
94
		selenium.setTimeout("60000");
95
		selenium.click("id=addToCart");
96
		Thread.sleep(30000);
97
		if(selenium.isVisible("id=cboxWrapper"))
98
		{
99
			selenium.goBack();
100
			Thread.sleep(15000);
101
			//selenium.click("link=HOME");
102
			continue;
103
		}
104
		break;
105
		}
106
        System.out.println("<----CART PAGE SPECIAL_DEALS THREAD---->");
107
        assertTrue("cartFlowHeader not found",selenium.isElementPresent("id=cartFlowHeader"));
108
		assertTrue("Cart details not found",selenium.isTextPresent("Cart Details"));
109
		assertTrue("Shipping Info. not found",selenium.isTextPresent("Shipping Info."));
110
		assertTrue("Make Payment not found",selenium.isTextPresent("Make Payment"));
111
		assertTrue("Order Status not found",selenium.isTextPresent("Order Status"));
112
		assertTrue("id=zipcode not found",selenium.isElementPresent("id=zipcode"));
113
		assertTrue("id=computeEstimate not found",selenium.isElementPresent("id=computeEstimate"));
114
		verifyEquals("Total Amount:", selenium.getText("css=tr.total-amount.payable > td.label"));
115
		Thread.sleep(6000);
116
		Thread.sleep(10000);
117
		assertEquals("ENTER SHIPPING INFO >",selenium.getText("id=poplogin"));
118
		selenium.click("id=poplogin");
119
		Thread.sleep(15000);
120
		selenium.type("id=loginEmail", "kshitijsood@ymail.com");
121
		selenium.type("id=loginPassword", "123abc");
122
		selenium.click("id=submitAddress");
123
		Thread.sleep(30000);
124
		 System.out.println("<----SHIPPING PAGE SPECIAL_DEALS THREAD---->");
125
		assertEquals("Item & Color", selenium.getText("css=th.first"));
126
		assertEquals("Delivery Time", selenium.getText("//table[@id='cartDetail']/thead/tr/th[2]"));
127
		assertEquals("Total Price", selenium.getText("//table[@id='cartDetail']/thead/tr/th[3]"));
128
		assertTrue("Select Shipping Address not found",selenium.isTextPresent("Select Shipping Address"));
129
		Thread.sleep(5000);
130
		//com.unitedinternet.portal.selenium.utils.logging.LoggingAssert.assertEquals("Proceed to payment button not present","PROCEED TO PAYMENT >", selenium.getText("id=proceedToPay"),selenium);
131
		assertEquals("PROCEED TO PAYMENT >", selenium.getText("id=proceedToPay"));
132
		selenium.click("id=proceedToPay");
133
		Thread.sleep(30000);
134
		 System.out.println("<----PROCEED TO PAY PAGE SPECIAL_DEALS THREAD---->");
135
		assertTrue("cartFlowHeader not found",selenium.isElementPresent("id=cartFlowHeader"));
136
		assertTrue("Cart details not found",selenium.isTextPresent("Cart Details"));
137
		assertTrue("Shipping Info. not found",selenium.isTextPresent("Shipping Info."));
138
		assertTrue("Make Payment not found",selenium.isTextPresent("Make Payment"));
139
		assertTrue("Order Status not found",selenium.isTextPresent("Order Status"));
140
		assertEquals("Order Amount:", selenium.getText("css=h4 > span"));
141
		String htmlstr = selenium.getBodyText();
142
    	int pos = htmlstr.indexOf("Order Amount:");
143
    	//System.out.println("Index is " + pos);
144
    	int pos1=pos+16;
145
    	int pos2=pos+28;
146
    	String amount;
147
    	amount = htmlstr.substring(pos1, pos2);
148
    	//System.out.println("pos1 pos2" + pos1 + ":" + pos2);
149
    	//int price=Integer.parseInt(amount);
150
    	//System.out.println("Amount : :" + amount + ":" + price );
151
    	amount=amount.replaceAll(",", "");
152
    	System.out.println("Amount : :" + amount);
153
    	///double price = Integer.parseInt(amount);
154
    	double price = Double.parseDouble(amount);
155
    	System.out.println("Price : :" + price);
156
    	assertTrue("CREDIT CARDS not found",selenium.isTextPresent("CREDIT CARDS"));
157
		assertTrue("EMI not found",selenium.isTextPresent("EMI"));
158
		assertTrue("DEBIT/ATM CARDS not found",selenium.isTextPresent("DEBIT/ATM CARDS"));
159
		assertTrue("NET BANKING not found",selenium.isTextPresent("NET BANKING"));
160
		assertTrue("CASH CARDS not found",selenium.isTextPresent("CASH CARDS"));
161
		assertTrue("css=input.make-payment-button not found",selenium.isElementPresent("css=input.make-payment-button"));
162
		if((price > 300) && (price < 20000))
163
		{
164
		assertTrue("CASH ON DELIVERY not found",selenium.isTextPresent("CASH ON DELIVERY"));	
165
		selenium.click("//div[@id='vtab']/ul/li[6]");
166
		assertTrue("id=captcha_response_box not found",selenium.isElementPresent("id=captcha_response_box"));
167
		assertTrue("id=captchaImage not found",selenium.isElementPresent("id=captchaImage"));
168
		assertTrue(selenium.isElementPresent("css=div.text-center > input.make-payment-button"));
169
		}
170
		selenium.deleteAllVisibleCookies();
171
	}
172
	@AfterClass
173
	public void clear() {
174
		selenium.selectWindow(selenium.getTitle());
175
		selenium.captureScreenshot("specialdeals_shop2020.png");
176
		selenium.stop();
177
	}	
178
	}