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 java.io.BufferedWriter;
5
import java.io.File;
6
import java.io.IOException;
7
 
8
import com.thoughtworks.selenium.*;
9
import com.unitedinternet.portal.selenium.utils.logging.HtmlResultFormatter;
10
import com.unitedinternet.portal.selenium.utils.logging.LoggingCommandProcessor;
11
import com.unitedinternet.portal.selenium.utils.logging.LoggingDefaultSelenium;
12
import com.unitedinternet.portal.selenium.utils.logging.LoggingResultsFormatter;
13
import com.unitedinternet.portal.selenium.utils.logging.LoggingSelenium;
14
import com.unitedinternet.portal.selenium.utils.logging.LoggingUtils;
15
//import static com.unitedinternet.portal.selenium.utils.logging.LoggingAssert.assertEquals;
16
//import static com.unitedinternet.portal.selenium.utils.logging.LoggingAssert.assertTrue;
17
import org.junit.After;
18
import org.junit.Before;
19
import org.junit.Test;
20
//import org.openqa.selenium.server.SeleniumServer;
21
 
22
//import java.util.regex.Pattern;
23
 
24
public class Testdashboard extends SeleneseTestBase {
25
 
26
 
27
	BufferedWriter loggingWriter;
28
	protected LoggingSelenium selenium;
29
	final String resultbasePath = "/opt/seleniumTests/results/dashboard";
30
	//final String resultbasePath = "/opt/seleniumTests/results";
31
    final String resultHtmlFileName = resultbasePath + "/" + "resultdashboard.html";
32
    final String resultEncoding = "UTF-8";	    
33
    final String screenshotpath="screenshot";
34
    final String screenshotresultPath=new File(resultbasePath+"/"+screenshotpath).getAbsolutePath();
35
	@Before
36
	public void setUp() throws Exception {
37
		if (!new File(screenshotresultPath).exists()) {
38
			 new File(screenshotresultPath).mkdirs();
39
		}
40
	    loggingWriter = LoggingUtils.createWriter(resultHtmlFileName, resultEncoding , true);
41
	    LoggingResultsFormatter htmlFormatter = 
42
	        new HtmlResultFormatter(loggingWriter, resultEncoding);
43
	   htmlFormatter.setScreenShotBaseUri(resultbasePath+"/"+screenshotpath+"/"); // this is for linking to the screenshots
44
	   htmlFormatter.setAutomaticScreenshotPath(screenshotresultPath);
45
	    // wrap HttpCommandProcessor from remote-control
46
	    LoggingCommandProcessor myProcessor = 
47
	    new LoggingCommandProcessor(new HttpCommandProcessor("localhost", 4444, "*firefox", "http://saholic:shop2020@www.shop2020.in:8080"), htmlFormatter);
48
	    //new LoggingCommandProcessor(new HttpCommandProcessor("localhost", 4444, "*firefox", "http://saholic.com/"), htmlFormatter);
49
	    selenium = new LoggingDefaultSelenium(myProcessor);
50
	    myProcessor.setExcludedCommands(new String[] {});
51
	    selenium.start();	
52
	}
53
 
54
	@Test(expected=AssertionError.class)
55
	public void testdashboardorder() throws Exception {
56
		String Orderid="136748";
57
		selenium.setContext("testdashboardorder()");
58
		selenium.setTimeout("60000");
59
		selenium.open("/dashboard");
60
		selenium.windowMaximize();
61
		selenium.type("css=input.gwt-TextBox","ys5admin");
62
		selenium.type("css=input.gwt-PasswordTextBox","1grim@ce");
63
		selenium.click("css=button.gwt-Button");
64
		Thread.sleep(10000);
65
		selenium.click("link=Search");
66
		Thread.sleep(10000);
67
		selenium.type("css=input.gwt-TextBox",Orderid);
68
		selenium.click("css=button.gwt-Button");
69
		Thread.sleep(10000);
70
		if(!selenium.isTextPresent("Submitted to processing"))
71
		{
72
			selenium.isTextPresent("Submitted to warehouse");
73
		}
74
		Thread.sleep(5000);
75
		selenium.click("css=input[type='checkbox']");
76
		Thread.sleep(5000);
77
		selenium.click("css=button.gwt-Button");
78
		Thread.sleep(5000);
79
		selenium.isTextPresent("Order "+Orderid+" was accepted");
80
		Thread.sleep(20000);
81
		selenium.click("css=div.dialogMiddleCenterInner.dialogContent > button.gwt-Button");
82
		Thread.sleep(5000);
83
		selenium.click("id=gwt-uid-24");
84
		Thread.sleep(6000);
85
 
86
	}
87
	@After
88
	public void tearDown() throws Exception {
89
		selenium.stop();
90
        //stopSeleniumServer();
91
		try {
92
	        if (null != loggingWriter) {
93
	            loggingWriter.close();
94
	        }
95
	    } catch (IOException e) {
96
	      System.out.println("IO exception");
97
	    }
98
	}
99
}