Menu

LoggingSelenium Running Problem

2008-09-12
2013-05-14
  • chetan dhumane

    chetan dhumane - 2008-09-12

    I get exception when try to run code as below :
    selenium.setContext("loggingSeleniumSuccessSample()");

    It throws exception as java.lang.NullPointerException

     
    • Robert Zimmermann

      If the code you ran is from the samples then obviously setup of the selenium object was not successful.

      Did you use junit 4 to run the sample?

       
  • sandeep sivan

    sandeep sivan - 2009-09-25

    hi even i m facing the same issue
    i m using junit 4.5 with selenium client driver selenium-java-client-driver-1.0.1 and server as same version.

    any help will be great..
    this is the snippet of code..

    /**
    *
    */
    package reply;

    import static org.junit.Assert.*;

    import org.junit.*;
    //import junit.framework.*;

    import com.sun.org.apache.xerces.internal.impl.xpath.regex.ParseException;
    import com.thoughtworks.selenium.HttpCommandProcessor;
    import com.unitedinternet.portal.selenium.utils.logging.*;

    import java.io.*;

    /**
    * @author ssivanan
    *
    */

    public class LoggingSeleniumSuccessSample {
          protected LoggingSelenium selenium;
          private BufferedWriter loggingWriter;
          @Before
          public void setUp() {

          final String resultHtmlFileName = "C:\\result.html";
          final String resultEncoding = "UTF-8";
          loggingWriter = LoggingUtils.createWriter(resultHtmlFileName, resultEncoding, true);

          LoggingResultsFormatter htmlFormatter = new HtmlResultFormatter(loggingWriter, resultEncoding);
          htmlFormatter.setScreenShotBaseUri("C:\\"); // this is for linking to the screenshots
          htmlFormatter.setAutomaticScreenshotPath("C:\\");

          LoggingCommandProcessor myProcessor = new LoggingCommandProcessor(new HttpCommandProcessor("localhost", 4444, "*iexplore", "http://www.google.com"), htmlFormatter);
          selenium = new LoggingDefaultSelenium(myProcessor);

          //Start causes the wedge.
          //selenium.start();
          }
     
          @After
          public void tearDown() {
              selenium.stop();
              try {
                  if (null != loggingWriter) {
                      loggingWriter.close();
                  }
              } catch (IOException e) {
                  // do nothing
              }
          }
     
          @Test
          public void loggingSeleniumSuccessSample() throws InterruptedException,ParseException {
             selenium.setContext("loggingSeleniumSuccessSample()");

             selenium.open("/");

             /*selenium.captureScreenshot(screenshotsResultsPath
                     + File.separator
                     + "openQaHomePage_"
                     + LoggingUtils.timeStampForFileName()
                     + ".png");
    */
             // Note the special assertEquals from logging-selenium needs
             // a selenium instance and a description string
             // selenium instance is needed in order to be able to log exceptions
             // Get rid of this is to be available in V >2.0
             assertEquals("Expected page title not found", selenium.getTitle());

             selenium.click("link=Selenium RC");
             selenium.waitForPageToLoad("30000");

             assertEquals("Expected page title not found",selenium.getTitle());
             assertTrue(selenium.isTextPresent("Supported Platforms"));

             selenium.click("link=Tutorial");
             selenium.waitForPageToLoad("30000");
             assertEquals("Expected page title not found",selenium.getTitle());

             /*selenium.captureScreenshot(screenshotsResultsPath
                     + File.separator
                     + "openQaTutorialPage_"
                     + LoggingUtils.timeStampForFileName()
                     + ".png");*/
        }

    }

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.