我正在GroovyConsole.exe
中运行下面的脚本(GebreportingSpec
测试用例)。第一次启动GroovyConsole时,它可以正常运行。它打开FF,运行场景,然后在退出浏览器时关闭FF。
但是,当我再次从相同的GroovyConsole运行相同的脚本时,我会得到unreachableBrowserException
。它首先调用setupspec()
方法,然后在调用测试用例中的go
方法时,调用cleanupspec()
······
GEB:0.9.0
Groovy:2.0.5
FF:14.0.1
JDK:1.6.0_37 64位
@Grapes([
@Grab("org.gebish:geb-core:0.9.0"),
@Grab("org.gebish:geb-spock:0.9.0"),
@Grab("org.seleniumhq.selenium:selenium-firefox-driver:2.26.0"),
//@Grab("org.seleniumhq.selenium:selenium-chrome-driver:2.26.0"),
@Grab("org.seleniumhq.selenium:selenium-support:2.26.0")
])
import geb.Browser
import geb.spock.GebReportingSpec
import org.openqa.selenium.firefox.*
class Google_Search_Test extends GebReportingSpec {
def setupSpec() {
println "Inside setupSpec()..."
browser.config.autoClearCookies = true
}
def cleanupSpec() {
println "Inside cleanupSpec()..."
println "Quitting browser..."
browser.quit()
}
def "google_search_wikipedia"() {
println "Inside google_search_wikipedia..."
when:
println "Going to google.com..."
go "http://google.com/ncr"
// make sure we actually got to the page
assert title == "Google"
// enter wikipedia into the search field
$("input", name: "q").value("wikipedia")
// wait for the change to results page to happen
// (google updates the page dynamically without a new request)
waitFor { title.endsWith("Google Search") }
// is the first link to wikipedia?
def firstLink = $("li.g", 0).find("a.l")
then:
firstLink.text() == "Wikipedia"
println "Finished test execution..."
}
}
gebconfig.groovy:
import org.openqa.selenium.firefox.*
import java.util.concurrent.*
driver = {
FirefoxProfile firefoxProfile = new FirefoxProfile()
firefoxProfile.setPreference("capability.policy.default.Window.frameElement", "allAccess")
def driver = new FirefoxDriver(firefoxProfile)
driver.manage().timeouts().implicitlyWait(60, TimeUnit.SECONDS)
driver.manage().timeouts().pageLoadTimeout(60, TimeUnit.SECONDS)
driver
}
waiting {
// all values are in seconds
timeout = 60
retryInterval = 0.5
}
reportsDir = "SeleniumReports"
成功运行:
Inside setupSpec()...
Inside google_search_wikipedia...
Going to google.com...
Finished test execution...
Inside cleanupSpec()...
Quitting browser...
JUnit 4 Runner, Tests: 1, Failures: 0, Time: 15739
后续运行(异常):
Inside setupSpec()...
Inside google_search_wikipedia...
Going to google.com...
Inside cleanupSpec()...
Quitting browser...
JUnit 4 Runner, Tests: 1, Failures: 2, Time: 687
Test Failure: google_search_wikipedia(Google_Search_Test)
org.openqa.selenium.remote.UnreachableBrowserException: Error communicating with the remote browser. It may have died.
Build info: version: '2.26.0', revision: '18040', time: '2012-11-02 09:44:45'
System info: os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.6.0_37'
Driver info: driver.version: RemoteWebDriver
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:526)
at org.openqa.selenium.remote.RemoteWebDriver.get(RemoteWebDriver.java:275)
at geb.Browser.go(Browser.groovy:371)
at geb.Browser.go(Browser.groovy:363)
at geb.spock.GebSpec.methodMissing(GebSpec.groovy:51)
at Google_Search_Test.google_search_wikipedia(Google_Search.groovy:27)
Caused by: org.openqa.selenium.WebDriverException: The FirefoxDriver cannot be used after quit() was called.
Build info: version: '2.26.0', revision: '18040', time: '2012-11-02 09:44:45'
System info: os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.6.0_37'
Driver info: driver.version: RemoteWebDriver
at org.openqa.selenium.firefox.FirefoxDriver$LazyCommandExecutor.execute(FirefoxDriver.java:351)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:505)
... 5 more
Test Failure: google_search_wikipedia(Google_Search_Test)
org.openqa.selenium.remote.UnreachableBrowserException: Error communicating with the remote browser. It may have died.
Build info: version: '2.26.0', revision: '18040', time: '2012-11-02 09:44:45'
System info: os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.6.0_37'
Driver info: driver.version: RemoteWebDriver
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:526)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:535)
at org.openqa.selenium.remote.RemoteWebDriver.getPageSource(RemoteWebDriver.java:396)
at geb.report.PageSourceReporter.getPageSource(PageSourceReporter.groovy:42)
at geb.report.PageSourceReporter.writePageSource(PageSourceReporter.groovy:38)
at geb.report.PageSourceReporter.writeReport(PageSourceReporter.groovy:29)
at geb.report.CompositeReporter.writeReport(CompositeReporter.groovy:31)
at geb.Browser.report(Browser.groovy:698)
at geb.spock.GebReportingSpec.report(GebReportingSpec.groovy:43)
at geb.spock.GebReportingSpec.cleanup(GebReportingSpec.groovy:39)
Caused by: org.openqa.selenium.WebDriverException: The FirefoxDriver cannot be used after quit() was called.
Build info: version: '2.26.0', revision: '18040', time: '2012-11-02 09:44:45'
System info: os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.6.0_37'
Driver info: driver.version: RemoteWebDriver
at org.openqa.selenium.firefox.FirefoxDriver$LazyCommandExecutor.execute(FirefoxDriver.java:351)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:505)
... 9 more
Geb有一个驱动程序缓存的概念,因此只打开和重用一个浏览器窗口,在groovy控制台中使用它会遇到问题。Geb为您管理驱动程序/浏览器实例,并且缓存在虚拟机的整个生命周期中处于活动状态。之所以出现错误,是因为您正在手动退出驱动程序(如果启用了驱动程序缓存,就不应该这样做),并且VM尚未关闭(groovy控制台仍在两次执行之间运行),这意味着从缓存中检索到的驱动程序管理的浏览器已经关闭。
你有两个选择,第二个在我看来更好:
问题内容: 我有一个带有Java Applet的网站,该Applet需要连接到我的服务器。这在JApplets @Override init()中有效,但不适用于javascript调用的我自己的函数中。 网站: 输出: 我尝试通过System.out调用解决它,但是那里也没有任何反应。但是,这绝对可以: 哦,小程序当然也来自 我该如何解决或解决它? 问题答案: 尝试以下方法:
我有以下目录结构: b、 py需要在a.py中导入一个类。因此,我可以在导入a之前将以下行添加到b.py。 sys.path.append(os.path.dirname(sys.argv[0])) 这是可行的,我可以从任何目录调用b.py,它也可以导入a。但是,当我在另一个目录中编写脚本以使用execfile()调用此文件时,这将失败。 我尝试了相对导入,但得到了“在非包错误中尝试相对导入” 我
问题内容: 我创建了一个C ++类,应该通过以下方式调用:http : //docs.oracle.com/javase/7/docs/technotes/guides/jni/spec/invocation.html#wp9502。 我没有使其正常工作,所以我遵循了:http : //www.coderanch.com/t/525082/CPP/create-JVM-native-code- c
根据文件,结构如下: char*GR_NAME 组的名称。 /tmp#java-cp.:jna-4.5.1.jar测试root Hello,线程“main”java.lang.IllegalArgumentException:在com.sun.jna.pointer.ReadArray(pointer.java:538)在com.sun.jna.pointer.GetValue(pointer.j
Quarkus 1.8.3。最终的 直接调用访问PanacherRepository的方法可以按预期工作,但是当通过EventBus调用同一方法时,调用到达该方法并执行每一行,直到它到达任何存储库调用,然后在没有任何发生的指示的情况下无声地失败/退出。 根据日志,直接调用在Quarkus主线程中执行,事件总线调用在vert中执行。x-eventloop-thread-2。 还尝试了以下步骤的组合,
我用java-jar selenium-server-standalone-2.30.0.jar-role hub启动selenium-standalone作为hub 节点为java-dwebdriver.chrome.driver=c://chrome/chromedri ver.exe-jar selenium-server-standalone-2.30.0.jar-role webdriv