实际上,我在尝试更改默认 webdriver 以获得宁静时正在苦苦挣扎。实际上我想在硒网格上运行我的测试。然后我在扩展 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);
但它不工作。它给出错误空指针异常。请有人给我建议如何在 Serenity 上设置硒网格?谢谢。
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)