ContributionsMost RecentMost LikesSolutionsIs it possible to get scenario inside the step in Cucumber? I need to make screenshot inside the step on specific place. It means not on @BeforeStep nor on @AfterStep. I need to call // public void someStep(Scenario scenario) // This does not work public void someStep() { page.openUrl(); scenario.attach(screenshot(), "image/png", fileName1); page.doSomething(); scenario.attach(screenshot(), "image/png", fileName2); page.doSomethingElse(); } But I am not able to get current scenario related to the step execution. Is it possible or not? I tried to call it like someStep(Scenarion scenario) but it throws an error. Thanks for any help. Re: -- rerun failed scenarios Thanks a lot. Re: -- rerun failed scenarios I use cucumber-jvm. Is there an solution for me? -- rerun failed scenarios I found a lot of articles about rerun the failed tests but none of them satisfies my needs. The closest solution I found is here. But I am not quite sure about this solution. Especially because of order and parallel runs. I would like to rerun failed scenario immediately when it fails. So the first question is if it is possible. It sounds like clean straightforward use case but I cant not find any documentation to it. I found also this article which mention --retry flag but the link to documentation returnss error 521. So I would like to know where I could find something about --retry flag. Thanks for any help I am little lost in it for now. SolvedRe: Paralel test timeout error I had the scriptTimeout set to 120 seconds. As I remove the parallel run the problem is for 95% gone. The problem was in unlimited count of threads. This is working version for my VPS <parallel>methods</parallel> <threadCount>2</threadCount> <perCoreThreadCount>false</perCoreThreadCount> Thanks for help. Re: Paralel test timeout error Can I ask which timeouts do you mean? Also how to set up number of parallel test properly? My settings comes from documentation. I did not find any other resources about it. Paralel test timeout error I have few tests which run in parallel via maven surefire plugin. Sometimes about 8:1 some test crashes on error: org.openqa.selenium.ScriptTimeoutException: java.util.concurrent.TimeoutException It seems it is related to parallel run but I don't know how to fix it. Tests run against Selenium standalone server 4, which is on the same server as the test runner and teste application. Here is maven surefire plugin implemantation: <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <version>3.0.0-M5</version> <configuration> <parallel>methods</parallel> <useUnlimitedThreads>true</useUnlimitedThreads> <includes> <include>${category}</include> </includes> </configuration> </plugin> and here is the whole error log: org.openqa.selenium.ScriptTimeoutException: java.util.concurrent.TimeoutException Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:17:03' System info: host: 'vmi503579.contaboserver.net', ip: '127.0.1.1', os.name: 'Linux', os.arch: 'amd64', os.version: '5.4.0-70-generic', java.version: '11.0.10' selenide.remote: http://127.0.0.1:4444 Driver info: org.openqa.selenium.remote.RemoteWebDriver selenide.url: https://tatrytec.eu Capabilities {acceptInsecureCerts: true, browserName: chrome, browserVersion: 89.0.4389.114, chrome: {chromedriverVersion: 89.0.4389.23 (61b08ee2c5002..., userDataDir: /tmp/.com.google.Chrome.rtlmvi}, goog:chromeOptions: {debuggerAddress: localhost:42525}, javascriptEnabled: true, networkConnectionEnabled: false, pageLoadStrategy: normal, platform: LINUX, platformName: LINUX, proxy: Proxy(), se:cdp: http://173.249.58.30:4444/s..., setWindowRect: true, strictFileInteractability: false, timeouts: {implicit: 0, pageLoad: 300000, script: 30000}, unhandledPromptBehavior: dismiss and notify, webauthn:extension:largeBlob: true, webauthn:virtualAuthenticators: true} selenide.baseUrl: https://tatrytec.eu Session ID: 9eacdc08d0171e3ebc29cd2e7ae64cfc at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:490) at org.openqa.selenium.remote.http.W3CHttpResponseCodec.createException(W3CHttpResponseCodec.java:187) at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:122) at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:49) at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:158) at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:552) at org.openqa.selenium.remote.RemoteWebDriver.get(RemoteWebDriver.java:277) at org.openqa.selenium.remote.RemoteWebDriver$RemoteNavigation.to(RemoteWebDriver.java:857) at com.codeborne.selenide.drivercommands.Navigator.lambda$navigateTo$0(Navigator.java:70) at com.codeborne.selenide.logevents.SelenideLogger.run(SelenideLogger.java:139) at com.codeborne.selenide.drivercommands.Navigator.navigateTo(Navigator.java:66) at com.codeborne.selenide.drivercommands.Navigator.open(Navigator.java:30) at com.codeborne.selenide.SelenideDriver.open(SelenideDriver.java:86) at com.codeborne.selenide.Selenide.open(Selenide.java:49) at steps.BaseSteps.openPage(BaseSteps.java:68) at steps.admin.AdminPageSteps.logInAndOpenAdminPage(AdminPageSteps.java:21) at ✽.User is logged in and is on admin page(file:///home/tatrytec/selenium-tests/cucumber.tatrytec.eu/src/test/features/admin/CreateEditCategory.feature:28) Screenshot Thanks a lot for any help. I really don't know what is the problem. Re: Where to store common logic like login No did not find it. But found a some mentions which say the login should be the part of each scenario. This is something opposite. Thanks. Where to store common logic like login I have a few features which test resources which needs to login. Every feature has its own steps class with concrete steps. But each of this features needs to make login, so I tried to make baseSteps which contains @Given("Login") public void login() { new HomepagePage().login(conf.getString("login.email"), conf.getString("login.password")); } But as I see Cucumber does not allow inheritance of classes with steps and hooks. It throws me an error: Unable to start Cucumber io.cucumber.java.InvalidMethodException: You're not allowed to extend classes that define Step Definitions or hooks. class steps.admin.CreateEditArticleSteps extends class steps.BaseSteps What is the best practice to achieve this logic? I dont want to have login method in every steps class. SolvedRe: How to write hook with annotation and order the solution is @After(value="@last", order=1)