Sunday, July 27, 2014

Running Selenium Tests in (Eclipse + Junit) Framework


Use the Selenium IDE for recording the tests. From the below website, Download Firefox plugin which records and plays back user interactions with the browser.

http://seleniumhq.org/download/

You can export the recorded test case into desired programming language using the option: File -> Export Test Case AS -> Java / JUnit 4 / WebDriver



Download and install the Eclipse from : http://www.eclipse.org/downloads/

Download the JUnit jars (junit.jar and hamcrest-core.jar) from http://junit.org/


Create a project in eclipse. Add JUnit jars in project's build path: Properties -> Java Build Path -> Libraries -> Add External Jars

Download the Selenium Client jars from below website. Add the jars to project's build path.

http://docs.seleniumhq.org/download/

------------------
You may test your JUnit installation by creating following two classes:

Create a class MessageDisplay in the project

public class MessageDisplay {

   private String message;

   /* Constructor
    * @param: message to be printed
    */
   public MessageDisplay(String message){
      this.message = message;
   }
   
   /* prints the message to console */
   public String displayMessage(){
      System.out.println(message);
      return message;
   }
}

Create a class TestMessageDisplay in the project

import org.junit.Test;
import static org.junit.Assert.assertEquals;

public class TestMessageDisplay {

   String message = "Hello World";
   MessageDisplay messageDisplay = new MessageDisplay(message);

   @Test
   public void testPrintMessage() {
      assertEquals(message,messageDisplay.displayMessage());
   }
}

Run the program successfully by right clicking on TestJUnit: Run As -> JUnit Test
------------------

Now add a test Case to the project by going to Project Explorer: New -> JUnit Test Case



Now, copy the code that Selenium IDE generated. You may need to fix compilation erros (such sa package name errors, class name errors, etc).

Run the test case by right clicking: Run As -> JUnit Test






Further info:

http://docs.seleniumhq.org/docs/03_webdriver.jsp#webdriver-backed-selenium-rc

- Web Driver vs. RC

Selenium-WebDriver makes direct calls to the browser using each browser’s native support for automation. How these direct calls are made, and the features they support depends on the browser you are using. Information on each ‘browser driver’ is provided later in this chapter.

For those familiar with Selenium-RC, this is quite different from what you are used to. Selenium-RC worked the same way for each supported browser. It ‘injected’ javascript functions into the browser when the browser was loaded and then used its javascript to drive the AUT within the browser. WebDriver does not use this technique. Again, it drives the browser directly using the browser’s built in support for automation.

- Do you need Selenium Server?

You may, or may not, need the Selenium Server, depending on how you intend to use Selenium-WebDriver. If you will be only using the WebDriver API you do not need the Selenium-Server. If your browser and tests will all run on the same machine, and your tests only use the WebDriver API, then you do not need to run the Selenium-Server; WebDriver will run the browser directly

- Running Standalone Selenium Server for use with RemoteDrivers

From Selenium’s Download page download selenium-server-standalone-.jar
Start the server on the command line with
java -jar /selenium-server-standalone-.jar

Thursday, January 02, 2014

travel outside of United States while Status Change is in process

Following are the responses from an Immigration Lawyer for questions related to 'Traveling outside of United States while Status Change (from H4 to F1) is in process':


Q: While the change of status is under process, can the applicant travel outside of the country? If applicant travels outside the country, what will happen?

A: Yes, applicant can leave the US while the change of status application is pending; but applicant will be abandoning this application. Applicant will need to obtain F-1 stamp at the consulate before applicant can travel back to the United States on F-1 status. Or, if applicant returns to the US on H-4 status, applicant will need to refile the (H4 to F-1) change of status application.


Q: When applicant's change of status application gets abandoned because of travel outside of United States, can the applicant come back to United States on existing H-4 visa (i.e. does applicant's existing H-4 visa stands valid after leaving United States)?

A: Yes, the visa should not be invalidated and as long as the H-4 visa stamps remains valid it can be used to travel back to the US.


Q:  Is it safe for the H4 Holder to get F1 Visa stamping when principal H1B holder has filed LC PERM for the green card?

A: The risk is whether the government would imply immigrant intent at H4 Holder's F-1 stamping -- a PERM is not a non-immigrant application so even if the PERM was filed on principal H1B holder's behalf, it should not have to be disclosed as it is not an "immigrant petition".