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