TA的每日心情 | 衰 2018-5-3 11:33 |
---|
签到天数: 3 天 连续签到: 1 天 [LV.2]测试排长
|
8#
楼主 |
发表于 2016-10-14 09:10:14
|
只看该作者
本帖最后由 Jay~ 于 2016-10-14 09:13 编辑
try {
for(int i=0;i<row;i++) {
String[] str = (String[]) list.get(i);
String username = str[0];
String realname = str[1];
String password = str[2];
String tel = str[3];
Newcustomer cus = new Newcustomer();
cus.newcust(username,realname,password,tel);
}
} catch (Exception e) {
e.printStackTrace();
}
if(stream != null){
stream.close();
}
public void newcust(String username,String realname,String password,String tel) throws Exception {
System.out.println( driver.findElement(By.name("realName"))); 这里就报空指针了 这是48行
driver.findElement(By.name("realName")).clear();
driver.findElement(By.name("realName")).sendKeys(realname);
// driver.findElement(By.xpath(".//*[@id='customerForm']/div/div/div/div/div/div[1]/div/input")).clear();
// driver.findElement(By.xpath(".//*[@id='customerForm']/div/div/div/div/div/div[1]/div/input")).sendKeys(realname);
driver.findElement(By.name("userName")).clear();
driver.findElement(By.name("userName")).sendKeys(username);
driver.findElement(By.name("password")).clear();
driver.findElement(By.name("password")).sendKeys(password);
driver.findElement(By.name("mobile")).clear();
driver.findElement(By.name("mobile")).sendKeys(tel);
driver.findElement(By.id("customerFormBtn")).click();
}
下面是报的错
java.lang.NullPointerException
at com.abczww.hs.demo.Newcustomer.newcust(Newcustomer.java:48)
at com.abczww.hs.demo.ExcelWorkBook.readExcel(ExcelWorkBook.java:80)
at com.abczww.hs.demo.Newcustomer.test1(Newcustomer.java:41)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
|
|