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