serenity-bdd / serenity-core

Serenity BDD is a test automation library designed to make writing automated acceptance tests easier, and more fun.
http://serenity-bdd.info
Other
723 stars 518 forks source link

Could not instantiate class net.thucydides.core.webdriver.ProvidedDriver #3525

Open realsskr opened 2 months ago

realsskr commented 2 months ago

What happened?

Am getting this error while initializing custom browser

Serenity.properties file webdriver.driver = provided webdriver.provided.type = mydriver webdriver.provided.mydriver = starter.DriverFactory thucydides.driver.capabilities = mydriver

DriverFactory Implemantation public class DriverFactory implements DriverSource {

@Override
public WebDriver newDriver()
{

    String browser = System.getProperty("browser");

    if (browser.equalsIgnoreCase("chrome"))
    {
        return new ChromeDriver();
    }
    else
    {
        System.setProperty("webdriver.gecko.driver","C:\\Users\\Downloads\\geckodriver.exe");
        return new FirefoxDriver();}
}

@Override
public boolean takesScreenshots()
{
    return true;
}

}


Serenity version : 4.1.12


Console logs

net.thucydides.core.webdriver.DriverConfigurationError: Could not instantiate class net.thucydides.core.webdriver.ProvidedDriver

at net.thucydides.core.webdriver.WebDriverFacade.newDriverInstance(WebDriverFacade.java:193)
at net.thucydides.core.webdriver.WebDriverFacade.newProxyDriver(WebDriverFacade.java:181)
at net.thucydides.core.webdriver.WebDriverFacade.getProxiedDriver(WebDriverFacade.java:132)
at net.thucydides.core.webdriver.WebDriverFacade.get(WebDriverFacade.java:221)
at net.serenitybdd.core.pages.PageObject.openPageAtUrl(PageObject.java:985)
at net.serenitybdd.core.pages.PageObject.open(PageObject.java:883)
at net.serenitybdd.core.pages.PageObject.open(PageObject.java:871)
at net.serenitybdd.screenplay.actions.OpenPageFromClass.performAs(OpenPageFromClass.java:30)
at net.serenitybdd.screenplay.actions.OpenPageFromClass$ByteBuddy$Hdsbu28t.performAs$accessor$e3tYUkDN(Unknown Source)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at net.thucydides.core.steps.StepInterceptor.invokeMethod(StepInterceptor.java:524)
at net.thucydides.core.steps.StepInterceptor.executeTestStepMethod(StepInterceptor.java:504)
at net.thucydides.core.steps.StepInterceptor.runTestStep(StepInterceptor.java:476)
at net.thucydides.core.steps.StepInterceptor.runOrSkipMethod(StepInterceptor.java:218)
at net.thucydides.core.steps.StepInterceptor.testStepResult(StepInterceptor.java:205)
at net.thucydides.core.steps.StepInterceptor.intercept(StepInterceptor.java:93)
at net.thucydides.core.steps.ProxyConfiguration$InterceptorDispatcher.intercept(ProxyConfiguration.java:51)
at net.serenitybdd.screenplay.actions.OpenPageFromClass$ByteBuddy$Hdsbu28t.performAs(Unknown Source)
at net.serenitybdd.screenplay.Actor.performTask(Actor.java:299)
at net.serenitybdd.screenplay.Actor.perform(Actor.java:274)
at net.serenitybdd.screenplay.Actor.attemptsTo(Actor.java:215)
at net.serenitybdd.screenplay.Actor.attemptsTo(Actor.java:222)
at net.serenitybdd.screenplay.AnonymousPerformable.performAs(AnonymousPerformable.java:25)
at net.serenitybdd.screenplay.AnonymousTask$ByteBuddy$4STusMkF.performAs$accessor$IuvRaja9(Unknown Source)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at net.thucydides.core.steps.StepInterceptor.invokeMethod(StepInterceptor.java:524)
at net.thucydides.core.steps.StepInterceptor.executeTestStepMethod(StepInterceptor.java:504)
at net.thucydides.core.steps.StepInterceptor.runTestStep(StepInterceptor.java:476)
at net.thucydides.core.steps.StepInterceptor.runOrSkipMethod(StepInterceptor.java:218)
at net.thucydides.core.steps.StepInterceptor.testStepResult(StepInterceptor.java:205)
at net.thucydides.core.steps.StepInterceptor.intercept(StepInterceptor.java:93)
at net.thucydides.core.steps.ProxyConfiguration$InterceptorDispatcher.intercept(ProxyConfiguration.java:51)
at net.serenitybdd.screenplay.AnonymousTask$ByteBuddy$4STusMkF.performAs(Unknown Source)
at net.serenitybdd.screenplay.Actor.performTask(Actor.java:299)
at net.serenitybdd.screenplay.Actor.perform(Actor.java:274)
at net.serenitybdd.screenplay.Actor.attemptsTo(Actor.java:215)
at net.serenitybdd.screenplay.Actor.attemptsTo(Actor.java:222)
at net.serenitybdd.screenplay.Actor.wasAbleTo(Actor.java:193)
at starter.stepdefinitions.SearchStepDefinitions.researchingThings(SearchStepDefinitions.java:16)
at ✽.Sergey is researching things on the internet(classpath:features/search/search_by_keyword.feature:5)

Caused by: net.thucydides.core.webdriver.DriverConfigurationError: After several attempts, could not instantiate new WebDriver instance of type class net.thucydides.core.webdriver.ProvidedDriver (Could not instantiate the custom webdriver provider of type mydriver). See below for more details. at net.thucydides.core.webdriver.WebDriverFactory.waitThenRetry(WebDriverFactory.java:184) at net.thucydides.core.webdriver.WebDriverFactory.waitThenRetry(WebDriverFactory.java:195) at net.thucydides.core.webdriver.WebDriverFactory.waitThenRetry(WebDriverFactory.java:195) at net.thucydides.core.webdriver.WebDriverFactory.waitThenRetry(WebDriverFactory.java:195) at net.thucydides.core.webdriver.WebDriverFactory.waitThenRetry(WebDriverFactory.java:195) at net.thucydides.core.webdriver.WebDriverFactory.waitThenRetry(WebDriverFactory.java:195) at net.thucydides.core.webdriver.WebDriverFactory.waitThenRetry(WebDriverFactory.java:195) at net.thucydides.core.webdriver.WebDriverFactory.waitThenRetry(WebDriverFactory.java:170) at net.thucydides.core.webdriver.WebDriverFactory.newWebdriverInstance(WebDriverFactory.java:144) at net.thucydides.core.webdriver.WebDriverFacade.newDriverInstance(WebDriverFacade.java:190) at net.thucydides.core.webdriver.WebDriverFacade.newProxyDriver(WebDriverFacade.java:181) at net.thucydides.core.webdriver.WebDriverFacade.getProxiedDriver(WebDriverFacade.java:132) at net.thucydides.core.webdriver.WebDriverFacade.get(WebDriverFacade.java:221) at net.serenitybdd.core.pages.PageObject.openPageAtUrl(PageObject.java:985) at net.serenitybdd.core.pages.PageObject.open(PageObject.java:883) at net.serenitybdd.core.pages.PageObject.open(PageObject.java:871) at net.serenitybdd.screenplay.actions.OpenPageFromClass.performAs(OpenPageFromClass.java:30) at net.serenitybdd.screenplay.actions.OpenPageFromClass$ByteBuddy$Hdsbu28t.performAs$accessor$e3tYUkDN(Unknown Source) at java.base/java.lang.reflect.Method.invoke(Method.java:566) at net.thucydides.core.steps.StepInterceptor.invokeMethod(StepInterceptor.java:524) at net.thucydides.core.steps.StepInterceptor.executeTestStepMethod(StepInterceptor.java:504) at net.thucydides.core.steps.StepInterceptor.runTestStep(StepInterceptor.java:476) at net.thucydides.core.steps.StepInterceptor.runOrSkipMethod(StepInterceptor.java:218) at net.thucydides.core.steps.StepInterceptor.testStepResult(StepInterceptor.java:205) at net.thucydides.core.steps.StepInterceptor.intercept(StepInterceptor.java:93) at net.thucydides.core.steps.ProxyConfiguration$InterceptorDispatcher.intercept(ProxyConfiguration.java:51) at net.serenitybdd.screenplay.actions.OpenPageFromClass$ByteBuddy$Hdsbu28t.performAs(Unknown Source) at net.serenitybdd.screenplay.Actor.performTask(Actor.java:299) at net.serenitybdd.screenplay.Actor.perform(Actor.java:274) at net.serenitybdd.screenplay.Actor.attemptsTo(Actor.java:215) at net.serenitybdd.screenplay.Actor.attemptsTo(Actor.java:222) at net.serenitybdd.screenplay.AnonymousPerformable.performAs(AnonymousPerformable.java:25) at net.serenitybdd.screenplay.AnonymousTask$ByteBuddy$4STusMkF.performAs$accessor$IuvRaja9(Unknown Source) at java.base/java.lang.reflect.Method.invoke(Method.java:566) at net.thucydides.core.steps.StepInterceptor.invokeMethod(StepInterceptor.java:524) at net.thucydides.core.steps.StepInterceptor.executeTestStepMethod(StepInterceptor.java:504) at net.thucydides.core.steps.StepInterceptor.runTestStep(StepInterceptor.java:476) at net.thucydides.core.steps.StepInterceptor.runOrSkipMethod(StepInterceptor.java:218) at net.thucydides.core.steps.StepInterceptor.testStepResult(StepInterceptor.java:205) at net.thucydides.core.steps.StepInterceptor.intercept(StepInterceptor.java:93) at net.thucydides.core.steps.ProxyConfiguration$InterceptorDispatcher.intercept(ProxyConfiguration.java:51) at net.serenitybdd.screenplay.AnonymousTask$ByteBuddy$4STusMkF.performAs(Unknown Source) at net.serenitybdd.screenplay.Actor.performTask(Actor.java:299) at net.serenitybdd.screenplay.Actor.perform(Actor.java:274) at net.serenitybdd.screenplay.Actor.attemptsTo(Actor.java:215) at net.serenitybdd.screenplay.Actor.attemptsTo(Actor.java:222) at net.serenitybdd.screenplay.Actor.wasAbleTo(Actor.java:193) at starter.stepdefinitions.SearchStepDefinitions.researchingThings(SearchStepDefinitions.java:16) at java.base/java.lang.reflect.Method.invoke(Method.java:566) at io.cucumber.java.Invoker.doInvoke(Invoker.java:66) at io.cucumber.java.Invoker.invoke(Invoker.java:24) at io.cucumber.java.AbstractGlueDefinition.invokeMethod(AbstractGlueDefinition.java:47) at io.cucumber.java.JavaStepDefinition.execute(JavaStepDefinition.java:29) at io.cucumber.core.runner.CoreStepDefinition.execute(CoreStepDefinition.java:66) at io.cucumber.core.runner.PickleStepDefinitionMatch.runStep(PickleStepDefinitionMatch.java:63) at io.cucumber.core.runner.ExecutionMode$1.execute(ExecutionMode.java:10) at io.cucumber.core.runner.TestStep.executeStep(TestStep.java:81) at io.cucumber.core.runner.TestStep.run(TestStep.java:53) at io.cucumber.core.runner.PickleStepTestStep.run(PickleStepTestStep.java:51) at io.cucumber.core.runner.TestCase.run(TestCase.java:84) at io.cucumber.core.runner.Runner.runPickle(Runner.java:75) at io.cucumber.junit.platform.engine.CucumberEngineExecutionContext.lambda$runTestCase$4(CucumberEngineExecutionContext.java:112) at io.cucumber.core.runtime.CucumberExecutionContext.lambda$runTestCase$5(CucumberExecutionContext.java:136) at io.cucumber.core.runtime.RethrowingThrowableCollector.executeAndThrow(RethrowingThrowableCollector.java:23) at io.cucumber.core.runtime.CucumberExecutionContext.runTestCase(CucumberExecutionContext.java:136) at io.cucumber.junit.platform.engine.CucumberEngineExecutionContext.runTestCase(CucumberEngineExecutionContext.java:109) at io.cucumber.junit.platform.engine.NodeDescriptor$PickleDescriptor.execute(NodeDescriptor.java:168) at io.cucumber.junit.platform.engine.NodeDescriptor$PickleDescriptor.execute(NodeDescriptor.java:90) at java.base/java.util.concurrent.RecursiveAction.exec(RecursiveAction.java:189) at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:290) at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1020) at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1656) at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1594) at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:183) Caused by: java.lang.RuntimeException: Could not instantiate the custom webdriver provider of type mydriver at net.serenitybdd.core.webdriver.driverproviders.ProvidedDriverProvider.newInstance(ProvidedDriverProvider.java:24) at net.thucydides.core.webdriver.WebDriverFactory.createWebDriver(WebDriverFactory.java:154) at net.thucydides.core.webdriver.WebDriverFactory.waitThenRetry(WebDriverFactory.java:191) ... 72 more Caused by: org.openqa.selenium.SessionNotCreatedException: Could not start a new session. Response code 500. Message: Expected browser binary location, but unable to find binary in default location, no 'moz:firefoxOptions.binary' capability provided, and no binary flag set on the command line Host info: host: 'TC6SKZ4V3', ip: '10.132.5.102' Build info: version: '4.24.0', revision: '748ffc9bc3' System info: os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '11.0.22' Driver info: org.openqa.selenium.firefox.FirefoxDriver Command: [null, newSession {capabilities=[Capabilities {acceptInsecureCerts: true, browserName: firefox, moz:debuggerAddress: true, moz:firefoxOptions: {prefs: {remote.active-protocols: 3}}}]}] at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:114) at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:75) at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:61) at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:162) at org.openqa.selenium.remote.service.DriverCommandExecutor.invokeExecute(DriverCommandExecutor.java:216) at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:174) at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:545) at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:245) at org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:174) at org.openqa.selenium.firefox.FirefoxDriver.(FirefoxDriver.java:155) at org.openqa.selenium.firefox.FirefoxDriver.(FirefoxDriver.java:150) at org.openqa.selenium.firefox.FirefoxDriver.(FirefoxDriver.java:132) at org.openqa.selenium.firefox.FirefoxDriver.(FirefoxDriver.java:127) at org.openqa.selenium.firefox.FirefoxDriver.(FirefoxDriver.java:112) at org.openqa.selenium.firefox.FirefoxDriver.(FirefoxDriver.java:102) at starter.DriverFactory.newDriver(DriverFactory.java:31) at net.serenitybdd.core.webdriver.driverproviders.ProvidedDriverProvider.newInstance(ProvidedDriverProvider.java:22) ... 74 more

What did you expect to happen?

I expect the driver to launch

Serenity BDD version

4.1.12

JDK version

11

Execution environment

am using windows 10 and trying to execute tests on Chrome and Firefox

How to reproduce the bug.

NA

How can we make it happen?

Add it to the Serenity BDD backlog and wait for a volunteer to pick it up

wakaleo commented 2 months ago

This is a problem with your custom driver code:

Caused by: org.openqa.selenium.SessionNotCreatedException: Could not start a new session. Response code 500. Message: Expected browser binary location, but unable to find binary in default location, no 'moz:firefoxOptions.binary' capability provided, and no binary flag set on the command line