我正在使用selenium webdriver,通過Java & TestNG。無法在Selenium Web驅動程序(Java)中啓動Chrome
我只是嘗試了下面的代碼:(啓動Chrome瀏覽器),
package testng1package;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.testng.AssertJUnit;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;
import org.testng.annotations.AfterTest;
public class TestNGFile {
//using firefox
//public WebDriver driver = new FirefoxDriver() ;
//using Chrome
System.setProperty("webdriver.chrome.driver", "C://Users//Roey//Desktop//chromedriver.exe");
public WebDriver driver = new ChromeDriver();
String baseurl = "http://newtours.demoaut.com/" ;
@BeforeTest
public void StartBrowser() {
}
@Test
public void Test1() {
driver.get(baseurl);
String expectedTitle = "Welcome: Mercury Tours" ;
String actualTitle = driver.getTitle();
AssertJUnit.assertEquals(actualTitle , expectedTitle) ;
driver.quit();
}
@AfterTest
public void terminateBrowser() {
driver.quit();
}
}
測試包含在system.setproperty錯誤,並說:
在這多個標記線
- 令牌(一個或多個)中的語法錯誤,錯放 構建體
- 上的令牌中的語法錯誤,刪除這些 令牌
如果我正在將此代碼行剪切並粘貼到@test中 - 沒關係,但我想從@BeforeTest
或開頭(現在就是它)使用它。
您需要向我們展示更多代碼。同時發佈整個錯誤堆棧。 – SiKing 2014-10-20 17:14:58