我正在使用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