2014-09-12 63 views
0
package Cabelcologin; 

import org.openqa.selenium.By; 

import org.openqa.selenium.WebDriver; 

import org.openqa.selenium.chrome.ChromeDriver; 

import org.testng.annotations.Test; 

public class Loginchrome { 

    WebDriver driver1; 

    public void launchChrome(){ 
     } 
    { 
    System.setProperty("webdriver.chrome.driver", "C:/chromedriver.exe"); 
    WebDriver driver = new ChromeDriver();} 

    @Test//This is TestNG annotation 

    public void testLoginPageTitle(){ 
    } 
    { 

    driver1.get("http://test01.boston-idm.ci.opal.synacor.com:4080/flowcontrol/1/"); 
    driver1.findElement(By.linkText("Cableco Login")).click(); 

    driver1.findElement(By.id("E-mail Address")).sendKeys("[email protected]"); 
    driver1.findElement(By.id("Password")).sendKeys("password1"); 
    driver1.findElement(By.id("Login")).click(); 
    } 

    public void kill() 
    { 
    driver1.close(); 

    driver1.quit(); 
    } 
} 
+2

您是否看到任何錯誤? – alecxe 2014-09-12 13:43:05

+0

在testLoginPageTitle之後,你看似額外的{}是什麼? – user1071777 2014-09-12 13:44:20

+0

java.lang.NullPointerException – Mel 2014-09-12 16:46:39

回答

0
public class Loginchrome { 
WebDriver driver1; 

@Test//This is TestNG annotation 
public void testLoginPageTitle() { 
    System.setProperty("webdriver.chrome.driver", "C:/chromedriver.exe"); 
    driver1 = new ChromeDriver(); 

    driver1.get("http://test01.boston-idm.ci.opal.synacor.com:4080/flowcontrol/1/"); 
    driver1.findElement(By.linkText("Cableco Login")).click(); 

    driver1.findElement(By.id("E-mail Address")).sendKeys("[email protected]"); 
    driver1.findElement(By.id("Password")).sendKeys("password1"); 
    driver1.findElement(By.id("Login")).click(); 
} 

@AfterMethod 
public void kill() 
{ 
    driver1.quit(); 
} 
} 
+0

它的工作,但現在它沒有找到電子郵件地址字段。 – Mel 2014-09-15 13:57:34

+0

check ure id - 電子郵件地址 – 2014-09-15 14:06:41

0

這個硒的webdriver測試乍一看我實例化驅動程序的webdriver =新ChromeDriver(),但你的get方法調用driver1.get(URL)。似乎有問題