我在项目文件夹中有chromedriver和chromedriver.exe.我正在使用此代码创建驱动程序实例.
ChromeOptions options = new ChromeOptions();
DesiredCapabilities capabilities = DesiredCapabilities.firefox();
LoggingPreferences log_prefs = new LoggingPreferences();
log_prefs.enable(LogType.BROWSER, Level.SEVERE);
capabilities.setCapability(CapabilityType.LOGGING_PREFS, log_prefs);
System.setProperty("webdriver.chrome.driver", "chromedriver");
driver = new ChromeDriver(capabilities);
driver.manage().window().maximize();
Run Code Online (Sandbox Code Playgroud)
并且它在本地窗口上是可以的(如果我们将"chromedriver"更改为"chromedriver.exe"),但是当我在CentOS上运行时,我收到错误消息:"驱动程序不可执行".
您好我正在尝试使用Maven运行JUnit测试.
public final class CreateAllObject {
public static final String INIT_URL = new String("http://fpt2:8080/webTest/");
@BeforeClass
public static void initialisation()
{
Driver driver = new Driver(PROFILE_PATH);
driver.getDriver().get(INIT_URL);
driver.getDriver().findElement(By.xpath(ADMIN_ARM_XPATH)).click();
BASE_URL = driver.getDriver().getCurrentUrl();
driver.getDriver().close();
try {
new File("C://logfiles//").mkdirs();
log_work = new BufferedWriter (new FileWriter(
new File("C://logfiles//" +
new SimpleDateFormat("dd.MM.yyyy 'at' HH-mm-ss").format(
new GregorianCalendar().getTime())+".log_work")));
} catch (IOException e) {
e.printStackTrace();
}
}
@Test
public void test()
{
Driver driver = new Driver( PROFILE_PATH );
...
}
@AfterClass
public static void destruction()
{
try
{ …Run Code Online (Sandbox Code Playgroud)