Selenium 驱动程序:-Dwebdriver.driver="iexplorer" 调用 safari
Selenium driver: -Dwebdriver.driver="iexplorer" invokes safari
当我尝试 运行 我的 Serenity 测试自动化时,我调用了以下 maven 命令:
mvn clean verify -Dentry_point="**/*SmokeTestSuite.java" -Dwebdriver.driver="iexplorer" -Dwebdriver.ie.driver="<my path>\IEDriverServer.exe"
我提供了 iexplorer 作为驱动程序和 IEDriverServer.exe 的路径。我的 Internet Explorer 版本是 11.x。
当我 运行 安装 ie 驱动程序时,它会出错,我需要将路径添加到 safari.exe。
以下是错误堆栈跟踪:
[pool-1-thread-1] ERROR net.thucydides.core.webdriver.WebDriverFacade - FAILED TO CREATE NEW WEBDRIVER_DRIVER INSTANCE class org.openqa.selenium.ie.InternetExplorerDriver: Could not instantiate class org.openqa.selenium.ie.InternetExplorerDriver
net.thucydides.core.webdriver.UnsupportedDriverException: Could not instantiate class org.openqa.selenium.ie.InternetExplorerDriver
at net.thucydides.core.webdriver.WebDriverFactory.newWebdriverInstance(WebDriverFactory.java:128)
at net.thucydides.core.webdriver.WebDriverFacade.newDriverInstance(WebDriverFacade.java:142)
at net.thucydides.core.webdriver.WebDriverFacade.newProxyDriver(WebDriverFacade.java:133)
at net.thucydides.core.webdriver.WebDriverFacade.getProxiedDriver(WebDriverFacade.java:103)
at net.thucydides.core.webdriver.WebDriverFacade.getTitle(WebDriverFacade.java:213)
at net.serenitybdd.jbehave.SerenityReporter.managedDriverIsNotAlive(SerenityReporter.java:215)
at net.serenitybdd.jbehave.SerenityReporter.beforeScenario(SerenityReporter.java:188)
at org.jbehave.core.reporters.DelegatingStoryReporter.beforeScenario(DelegatingStoryReporter.java:55)
at org.jbehave.core.reporters.ConcurrentStoryReporter.beforeScenario(ConcurrentStoryReporter.java:158)
at org.jbehave.core.embedder.PerformableTree$PerformableScenario.perform(PerformableTree.java:877)
at org.jbehave.core.embedder.PerformableTree$PerformableStory.performScenarios(PerformableTree.java:811)
at org.jbehave.core.embedder.PerformableTree$PerformableStory.perform(PerformableTree.java:784)
at org.jbehave.core.embedder.PerformableTree.performCancellable(PerformableTree.java:416)
at org.jbehave.core.embedder.PerformableTree.perform(PerformableTree.java:387)
at org.jbehave.core.embedder.StoryManager$EnqueuedStory.call(StoryManager.java:291)
at org.jbehave.core.embedder.StoryManager$EnqueuedStory.call(StoryManager.java:265)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)at java.lang.Thread.run(Thread.java:748) .
Caused by: java.lang.RuntimeException: Safari could not be found in the path!
Please add the directory containing ''Safari.exe'' to your PATH environment
variable, or explicitly specify a path to Safari like this:
*safari c:\blah\Safari.exe
at org.openqa.selenium.browserlaunchers.locators.SingleBrowserLocator.findBrowserLocationOrFail(SingleBrowserLocator.java:42)
at org.openqa.selenium.safari.SafariDriverCommandExecutor.start(SafariDriverCommandExecutor.java:100)
at org.openqa.selenium.safari.SafariDriver.startClient(SafariDriver.java:76)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:119)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:144)
at org.openqa.selenium.safari.SafariDriver.<init>(SafariDriver.java:62)
at org.openqa.selenium.safari.SafariDriver.<init>(SafariDriver.java:53)
at net.thucydides.core.webdriver.strategies.InternetExplorerDriverBuilder.newInstance(InternetExplorerDriverBuilder.java:30)
at net.thucydides.core.webdriver.WebDriverFactory.newWebdriverInstance(WebDriverFactory.java:116)
... 19 more
此错误消息...
ERROR net.thucydides.core.webdriver.WebDriverFacade - FAILED TO CREATE NEW WEBDRIVER_DRIVER INSTANCE class org.openqa.selenium.ie.InternetExplorerDriver: Could not instantiate class org.openqa.selenium.ie.InternetExplorerDriver
net.thucydides.core.webdriver.UnsupportedDriverException: Could not instantiate class org.openqa.selenium.ie.InternetExplorerDriver
...意味着该程序无法 create/spawn 所需的新 InternetExplorerDriver 实例。
这个错误的主要原因是容易出错的maven命令你用来执行Serenity Test Automation Suite 如下:
mvn clean verify -Dentry_point="**/*SmokeTestSuite.java" -Dwebdriver.driver="iexplorer" -Dwebdriver.ie.driver="<my path>\IEDriverServer.exe"
最常用的 WebDriver 变体是:
-Dwebdriver.gecko.driver
- 对于 geckodriver.exe
-Dwebdriver.chrome.driver
- 对于 chromedriver.exe
-Dwebdriver.ie.driver
- 对于 IEDriverServer.exe
但是因为您使用了不正确的参数作为-Dwebdriver.driver
以及不正确的值 因为 iexplorer
Serenity 测试自动化框架 尝试访问 [=82 的默认配置=].
解决方案
你需要删除容易出错的论点-Dwebdriver.driver="iexplorer"
,你就会成功。
webdriver.driver
是设置驱动程序的正确 Serenity 属性。我不确定 DebajanB 的 "error-prone" 是什么意思 - 通常,它可以工作或不工作,如果不工作,则是配置问题。要检查驱动程序 属性 在 Maven 中是否配置正确(您可能需要将它作为系统 属性 在 surefire 或 failsafe 插件中传递到您的测试中),看看它是否适用于 firefox。
对 webdriver.gecko.driver 等的引用告诉 Serenity 在哪里可以找到特定驱动程序的二进制文件,但它们并没有告诉 Serenity 使用哪个驱动程序。您可以配置多个驱动程序二进制文件,然后选择使用其中一个 webdriver.driver
.
Safari 不是 Serenity 的默认驱动程序,Firefox 是,所以对 Safari 的引用很好奇。这可能是来自旧版本的 defect/misleading 错误消息 - 您使用的是最新版本的 Serenity 吗?
当我尝试 运行 我的 Serenity 测试自动化时,我调用了以下 maven 命令:
mvn clean verify -Dentry_point="**/*SmokeTestSuite.java" -Dwebdriver.driver="iexplorer" -Dwebdriver.ie.driver="<my path>\IEDriverServer.exe"
我提供了 iexplorer 作为驱动程序和 IEDriverServer.exe 的路径。我的 Internet Explorer 版本是 11.x。 当我 运行 安装 ie 驱动程序时,它会出错,我需要将路径添加到 safari.exe。
以下是错误堆栈跟踪:
[pool-1-thread-1] ERROR net.thucydides.core.webdriver.WebDriverFacade - FAILED TO CREATE NEW WEBDRIVER_DRIVER INSTANCE class org.openqa.selenium.ie.InternetExplorerDriver: Could not instantiate class org.openqa.selenium.ie.InternetExplorerDriver
net.thucydides.core.webdriver.UnsupportedDriverException: Could not instantiate class org.openqa.selenium.ie.InternetExplorerDriver
at net.thucydides.core.webdriver.WebDriverFactory.newWebdriverInstance(WebDriverFactory.java:128)
at net.thucydides.core.webdriver.WebDriverFacade.newDriverInstance(WebDriverFacade.java:142)
at net.thucydides.core.webdriver.WebDriverFacade.newProxyDriver(WebDriverFacade.java:133)
at net.thucydides.core.webdriver.WebDriverFacade.getProxiedDriver(WebDriverFacade.java:103)
at net.thucydides.core.webdriver.WebDriverFacade.getTitle(WebDriverFacade.java:213)
at net.serenitybdd.jbehave.SerenityReporter.managedDriverIsNotAlive(SerenityReporter.java:215)
at net.serenitybdd.jbehave.SerenityReporter.beforeScenario(SerenityReporter.java:188)
at org.jbehave.core.reporters.DelegatingStoryReporter.beforeScenario(DelegatingStoryReporter.java:55)
at org.jbehave.core.reporters.ConcurrentStoryReporter.beforeScenario(ConcurrentStoryReporter.java:158)
at org.jbehave.core.embedder.PerformableTree$PerformableScenario.perform(PerformableTree.java:877)
at org.jbehave.core.embedder.PerformableTree$PerformableStory.performScenarios(PerformableTree.java:811)
at org.jbehave.core.embedder.PerformableTree$PerformableStory.perform(PerformableTree.java:784)
at org.jbehave.core.embedder.PerformableTree.performCancellable(PerformableTree.java:416)
at org.jbehave.core.embedder.PerformableTree.perform(PerformableTree.java:387)
at org.jbehave.core.embedder.StoryManager$EnqueuedStory.call(StoryManager.java:291)
at org.jbehave.core.embedder.StoryManager$EnqueuedStory.call(StoryManager.java:265)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)at java.lang.Thread.run(Thread.java:748) .
Caused by: java.lang.RuntimeException: Safari could not be found in the path!
Please add the directory containing ''Safari.exe'' to your PATH environment
variable, or explicitly specify a path to Safari like this:
*safari c:\blah\Safari.exe
at org.openqa.selenium.browserlaunchers.locators.SingleBrowserLocator.findBrowserLocationOrFail(SingleBrowserLocator.java:42)
at org.openqa.selenium.safari.SafariDriverCommandExecutor.start(SafariDriverCommandExecutor.java:100)
at org.openqa.selenium.safari.SafariDriver.startClient(SafariDriver.java:76)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:119)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:144)
at org.openqa.selenium.safari.SafariDriver.<init>(SafariDriver.java:62)
at org.openqa.selenium.safari.SafariDriver.<init>(SafariDriver.java:53)
at net.thucydides.core.webdriver.strategies.InternetExplorerDriverBuilder.newInstance(InternetExplorerDriverBuilder.java:30)
at net.thucydides.core.webdriver.WebDriverFactory.newWebdriverInstance(WebDriverFactory.java:116)
... 19 more
此错误消息...
ERROR net.thucydides.core.webdriver.WebDriverFacade - FAILED TO CREATE NEW WEBDRIVER_DRIVER INSTANCE class org.openqa.selenium.ie.InternetExplorerDriver: Could not instantiate class org.openqa.selenium.ie.InternetExplorerDriver
net.thucydides.core.webdriver.UnsupportedDriverException: Could not instantiate class org.openqa.selenium.ie.InternetExplorerDriver
...意味着该程序无法 create/spawn 所需的新 InternetExplorerDriver 实例。
这个错误的主要原因是容易出错的maven命令你用来执行Serenity Test Automation Suite 如下:
mvn clean verify -Dentry_point="**/*SmokeTestSuite.java" -Dwebdriver.driver="iexplorer" -Dwebdriver.ie.driver="<my path>\IEDriverServer.exe"
最常用的 WebDriver 变体是:
-Dwebdriver.gecko.driver
- 对于geckodriver.exe
-Dwebdriver.chrome.driver
- 对于chromedriver.exe
-Dwebdriver.ie.driver
- 对于IEDriverServer.exe
但是因为您使用了不正确的参数作为-Dwebdriver.driver
以及不正确的值 因为 iexplorer
Serenity 测试自动化框架 尝试访问 [=82 的默认配置=].
解决方案
你需要删除容易出错的论点-Dwebdriver.driver="iexplorer"
,你就会成功。
webdriver.driver
是设置驱动程序的正确 Serenity 属性。我不确定 DebajanB 的 "error-prone" 是什么意思 - 通常,它可以工作或不工作,如果不工作,则是配置问题。要检查驱动程序 属性 在 Maven 中是否配置正确(您可能需要将它作为系统 属性 在 surefire 或 failsafe 插件中传递到您的测试中),看看它是否适用于 firefox。
对 webdriver.gecko.driver 等的引用告诉 Serenity 在哪里可以找到特定驱动程序的二进制文件,但它们并没有告诉 Serenity 使用哪个驱动程序。您可以配置多个驱动程序二进制文件,然后选择使用其中一个 webdriver.driver
.
Safari 不是 Serenity 的默认驱动程序,Firefox 是,所以对 Safari 的引用很好奇。这可能是来自旧版本的 defect/misleading 错误消息 - 您使用的是最新版本的 Serenity 吗?