Subversion Repositories SmartDukaan

Rev

Details | Last modification | View Log | RSS feed

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