actually I am struggling when trying to change default webdriver for serenity. actually I want to run my test on selenium grid. then I add the following code on class that extends PageObject :
DesiredCapabilities cap = DesiredCapabilities.firefox();
cap.setPlatform(Platform.WINDOWS);
cap.setCapability("marionette",false);
ProfilesIni profile = new ProfilesIni();
FirefoxProfile ffprofile = profile.
getProfile("JbehaveProfile");
cap.setCapability(FirefoxDriver.PROFILE, ffprofile);
//cap.setVersion("46.0.1");
URL url = new URL("http://localhost:4444/wd/hub");
WebDriver driver = new RemoteWebDriver(url,cap);
Serenity.getWebdriverManager().registerDriver(driver);
Serenity.getWebdriverManager().setCurrentDriver(driver);
but it is not working. it giving error null pointer exception. please someone give me advice how to set up selenium grid on Serenity? thanks.
java.lang.NullPointerException
at testSeleniumGrid.pages.DictionaryPage.setProfileFirefox(DictionaryPage.java:70)
at testSeleniumGrid.steps.serenity.EndUserSteps.is_the_home_page(EndUserSteps.java:35)
at testSeleniumGrid.steps.serenity.EndUserSteps$$EnhancerByCGLIB$$6d97ef9c.CGLIB$is_the_home_page$3(<generated>)
at testSeleniumGrid.steps.serenity.EndUserSteps$$EnhancerByCGLIB$$6d97ef9c$$FastClassByCGLIB$$53eb4f32.invoke(<generated>)
at net.sf.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:228)
at net.thucydides.core.steps.StepInterceptor.invokeMethod(StepInterceptor.java:348)
at net.thucydides.core.steps.StepInterceptor.executeTestStepMethod(StepInterceptor.java:333)
at net.thucydides.core.steps.StepInterceptor.runTestStep(StepInterceptor.java:308)
at net.thucydides.core.steps.StepInterceptor.testStepResult(StepInterceptor.java:130)
at net.thucydides.core.steps.StepInterceptor.intercept(StepInterceptor.java:57)
at testSeleniumGrid.steps.serenity.EndUserSteps$$EnhancerByCGLIB$$6d97ef9c.is_the_home_page(<generated>)
at testSeleniumGrid.steps.DefinitionSteps.givenTheUserIsOnTheWikionaryHomePage(DefinitionSteps.java:17)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.jbehave.core.steps.StepCreator$ParametrisedStep.perform(StepCreator.java:595)
at org.jbehave.core.embedder.StoryRunner$FineSoFar.run(StoryRunner.java:566)
at org.jbehave.core.embedder.StoryRunner.runStepsWhileKeepingState(StoryRunner.java:546)
at org.jbehave.core.embedder.StoryRunner.runScenarioSteps(StoryRunner.java:510)
at org.jbehave.core.embedder.StoryRunner.runStepsWithLifecycle(StoryRunner.java:476)
at org.jbehave.core.embedder.StoryRunner.runCancellable(StoryRunner.java:336)
at org.jbehave.core.embedder.StoryRunner.run(StoryRunner.java:239)
at org.jbehave.core.embedder.StoryRunner.run(StoryRunner.java:182)
at org.jbehave.core.embedder.StoryManager$EnqueuedStory.call(StoryManager.java:266)
at org.jbehave.core.embedder.StoryManager$EnqueuedStory.call(StoryManager.java:233)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)
If you are working in a local mode i.e., not using the Grid, for you to be able to switch browsers you merely pass the browser flavor via the JVM argument -Dwebdriver.driver=chrome
. Please make sure that you have corresponding driver binaries [IEDriverServer.exe (for Internet explorer), ChromeDriver.exe (for Chrome) and Geckodriver.exe (for newer versions of Firefox and if using Selenium 3.0.1 )
If you are making use of a Selenium Grid wherein the Grid Node (Not the Grid Hub) runs on a different machine i.e., lets say you are kicking off your Serenity tests from MachineA and your Grid node is running on MachineC, please ensure that you have added the location of the IEDriverServer/ChromeDriver/GeckoDriver binaries in to your PATH environment variable of MachineC (i.e., the machine on which your Selenium node is running).
More instructions with respect to setting up the binary and working with it.
Setting up the Marionette executable
)In order for you to be able to use Serenity and point it to a Grid you would need to use the JVM argument -Dwebdriver.remote.url=http://GridIp:GridPort/wd/hub
If you are looking for some general instructions on how to setup the Selenium Grid and work with it please refer to the below links :
All the arguments for Serenity are found in ThucydidesSystemProperty.java. The translation logic seems to be change the enum to lower case, replace all -
with a .
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments