Subversion Repositories SmartDukaan

Rev

Blame | Last modification | View Log | RSS feed

package com;


import java.io.BufferedWriter;
import java.io.File;
import java.io.IOException;

import com.thoughtworks.selenium.*;
import com.unitedinternet.portal.selenium.utils.logging.HtmlResultFormatter;
import com.unitedinternet.portal.selenium.utils.logging.LoggingCommandProcessor;
import com.unitedinternet.portal.selenium.utils.logging.LoggingDefaultSelenium;
import com.unitedinternet.portal.selenium.utils.logging.LoggingResultsFormatter;
import com.unitedinternet.portal.selenium.utils.logging.LoggingSelenium;
import com.unitedinternet.portal.selenium.utils.logging.LoggingUtils;
//import static com.unitedinternet.portal.selenium.utils.logging.LoggingAssert.assertEquals;
//import static com.unitedinternet.portal.selenium.utils.logging.LoggingAssert.assertTrue;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
//import org.openqa.selenium.server.SeleniumServer;

//import java.util.regex.Pattern;

public class Testdashboard extends SeleneseTestBase {
        

        BufferedWriter loggingWriter;
        protected LoggingSelenium selenium;
        final String resultbasePath = "/opt/seleniumTests/results/dashboard";
        //final String resultbasePath = "/opt/seleniumTests/results";
    final String resultHtmlFileName = resultbasePath + "/" + "resultdashboard.html";
    final String resultEncoding = "UTF-8";          
    final String screenshotpath="screenshot";
    final String screenshotresultPath=new File(resultbasePath+"/"+screenshotpath).getAbsolutePath();
        @Before
        public void setUp() throws Exception {
                if (!new File(screenshotresultPath).exists()) {
                         new File(screenshotresultPath).mkdirs();
                }
            loggingWriter = LoggingUtils.createWriter(resultHtmlFileName, resultEncoding , true);
            LoggingResultsFormatter htmlFormatter = 
                new HtmlResultFormatter(loggingWriter, resultEncoding);
           htmlFormatter.setScreenShotBaseUri(resultbasePath+"/"+screenshotpath+"/"); // this is for linking to the screenshots
           htmlFormatter.setAutomaticScreenshotPath(screenshotresultPath);
            // wrap HttpCommandProcessor from remote-control
            LoggingCommandProcessor myProcessor = 
            new LoggingCommandProcessor(new HttpCommandProcessor("localhost", 4444, "*firefox", "http://saholic:shop2020@www.shop2020.in:8080"), htmlFormatter);
            //new LoggingCommandProcessor(new HttpCommandProcessor("localhost", 4444, "*firefox", "http://saholic.com/"), htmlFormatter);
            selenium = new LoggingDefaultSelenium(myProcessor);
            myProcessor.setExcludedCommands(new String[] {});
            selenium.start();   
        }

        @Test(expected=AssertionError.class)
        public void testdashboardorder() throws Exception {
                String Orderid="136748";
                selenium.setContext("testdashboardorder()");
                selenium.setTimeout("60000");
                selenium.open("/dashboard");
                selenium.windowMaximize();
                selenium.type("css=input.gwt-TextBox","ys5admin");
                selenium.type("css=input.gwt-PasswordTextBox","1grim@ce");
                selenium.click("css=button.gwt-Button");
                Thread.sleep(10000);
                selenium.click("link=Search");
                Thread.sleep(10000);
                selenium.type("css=input.gwt-TextBox",Orderid);
                selenium.click("css=button.gwt-Button");
                Thread.sleep(10000);
                if(!selenium.isTextPresent("Submitted to processing"))
                {
                        selenium.isTextPresent("Submitted to warehouse");
                }
                Thread.sleep(5000);
                selenium.click("css=input[type='checkbox']");
                Thread.sleep(5000);
                selenium.click("css=button.gwt-Button");
                Thread.sleep(5000);
                selenium.isTextPresent("Order "+Orderid+" was accepted");
                Thread.sleep(20000);
                selenium.click("css=div.dialogMiddleCenterInner.dialogContent > button.gwt-Button");
                Thread.sleep(5000);
                selenium.click("id=gwt-uid-24");
                Thread.sleep(6000);
                
        }
        @After
        public void tearDown() throws Exception {
                selenium.stop();
        //stopSeleniumServer();
                try {
                if (null != loggingWriter) {
                    loggingWriter.close();
                }
            } catch (IOException e) {
              System.out.println("IO exception");
            }
        }
}