收到在我的 GebConfig 中发生的 java.lang.IllegalStateException。

huangapple 未分类评论43阅读模式
英文:

Receiving java.lang.IllegalStateException in my GebConfig

问题

以下是翻译好的内容:

任何帮助都会受到赞赏。我已经阅读了许多关于此问题的帖子,无论是在这里还是其他网站上,但都没有给我提供解决方案。我真的无法弄清楚我的配置文件中出了什么问题。

我收到的完整错误信息:

java.lang.IllegalStateException: 必须通过webdriver.chrome.driver系统属性设置驱动程序可执行文件的路径;

这是我的配置文件:

import org.openqa.selenium.WebDriver
import org.openqa.selenium.chrome.ChromeDriver
import org.openqa.selenium.firefox.FirefoxDriver
import org.openqa.selenium.remote.DesiredCapabilities
import org.openqa.selenium.remote.RemoteWebDriver

baseUrl = "mysite.com"

driver = 'chrome'
environments {
	'chrome' {
		def chromeDriver = new File('G:\\Programs\\Eclipse\\Workspace\\chromedriver.exe')
		System.setProperty('webdriver.chrome.driver', chromeDriver.absolutePath)
		driver = { new ChromeDriver() }
		driver.manage().window().maximize()
	}
	'firefox' {
		def geckoDriver = new File('G:\\Programs\\Eclipse\\Workspace\\geckodriver.exe')
		System.setProperty('webdriver.gecko.driver', geckoDriver.absolutePath)
		driver = { new FirefoxDriver() }
	}
}

reportsDir = new File("target/geb-reports1")

无论是geckodriver还是chromedriver都是最新版本,我的浏览器也都是最新版本。如果有人能够指导我正确的方向,我将不胜感激。

编辑:我还应该注意到,我已经尝试将absolutePath更新为System.setProperty('webdriver.chrome.driver', 'G:\\Programs\\Eclipse\\Workspace\\chromedriver.exe'),但不幸的是这也没有起作用。

英文:

Any help would be appreciated. I've read many threads both here, and on other sites, but none have provided me with a solution. I truly can't figure out what is broken in my config.

The full error I'm receiving:

>java.lang.IllegalStateException: The path to the driver executable must be set by the webdriver.chrome.driver system property;

And here is my config:

import org.openqa.selenium.chrome.ChromeDriver
import org.openqa.selenium.firefox.FirefoxDriver
import org.openqa.selenium.remote.DesiredCapabilities
import org.openqa.selenium.remote.RemoteWebDriver


baseUrl = "mysite.com"

driver = 'chrome'
environments {
	'chrome' {
		def chromeDriver = new File('G:\\Programs\\Eclipse\\Workspace\\chromedriver.exe')
		System.setProperty('webdriver.chrome.driver', chromeDriver.absolutePath)
		driver = { new ChromeDriver() }
		driver.manage().window().maximize()
	}
	'firefox' {
		def FirefoxDriver = new File('G:\\Programs\\Eclipse\\Workspace\\geckodriver.exe')
		System.setProperty('webdriver.gecko.driver', geckoDriver.absolutePath)
		driver = { new FirefoxDriver() }
	}
}

reportsDir = new File("target/geb-reports1")

Both geckodriver and chromedriver are up to date with the latest releases, as are both my browsers. If anyone can point me in the right direction I would greatly appreciate it.

EDIT: I should also note that I've tried updating absolutePath to be System.setProperty('webdriver.chrome.driver', 'G:\\Programs\\Eclipse\\Workspace\\chromedriver.exe') but unfortunately that hasn't worked, either.

huangapple
  • 本文由 发表于 2020年4月9日 23:56:36
  • 转载请务必保留本文链接:https://java.coder-hub.com/61125213.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定