How to type in textbox using Selenium WebDriver (Selenium 2) with Java? -


enter image description here using selenium 2. after running following code, not able type in textbox.

    package actor; import org.openqa.*; import org.openqa.selenium.by; import org.openqa.selenium.webdriver; import org.openqa.selenium.webelement; import org.openqa.selenium.firefox.firefoxdriver; import org.junit.*; import com.thoughtworks.selenium.*; //import org.junit.before; public class actor {   public selenium selenium;   public webdriver driver;    @before   public void setup() throws exception{   driver = new firefoxdriver();       driver.get("http://www.fb.com");   }   @test   public void test() throws exception{       //selenium.type("id=gs_htif0", "test");       system.out.println("hi");       // driver.findelement(by.cssselector("#gb_1 > span.gbts")).click();           selenium.waitforpagetoload("300000000");            webelement email=driver.findelement(by.id("email"));            email.sendkeys("nshakuntalas@gmail.com");           driver.findelement(by.id("u_0_b")).click();   }   @after   public void close() throws exception{       system.out.println("how you?");   }  } 

this simple if use selenium webdriver, , forget usage of selenium-rc. i'd go this.

webdriver driver = new firefoxdriver(); webelement email = driver.findelement(by.id("email")); email.sendkeys("your@email.here"); 

the reason nullpointerexception variable driver has never been started, start firefoxdriver in variable wb thas never being used.


Comments

Popular posts from this blog

c# - Operator '==' incompatible with operand types 'Guid' and 'Guid' using DynamicExpression.ParseLambda<T, bool> -