以下是创建FB帐户的代码。我有Excel表格和测试数据来创建它们。如何将该数据导入下面的代码???
代码:
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.By;
public class Facebookup {
public static void main (String args[]) throws InterruptedException
{
WebDriver gm = new FirefoxDriver();
gm.manage().window().maximize();
gm.get("https://www.facebook.com/");
gm.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
gm.findElement(By.xpath(".//*[@id='u_0_1']")).sendKeys("Tester");
gm.findElement(By.xpath(".//*[@id='u_0_3']")).sendKeys("Dravid");
gm.findElement(By.xpath(".//*[@id='u_0_5']")).sendKeys("testprod2000@gmail.com");
gm.findElement(By.xpath(".//*[@id='u_0_8']")).sendKeys("testprod2000@gmail.com");
gm.findElement(By.xpath(".//*[@id='u_0_a']")).sendKeys("Naren1234");
gm.findElement(By.xpath(".//*[@id='month']")).click();
Thread.sleep(2000);
gm.findElement(By.xpath(".//option[@value = '1']")).click();
gm.findElement(By.xpath(".//*[@id='day']")).click();
Thread.sleep(2000);
gm.findElement(By.xpath(".//option[@value = '8']")).click();
gm.findElement(By.xpath(".//*[@id='year']")).click();
Thread.sleep(2000);
gm.findElement(By.xpath(".//option[@value = '1991']")).click();
Thread.sleep(2000);
gm.findElement(By.xpath(".//*[@id='u_0_e']")).click();
gm.findElement(By.xpath(".//*[@id='u_0_i']")).click();
}
}
答案 0 :(得分:0)
您可以使用JXL Java库,它具有从Excel工作表中读取数据的方法。 可以从http://www.java2s.com/Code/Jar/j/Downloadjxljar.htm
下载jar