title: Selenium how to open a web browser to run a selenium script
body: <p>I exported a script from <strong>selenium IDE 1.9.0</strong> as Java/TestNG/RemoteControl. </p>
  
  <p>I would like to run this script using <strong>TestNG</strong> within <strong>Eclipse</strong> and I want to see the script play back in <strong>Firefox</strong> browser. </p>
  
  <p>I did some search online, but I could not make it work. I need some instructions and guidance on how to make the code work. Your help is greatly appreciated. </p>
  
  <p>Here is my code: </p>
  
  <pre><code>import java.util.List;
  import org.testng.annotations.*;
  import org.openqa.selenium.By;
  import org.openqa.selenium.WebDriver;
  import org.openqa.selenium.WebElement;
  import org.openqa.selenium.htmlunit.HtmlUnitDriver;
  import org.openqa.selenium.firefox.FirefoxDriver;
  import org.openqa.selenium.firefox.FirefoxProfile;
  import static org.testng.Assert.*;
  import org.testng.annotations.Test;
  import org.testng.annotations.BeforeTest;
  import org.testng.annotations.AfterTest;
  
  public class search_donor_suzy_ng //extends SeleneseTestNgHelper {
      @BeforeTest
      public void setUp() throws Exception {
          //initizlize Firefoxbrowser: 
          WebDriver ffoxdriver = new FirefoxDriver();
          String baseUrl = "www.google.com"; //sample URL
      }
      @Test 
      public void testSearch_donor_suzy_ng() throws Exception {
          // set overall speed of the test case
          selenium.setSpeed("4000");
          selenium.open("/?html=openid");
          selenium.click("css=input[type=\"submit\"]");
          selenium.waitForPageToLoad("30000");
          Thread.sleep(4000);
          selenium.type("id=edit-name", "jeffshu");
          selenium.type("id=edit-pass", "tEgvz9xsaNjnwe4Y");
          selenium.click("id=edit-submit");
          selenium.waitForPageToLoad("30000");
          Thread.sleep(4000);
          selenium.click("id=cmp_admin");
          selenium.waitForPageToLoad("30000");
          selenium.click("id=quicksearch_anchor");
          selenium.click("css=img[alt=\"Member\"]");
          selenium.waitForPageToLoad("30000");
          selenium.type("id=search_name", "suzy");
          selenium.click("css=input[type=\"image\"]");
          selenium.click("link=Balagia, Suzy");
          selenium.waitForPageToLoad("30000");
      }
      @AfterTest
      public void tearDown() throws Exception {
          ffoxdriver.quit();  
      }
  } 
  </code></pre>