Selenium Cucumber Java BDD Framework 11 | How to run from CommandLine

  Рет қаралды 57,293

Automation Step by Step

Automation Step by Step

Күн бұрын

Пікірлер: 135
@ajinkyadhoke4713
@ajinkyadhoke4713 2 жыл бұрын
Usually MNC'S give Training but in that they also didn't teach this, Thanks for this Hidden jam Raghav, I appreciate your hard work .......💯💯💯
@RaghavPal
@RaghavPal 2 жыл бұрын
Thanks a lot
@muhammadasifansari1031
@muhammadasifansari1031 3 жыл бұрын
I would definitely recommend everyone who is a beginner in this automation field like me. These videos helped me a lot in my projects... ❤️❤️
@RaghavPal
@RaghavPal 3 жыл бұрын
Great to know Asif, can check all here - automationstepbystep.com/
@muhammadasifansari1031
@muhammadasifansari1031 3 жыл бұрын
@@RaghavPal thanks a lot ..I will check it. 👍🏼
@sunshineandsmiles2k6
@sunshineandsmiles2k6 Жыл бұрын
Hi Raghav: Thank you so much for sharing your amazing courses. I love them and am learning soooo much.
@RaghavPal
@RaghavPal Жыл бұрын
Glad you like them David
@deepeshjain2742
@deepeshjain2742 Жыл бұрын
Hey Raghav: Thank you so much for sharing this amazing courses....
@RaghavPal
@RaghavPal Жыл бұрын
Glad you like them!
@rahuljadhav3409
@rahuljadhav3409 Жыл бұрын
Hi Raghav, thanks you very much for informative video. I really appreciate this session it's simple as you explain it.
@RaghavPal
@RaghavPal Жыл бұрын
You're most welcome Rahul
@jagratsahoo6885
@jagratsahoo6885 2 жыл бұрын
Thanks Raghav. Appreciate your efforts
@RaghavPal
@RaghavPal 2 жыл бұрын
Most welcome
@SarangHoley
@SarangHoley 4 жыл бұрын
Thanks, @Raghav for taking this topic into consideration & making a video on this. Its really helpful 😊👍👍
@RaghavPal
@RaghavPal 4 жыл бұрын
Glad you liked it Sarang
@abdulnazer3136
@abdulnazer3136 3 жыл бұрын
Thanks a lot Raghav for this helpful tutorial.
@RaghavPal
@RaghavPal 3 жыл бұрын
Most welcome Abdul
@vanithasadhu5178
@vanithasadhu5178 Жыл бұрын
Hi Raghav sir, The videos are quite helpful. I have couple of questions: 1) Can the background be used across multiple feature files? 2) In my project I have to cache couple of values in run time and use it in across multiple feature files. Is it possible? If so could you please provide a video for it?
@RaghavPal
@RaghavPal Жыл бұрын
Hi Vanitha, 1) Yes, you can use the Background keyword in Cucumber to define common steps that should be executed before each scenario in a feature file. The Background steps will be executed before every scenario in that feature file. If you want to use the same Background steps across multiple feature files, you can define the Background in a separate file and then include it in each of the feature files that require it. To do this, create a new feature file and define the Background steps in it. Then, use the Scenario Outline keyword to create a template for the scenarios that will use the Background steps. You can also include multiple background files in a single feature file by including multiple Background sections. 2) Yes, you can cache values in runtime and use them across multiple feature files in Cucumber. One way to do this is to use a static class to store the values that need to be shared. Eg: public class TestContext { private static Map contextMap = new HashMap(); public static void setContext(String key, Object value) { contextMap.put(key, value); } public static Object getContext(String key) { return contextMap.get(key); } } In this example, TestContext is a static class that provides two methods for storing and retrieving values. The setContext method takes a key and a value and stores them in a Map. The getContext method takes a key and returns the corresponding value from the Map To cache a value, you can call the setContext method and provide a key and a value: TestContext.setContext("myKey", "myValue"); To retrieve the cached value in another step or feature file, you can call the getContext method and provide the key: Object myValue = TestContext.getContext("myKey"); You can use this approach to cache values in runtime and share them across multiple feature files. Just be sure to choose a unique key for each value you want to store, so that you can retrieve it later using the same key.
@vanithasadhu5178
@vanithasadhu5178 Жыл бұрын
@@RaghavPal Thank you very much for the explanation Raghav sir!! I will implement it.
@krishnamoorthynatarajan7983
@krishnamoorthynatarajan7983 4 жыл бұрын
Great Info. Very useful and clearly explained. Thanks Raghav.🙌
@RaghavPal
@RaghavPal 4 жыл бұрын
Most welcome Krishnamoorthy
@weleyam
@weleyam 2 жыл бұрын
Hi Raghav, I using this command on cli mvn test -Dcucumber.options="-tags @regressionUI" but facing an issue like this [ERROR] Unknown lifecycle phase ".options=-tags @regressionUI". You must specify a valid lifecycle phase or a goal in the format : or :[:]:. Available lifecycle phases are: validate, initialize, generate-sources, process-sources, generate-resourc es, process-resources, compile, process-classes, generate-test-sources, process-test-sources, generate-test-resources, process-test-resources, test-compile, proces s-test-classes, test, prepare-package, package, pre-integration-test, integration-test, post-integration-test, verify, install, deploy, pre-clean, clean, post-clea n, pre-site, site, post-site, site-deploy. :( :( :(
@RaghavPal
@RaghavPal 2 жыл бұрын
Hi Wele, first run the command mvn verify check if there are any errors Also check github.com/cucumber/cucumber-jvm/issues/797
@krishnasai1817
@krishnasai1817 Жыл бұрын
@@RaghavPal Hi Raghav, Im also facing this error i tried mvn verify but i didnt saw any errors in mvn verify.
@UCIUbaf3b8lN7Q5GA8qO
@UCIUbaf3b8lN7Q5GA8qO Жыл бұрын
If anyone has trouble with the commands execution those are the new command (at least for junit), I didn't check for testNG : For example, if you are using Maven and want to run a subset of scenarios tagged with @smoke: mvn test -Dcucumber.filter.tags="@smoke" Supported properties are: cucumber.ansi-colors.disabled= # true or false. default: false cucumber.execution.dry-run= # true or false. default: false cucumber.execution.limit= # number of scenarios to execute (CLI only). cucumber.execution.order= # lexical, reverse, random or random:[seed] (CLI only). default: lexical cucumber.execution.wip= # true or false. default: false. cucumber.features= # comma separated paths to feature files. example: path/to/example.feature, path/to/other.feature cucumber.filter.name= # regex. example: .*Hello.* cucumber.filter.tags= # tag expression. example: @smoke and not @slow cucumber.glue= # comma separated package names. example: com.example.glue cucumber.plugin= # comma separated plugin strings. example: pretty, json:path/to/report.json cucumber.object-factory= # object factory class name. example: com.example. Also a question for you @Raghav, do you know how can I cancel the execution for the tests inside a Test Class? The problem is that if I want to execute only a feature, it executes also all of the @Test annotations from project, I have a separate class where I have some tests like this, ex: @Test public void loginPositiveNegativeTesting() throws IOException { Assert.assertTrue("Searching for something is not successful", googleSearch.searchEngine("Test Login - Practice Test Automation")); }
@RaghavPal
@RaghavPal Жыл бұрын
Thanks for adding
@mostafanader8668
@mostafanader8668 4 жыл бұрын
Hey Raghav, I really appreciate this session its as simple as you explain it ! Can you tell me when will the hooks session be available ?
@RaghavPal
@RaghavPal 4 жыл бұрын
Thanks Mostafa, will plan soon
@amitmalik7804
@amitmalik7804 2 жыл бұрын
Thanks Raghav for this amazing video. I have an issue with my project when run through cmd, scenario get executed but shows 0 test 0 fail. Could you please help in troubleshooting.
@RaghavPal
@RaghavPal 2 жыл бұрын
Hi Amit, Try to rename the TestRunner file to something like - RunTest.java put file in src/test/java/RunTest.java pls check if this helps - stackoverflow.com/questions/31117370/no-tests-run-0-failures-0-errors-0-skipped-0-even-that-cucumber-test
@amitmalik7804
@amitmalik7804 2 жыл бұрын
@@RaghavPal Thanks Raghav, worked for me.
@sanjaypatel5677
@sanjaypatel5677 3 жыл бұрын
Superb way to teach
@RaghavPal
@RaghavPal 3 жыл бұрын
Thanks Sanjay
@deepika5137
@deepika5137 3 жыл бұрын
Raghav thanks for your wonderful videos Is there any lecture helping on entering OTP thru automation script
@RaghavPal
@RaghavPal 3 жыл бұрын
Not yet Deepika
@rebelScience
@rebelScience 3 жыл бұрын
You mentioned but did not show how to run a specific runner. If it is, for example, in /src/test/java/runners/MainRunner.java
@RaghavPal
@RaghavPal 3 жыл бұрын
I will check and add this
@AxmLolit
@AxmLolit 2 жыл бұрын
Nice video, thanks for explaining in details. One query: how do I pass environment parameter such INT, REL, UAT when I have to execute same test in diff environments?
@RaghavPal
@RaghavPal 2 жыл бұрын
Hi Lolit, you can parameterize the values and can take it from an external source based on the env you are using
@AxmLolit
@AxmLolit 2 жыл бұрын
@@RaghavPal Thanks for quick response, if you have any videos/documentation for such configuration please do share. I want to pass some input data like date from CI tools along with env variable.
@RaghavPal
@RaghavPal 2 жыл бұрын
Not as of now, can check some online examples
@saikiranpalugula802
@saikiranpalugula802 4 жыл бұрын
Hi Raghav, thank you very much for the informative video. At 8:04 i observed couple of packages like "steps for background" and "steps for hooks" and multiple test runner files as well. In which video did you explain that? Please let us know I saw the hooks video but these packages were not present in that one.
@RaghavPal
@RaghavPal 4 жыл бұрын
I will add these sessions soon Saikiran
@saikiranpalugula802
@saikiranpalugula802 4 жыл бұрын
@@RaghavPal Thank you very much Raghav..
@jayantamandal9732
@jayantamandal9732 4 жыл бұрын
Thanks a lot Raghav.Can you please make a video on allure and extent report integration with Cucumber
@RaghavPal
@RaghavPal 4 жыл бұрын
Hi Jayanta, sure I will plan
@DestroyedRuben
@DestroyedRuben Жыл бұрын
Hi, Raghav! Thanks for your videos, they are awesome! I have a problem. When I create a new project just like you and then run the "mvn test" command on the CMD, the Build is Successful but no test were executed at all. I've tried with an old project and it worked fine, I just don't understand why it is not working with the new project. I checked the POM and it was exactly the same as my old project, not sure what is happening here. I'm using IntelliJ instead of Eclipse but I don't think this has something to do with my problem
@DestroyedRuben
@DestroyedRuben Жыл бұрын
Nevermind, my problem was that my runner file was called "Runner". After refactoring it to "TestRunner" everything seems to be working fine
@RaghavPal
@RaghavPal Жыл бұрын
Great, all the best Ruben
@sappanimuthubalasubramania1572
@sappanimuthubalasubramania1572 3 жыл бұрын
Hi Raghav, Hope all are well, This is amazing video but I have one doubt. I.e, here we are using the multiple -Dcucumber.options but it runs the only one option(35:18 to 36:05), is it correct. Then what is the difference between multiple options and a single option? Please clarify the same. Thanks in advance.
@RaghavPal
@RaghavPal 3 жыл бұрын
Hi, it should take all options, I will check again and update
@raghavaraparthi5184
@raghavaraparthi5184 Жыл бұрын
Hi Raghva, i'm unable to work from cmd line execution, it still shows the build failure, i have gone through the steps as mentioned.
@RaghavPal
@RaghavPal Жыл бұрын
Hi Raghava If you are experiencing build failures when running your Selenium Cucumber Java tests from the command line, there could be several possible reasons. Here are a few things to check: Make sure you have set up the correct environment variables in your system. You need to set the JAVA_HOME and PATH variables to the Java installation directory and the bin folder of your Maven installation, respectively. Check that you have set up the pom.xml file correctly. Make sure that all the required dependencies are added in the section of the pom.xml file. Verify that your Cucumber feature file is located in the correct directory and that the @CucumberOptions annotation in your test runner class specifies the correct path to the feature file. Ensure that you are running the tests with the correct command. In most cases, the command to run Cucumber tests with Maven is mvn test. Make sure that you are executing this command from the correct directory. Check that you have properly installed the necessary drivers for your Selenium tests. For example, if you are running your tests on Chrome, you need to have the ChromeDriver executable installed on your system and referenced in your code. If you have checked all of the above and are still experiencing build failures, it could be helpful to provide more specific details about the error message you are receiving in order to troubleshoot the issue further.
@mayurigawali5173
@mayurigawali5173 Жыл бұрын
hey i am getting an error in console that is MojoFailureException what should i do
@RaghavPal
@RaghavPal Жыл бұрын
Hi Mayuri, have you installed cucumber eclipse plugin can try updating cucumber ver in pom.xml also pls check if this helps: stackoverflow.com/questions/55322532/selenium-cucumber-feature-file-is-not-enabling-in-eclipse stackoverflow.com/questions/7927997/how-to-fix-mojofailureexception-while-using-spring-to-build-web-project
@mushfiquazaman9597
@mushfiquazaman9597 3 жыл бұрын
​ @Automation Step by Step - Raghav Pal I am running ----- mvn test -Dcucumber.options="src/test/resources/Features/loginDev.feature". It is showing BUILD success, but not showing any test results, like your video showing. Could u please le me know, why?
@RaghavPal
@RaghavPal 3 жыл бұрын
Hi Mushfiqua, pls check the naming convention of the testrunner class it should be Test* *Test TestCase Check 6:07
@mushfiquazaman9597
@mushfiquazaman9597 3 жыл бұрын
@@RaghavPal ​ @Automation Step by Step - Raghav Pal Thanks Raghav again. My runner class was named as BAFS Test Runner. I will refactor it on Monday.
@mushfiquazaman9597
@mushfiquazaman9597 3 жыл бұрын
@@RaghavPal Yes Raghav, After refactoring the BAFSTestRunner toTestBAFSRunner, it worked. Thank you very much for your suggestion
@amitbhardwaj7824
@amitbhardwaj7824 4 жыл бұрын
Nice video plz make video on some more topics
@RaghavPal
@RaghavPal 4 жыл бұрын
Sure I will Amit
@rahuldahikar2783
@rahuldahikar2783 4 жыл бұрын
Thank you.. very useful
@RaghavPal
@RaghavPal 4 жыл бұрын
You are welcome Rahul
@rammsteiniano477
@rammsteiniano477 4 жыл бұрын
so useful thank you! :)
@RaghavPal
@RaghavPal 4 жыл бұрын
You're welcome!
@mradulat2834
@mradulat2834 4 жыл бұрын
Thanks for making this video.please make video on how we can read data from excel in cucumber using datatables and write to excel using cucumber and please use poi file you created for framework. Please sir its a request.
@RaghavPal
@RaghavPal 4 жыл бұрын
Sure will plan for it Mishra
@mushfiquazaman9597
@mushfiquazaman9597 3 жыл бұрын
@@RaghavPal I am running ----- mvn test -Dcucumber.options="src/test/resources/Features/loginDev.feature". It is showing BUILD success, but not showing any test results, like your video showing. Could u please le me know, why?
@sasidharsamala1889
@sasidharsamala1889 4 жыл бұрын
Raghav Sir, How give the command line option to select a specific TestRunner file(when there are multiple testrunner files) to run cud u plz give an example.
@RaghavPal
@RaghavPal 4 жыл бұрын
Hi Sasidhar, when you run mvn test, it runs the runner file, You can goto the location of the specific runner file and run it. You can also provide information on which file to include or exclude in pom.xml. Check this - stackoverflow.com/questions/34772622/how-to-run-single-cucumber-feature-files-through-command-prompt-and-through-jenk
@rodatt78
@rodatt78 Жыл бұрын
Hi Raghav.. The command cucumber.options doesn't work for me. Whichever TAG or Scenario I select, it still executes all the tests. I see the following warning message as well. WARNING: Passing commandline options via the property 'cucumber.options' is no longer supported. Please use individual properties instead. Will you be able to suggest a workaround to run these?
@RaghavPal
@RaghavPal Жыл бұрын
Hi Rohit, The warning message suggests that passing command-line options via the cucumber.options property is no longer supported, and individual properties should be used instead. Therefore, you can try passing individual properties for the features and tags you want to execute. Here's an example: cucumber.runtime.options="--tags @tag1 --tags @tag2 path/to/features" This will execute only the scenarios that have both tags @tag1 and @tag2. You can modify the tags and feature paths to suit your needs. Alternatively, you can specify the options in your cucumber.js configuration file. Here's an example: module.exports = { default: '--tags @tag1 --tags @tag2 path/to/features', }; This will set the default options for the cucumber execution. Note that these examples assume you're using cucumber-js. If you're using a different cucumber implementation, the syntax may be slightly different.
@abhishekthomas7799
@abhishekthomas7799 3 жыл бұрын
Hi Raghav, Inorder to run from jenkins. Can I use same "mvn test -D options" in maven goals and options in jenkins.? Or is there some other ways as well to run from jenkins.?
@RaghavPal
@RaghavPal 3 жыл бұрын
Yes, you can do that from Jenkins, Just ensure you setup Maven in Jenkins tools
@Reyolive-z5b
@Reyolive-z5b 10 ай бұрын
When I run the maven test, showing Build success in the console But not launching the page
@RaghavPal
@RaghavPal 10 ай бұрын
Rey While I can't access your specific code or environment, I can provide some tips to troubleshoot the page not launching. Here are some common causes and troubleshooting steps: 1. Incorrect WebDriver: - Ensure compatibility: Verify that the WebDriver version matches your browser version exactly. Download the correct driver from [chromedriver.chromium.org/downloads](chromedriver.chromium.org/downloads) (for Chrome) or the respective browser's website. - Path setup: Confirm that the WebDriver executable is in a directory within your system's PATH or explicitly set the path in your code. 2. Missing Dependencies: - Check Maven configuration: Ensure your pom.xml file includes necessary Selenium dependencies, such as: ```xml org.seleniumhq.selenium selenium-java 4.4.0 ``` - Resolve any dependency conflicts: Check for conflicting versions of Selenium or other libraries. 3. Test Code Errors: - Inspect test logic: Review your test code for syntax errors, incorrect browser setup, or issues with page navigation. - Use debugging tools: Step through your code to identify the point of failure. 4. Browser Configuration: - Disable extensions and plugins: Temporarily disable any browser extensions or plugins that might interfere with Selenium. - Check browser settings: Ensure browser settings (e.g., pop-up blockers, security settings) aren't blocking test execution. 5. Maven Configuration: - Verify test execution: Make sure Maven is configured to execute tests during the build process. - Check for errors: Look for any errors or warnings in the Maven build output that might provide clues. 6. Headless Mode: - Disable if not intended: If you're not using headless mode intentionally, ensure it's not enabled in your code or configuration. Additional Tips: - Run tests individually: Try running tests one by one to isolate the issue. - Increase logging: Add more logging statements to track test execution flow. - Clear browser cache: Clear cache and cookies to rule out interference. - Try a different browser: Test with a different browser to see if the issue persists. - Search online forums: Seek help from Selenium communities for specific error messages or scenarios.
@navikasspecials3112
@navikasspecials3112 4 жыл бұрын
hello Raghav, i have followed all the steps as u said.. my feature file is not able to sync with step definition file. can u please let me know wat may the reason.
@RaghavPal
@RaghavPal 4 жыл бұрын
Hi Mounika, pls check the logs to troubleshoot
@meharasoundarya6695
@meharasoundarya6695 Жыл бұрын
Hi, I have my test cases under src->test->java->feature (not in resources) and I have runner class name with Runner. I have tried to run with the options by giving full path, with tags but build is getting passed but test cases are not getting executed. Can someone please suggest
@RaghavPal
@RaghavPal Жыл бұрын
Mehara I see. There could be a few reasons why your Selenium Java Cucumber test cases are not getting executed in Eclipse. Here are a few things you can check: * Make sure that your feature files are in the correct directory. The default directory is `src/test/resources/features`, but you can change this in your project settings. * Make sure that your step definitions are in the correct directory. The default directory is `src/test/java/stepdefinitions`, but you can change this in your project settings. * Make sure that your runner class is in the correct directory. The default directory is `src/test/java`, but you can change this in your project settings. * Make sure that your runner class has the annotation `@RunWith(Cucumber.class)`. * Make sure that your feature files are formatted correctly. Cucumber uses a specific syntax for feature files. You can find more information about the syntax here: cucumber.io/docs/gherkin/ * Make sure that your step definitions are implemented correctly. The step definitions should match the steps in your feature files. If you have checked all of these things and your test cases are still not getting executed, then you can try the following: * Restart Eclipse. * Clear the project's build cache. * Update the Cucumber and Selenium libraries I hope this helps
@naynaborda557
@naynaborda557 4 жыл бұрын
Hey Raghav, is it possible to create this all video on IntelliJ Idea as well? because all the settings are not same as Eclipse in IntelliJ
@RaghavPal
@RaghavPal 4 жыл бұрын
Hi Nayna, I will plan on this
@arunbr4236
@arunbr4236 4 жыл бұрын
Is there any tool to mock database calls for performance testing?
@RaghavPal
@RaghavPal 4 жыл бұрын
Hi Arun, I have not tried practically, this can help examples.javacodegeeks.com/core-java/mockito/mockito-mock-database-connection-example/
@digitallova
@digitallova Жыл бұрын
hello is there any integration for running cucumber feature from vscode. i'm using java and couldnt find any special config to create a runner in vscode thanks in advance.
@RaghavPal
@RaghavPal Жыл бұрын
Hi Youssef Yes, you can run Cucumber features from VS Code using various extensions available in the marketplace. Here are a few options you can consider: Cucumber (Gherkin) Full Support: This extension provides full support for Cucumber (Gherkin) syntax highlighting, IntelliSense, and code snippets. It also includes a test runner that allows you to run Cucumber features directly from VS Code. To use this extension, you can create a new file with a ".feature" extension and start writing your Cucumber scenarios. Once you have created your scenarios, you can run them using the test runner provided by the extension. Java Test Runner: This extension provides support for running JUnit and TestNG tests in Java projects. To use this extension for running Cucumber features, you can create a new JUnit or TestNG test file and configure it to run your Cucumber features. This requires some additional configuration, such as specifying the Cucumber runner class and the location of your feature files. You can find more information about how to configure this extension for running Cucumber tests in Java on the extension's documentation page. Maven for Java: If you are using Maven to manage your Java project, you can use the Maven extension for VS Code to run your Cucumber features. To do this, you can add the Cucumber JUnit runner as a dependency in your pom.xml file and configure your project to run the Cucumber runner class during the test phase. You can find more information about how to configure Maven for running Cucumber tests in Java on the Maven documentation page. There are many other extensions available in the VS Code marketplace that can be used to run Cucumber tests. The best option depends on your specific needs and preferences.
@digitallova
@digitallova Жыл бұрын
@@RaghavPal weird because i have got the full support cuccumber plugin installled , but when i right click and do run cucumber feature , it says the cucumber-quick command couldnt been executed , as if it were waiting for me to configure the snippet in the settings.json. is there any video i can use as a support running cucumber on vscode?
@RaghavPal
@RaghavPal Жыл бұрын
It's possible that the Cucumber (Gherkin) Full Support extension in your VS Code installation is not properly configured. Here are some steps you can take to troubleshoot the issue: Check that the Cucumber (Gherkin) Full Support extension is enabled: Go to the Extensions view in VS Code (by clicking on the extensions icon in the left-hand menu or by using the keyboard shortcut Ctrl + Shift + X), and check that the extension is installed and enabled. If it is not enabled, click the enable button. Check that the Cucumber executable is on your system path: The error message you are seeing suggests that the cucumber-quick command is not found on your system path. You can check your system path by opening a terminal window and typing echo $PATH. This will print a list of directories that are on your system path. Check that the directory containing the cucumber-quick command is listed. Configure the cucumber.java.executable setting: The Cucumber (Gherkin) Full Support extension requires that the path to the Cucumber executable be configured in the cucumber.java.executable setting in your VS Code settings.json file. You can open your settings.json file by going to File > Preferences > Settings in VS Code, searching for "cucumber.java.executable", and entering the path to your Cucumber executable. For example, on a Unix-based system, the path might be /usr/local/bin/cucumber. Restart VS Code: After making changes to your settings.json file, it's a good idea to restart VS Code to ensure that the changes are applied.
@digitallova
@digitallova Жыл бұрын
@@RaghavPal i would really aperiate a video about how to setup cucumber on vscode(espacially for java on macos). i couldnt figure it out. its unfortently so simple on jetbrains and eclipse, but not that abvious on vscode. thanks in advance
@RaghavPal
@RaghavPal Жыл бұрын
I will plan Youssef
@sidb2023
@sidb2023 2 жыл бұрын
Hi Raghav, I tried but cucumber options are not being accepted from command line. I think cucumber options from command line are deprecated. Also when I tried to generate report through command line, report did not generate. I used mvn test -Dcucumber.plugin="pretty, json: target/JSONReport/report.json" please help me.
@RaghavPal
@RaghavPal 2 жыл бұрын
I will check on this Siddharth
@aakritijain9953
@aakritijain9953 Жыл бұрын
@@RaghavPal In my project also there is no html report generated.
@anikethinamdar9404
@anikethinamdar9404 3 жыл бұрын
How to run it if it is not a maven project?
@RaghavPal
@RaghavPal 3 жыл бұрын
Hi Aniketh can run as Java program
@pl_0077
@pl_0077 2 жыл бұрын
Can you make one on cucumber 7.1 it's looking very difficult for me as I am new learner
@RaghavPal
@RaghavPal 2 жыл бұрын
I will plan
@atulsharmacsk
@atulsharmacsk 3 жыл бұрын
Hi Raghav, Thanks for such detailed videos. I am facing an issue while command line execution. Dcucumber.options is not overriding the TestRunner file options. Even mvn test Dcucumber.options="--help" is just running the tests as per TestRunner file but Help section is not available. Same behavior is being observed with other Dcucumber options, these options are also being ignored. Eg:-in below command I mentioned to execute only the scenario having @smoke tag but scenario having @regression tag is also being executed. Any suggestion what could be going wrong here: C:\Users\Atul\Desktop\Atul\Cucumber>mvn test -Dcucumber.options="-t @smoke" [INFO] Scanning for projects... [INFO] [INFO] -------------------------< Atul:com.cucumber >-------------------------- [INFO] Building CucumberL 0.0.1-SNAPSHOT [INFO] --------------------------------[ jar ]--------------------------------- [INFO] [INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ com.cucumber --- [WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent! [INFO] Copying 0 resource [INFO] [INFO] --- maven-compiler-plugin:3.7.0:compile (default-compile) @ com.cucumber --- [INFO] Nothing to compile - all classes are up to date [INFO] [INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ com.cucumber --- [WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent! [INFO] Copying 2 resources [INFO] [INFO] --- maven-compiler-plugin:3.7.0:testCompile (default-testCompile) @ com.cucumber --- [INFO] Nothing to compile - all classes are up to date [INFO] [INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ com.cucumber --- [INFO] Surefire report directory: C:\Users\Atul\Desktop\Atul\Cucumber\target\surefire-reports ------------------------------------------------------- T E S T S ------------------------------------------------------- Running Runner.TestRunner @smoke Scenario Outline: Multiple Logins-1 # src/test/resources/FeatureSet/LoginF.feature:13 this should come first This will be used only in smoke & shoudl come second SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder". SLF4J: Defaulting to no-operation (NOP) logger implementation SLF4J: See www.slf4j.org/codes.html#StaticLoggerBinder for further details. Starting ChromeDriver 87.0.4280.88 (89e2380a3e36c3464b5dd1302349b1382549290d-refs/branch-heads/4280@{#1761}) on port 27169 Only local connections are allowed. Please see chromedriver.chromium.org/security-considerations for suggestions on keeping ChromeDriver safe. ChromeDriver was started successfully. Dec 19, 2020 7:19:19 PM org.openqa.selenium.remote.ProtocolHandshake createSession INFO: Detected dialect: W3C Dec 19, 2020 7:19:19 PM org.openqa.selenium.devtools.CdpVersionFinder findNearestMatch WARNING: Unable to find an exact match for CDP version 87, so returning the closest version found: 86 Dec 19, 2020 7:19:19 PM org.openqa.selenium.devtools.CdpVersionFinder findNearestMatch INFO: Found CDP implementation for version 87 of 86 Given Open the browser # StepsSet.loginSteps.open_the_browser() When Navigate to the url # StepsSet.loginSteps.navigate_to_the_url() Login is successfull And login using smoke and 12345 # StepsSet.loginSteps.login_using_and(java.lang.String,java.lang.String) @regression Scenario Outline: Multiple Logins-2 # src/test/resources/FeatureSet/LoginF.feature:23 this should come first Starting ChromeDriver 87.0.4280.88 (89e2380a3e36c3464b5dd1302349b1382549290d-refs/branch-heads/4280@{#1761}) on port 2322 Only local connections are allowed. Please see chromedriver.chromium.org/security-considerations for suggestions on keeping ChromeDriver safe. ChromeDriver was started successfully. Dec 19, 2020 7:19:32 PM org.openqa.selenium.remote.ProtocolHandshake createSession INFO: Detected dialect: W3C Dec 19, 2020 7:19:32 PM org.openqa.selenium.devtools.CdpVersionFinder findNearestMatch WARNING: Unable to find an exact match for CDP version 87, so returning the closest version found: 86 Dec 19, 2020 7:19:32 PM org.openqa.selenium.devtools.CdpVersionFinder findNearestMatch INFO: Found CDP implementation for version 87 of 86 Given Open the browser # StepsSet.loginSteps.open_the_browser() When Navigate to the url # StepsSet.loginSteps.navigate_to_the_url() Login is successfull And login using regression and 12345 # StepsSet.loginSteps.login_using_and(java.lang.String,java.lang.String) ????????????????????????????????????????????????????????????????????????????????????? ? Share your Cucumber Report with your team at reports.cucumber.io ? ? Activate publishing with one of the following: ? ? ? ? src/test/resources/cucumber.properties: cucumber.publish.enabled=true ? ? src/test/resources/junit-platform.properties: cucumber.publish.enabled=true ? ? Environment variable: CUCUMBER_PUBLISH_ENABLED=true ? ? JUnit: @CucumberOptions(publish = true) ? ? ? ? More information at reports.cucumber.io/docs/cucumber-jvm ? ? ? ? Disable this message with one of the following: ? ? ? ? src/test/resources/cucumber.properties: cucumber.publish.quiet=true ? ? src/test/resources/junit-platform.properties: cucumber.publish.quiet=true ? ????????????????????????????????????????????????????????????????????????????????????? Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 27.413 sec Results : Tests run: 2, Failures: 0, Errors: 0, Skipped: 0 [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ [INFO] Total time: 30.201 s [INFO] Finished at: 2020-12-19T19:19:41+05:30 [INFO] ------------------------------------------------------------------------
@RaghavPal
@RaghavPal 3 жыл бұрын
Did you try changing chrome driver ver
@atulsharmacsk
@atulsharmacsk 3 жыл бұрын
@@RaghavPal , Thanks for the suggestion, I just tried with geckodriver but still Dcucumber.options is being ignored.
@RaghavPal
@RaghavPal 3 жыл бұрын
try some online examples
@ЮлияКузнецова-х5ь
@ЮлияКузнецова-х5ь 3 жыл бұрын
Hi Atul Sharma, I've faced with the same problem and looks like I was using Cucumber 6 version and documentation is changed so now we should use like mvn test -Dcucumber.filter.tags="@youttagname"
@ravisinghrajpoot3086
@ravisinghrajpoot3086 4 жыл бұрын
Hi Raghav I m looking for Jenkins Job config settings which trigger multiple Jenkins jobs and aggregate the results from those jobs n send it in a single email Any help is highly appreciated
@RaghavPal
@RaghavPal 4 жыл бұрын
Hi Ravi, I will plan a session. To achieve this, you can also check my Jenkins series here - automationstepbystep.com/
@i.adi_
@i.adi_ 4 жыл бұрын
-Dcucumber.options is not working
@RaghavPal
@RaghavPal 4 жыл бұрын
Hi Aditya, what does the logs say. Check the complete setup again with the video
@abdulnazer3136
@abdulnazer3136 3 жыл бұрын
Hi Aditya, its not working for me as well, did you able to sort it out?
@priyanshisaxena1822
@priyanshisaxena1822 2 жыл бұрын
mvn test -Dcucumber.options="src/test/resources/Features/login.feature:9" For me this is not working, still its showing 2 test pass, instead of only 1 being pass, my scenario is starting from line 9. Any idea what could be the reason ?
@sunshineandsmiles2k6
@sunshineandsmiles2k6 Жыл бұрын
@@priyanshisaxena1822 I believe the syntax changed. The following worked for me: mvn test -Dcucumber.features="src/test/resources/features/login.feature:9"
@spratanzz4324
@spratanzz4324 3 жыл бұрын
How to pass username and password for login through conmandline
@RaghavPal
@RaghavPal 3 жыл бұрын
What credentials do you need
@prachimuddapur
@prachimuddapur 4 жыл бұрын
Raghav, when I run "Maven test" from Eclipse or from command prompt, I do not see any test results per se. All I see is that the build is successful. Why can't I see the tests results? Thanks in advance [INFO] Scanning for projects... [INFO] [INFO] ---------------------< CucumberJava:CucumberJava >---------------------- [INFO] Building CucumberJava 0.0.1-SNAPSHOT [INFO] --------------------------------[ jar ]--------------------------------- [INFO] [INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ CucumberJava --- [WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent! [INFO] Copying 0 resource [INFO] [INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ CucumberJava --- [INFO] Nothing to compile - all classes are up to date [INFO] [INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ CucumberJava --- [WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent! [INFO] Copying 1 resource [INFO] [INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ CucumberJava --- [INFO] Changes detected - recompiling the module! [WARNING] File encoding has not been set, using platform encoding Cp1252, i.e. build is platform dependent! [INFO] Compiling 2 source files to C:\Users\PV3\eclipse-workspace\cucumberbddCMD\target\test-classes [INFO] [INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ CucumberJava --- [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------
@prachimuddapur
@prachimuddapur 4 жыл бұрын
One more question - what exactly are the default folder structures for? src/main/java, src/test/java etc.
@RaghavPal
@RaghavPal 4 жыл бұрын
Hi Prachi, basically all test classes and its helping files are placed under src/test/java and other main or dev classes in src/main/java Check if you have any classes having name Test in its name in the src/test/java folder
@prachimuddapur
@prachimuddapur 4 жыл бұрын
@@RaghavPal Raghav thank you for your reply. :) I tried putting the name ending with Test and it did work.
@suruchigarg57
@suruchigarg57 Жыл бұрын
Hi Raghav, CMd is giving the following message : T E S T S ------------------------------------------------------- There are no tests to run. Results : Tests run: 0, Failures: 0, Errors: 0, Skipped: 0 While i am able to run the tests via GUI Please suggest me the solutions
@RaghavPal
@RaghavPal Жыл бұрын
Suruchi There are a few possible reasons why you might be getting the message "There are no tests to run" when trying to run your Selenium Java with Cucumber project from the command line: *Your test runner is not configured correctly:* Make sure that your test runner is configured to find your feature files and step definitions. *Your feature files are not formatted correctly:* Make sure that your feature files are formatted correctly and that they are located in a directory that your test runner can find. *Your step definitions are not implemented correctly:* Make sure that your step definitions are implemented correctly and that they are located in a directory that your test runner can find. Here are some things you can try to troubleshoot the issue: *Check your test runner configuration:* Make sure that your test runner is configured to find your feature files and step definitions. You can usually do this by editing a configuration file, such as a `testng.xml` file or a `pom.xml` file. *Check your feature file formatting:* Make sure that your feature files are formatted correctly. You can use a tool such as the Cucumber Eclipse plugin to help you with this. *Check your step definition implementation:* Make sure that your step definitions are implemented correctly. You can use a tool such as the Cucumber Eclipse plugin to help you with this. *Try running your tests from the command line using the full class name of your test runner:* For example, if your test runner is called `MyTestRunner`, you can try running it from the command line using the following command: ``` java MyTestRunner ``` If you are still having trouble, you can post your test runner configuration, feature files, and step definitions on a forum or mailing list for help. Here are some additional tips for running Selenium Java with Cucumber projects from the command line: * Make sure that you have the latest versions of Java, Selenium, and Cucumber installed. * Make sure that you have the Maven command-line tools installed. * Make sure that you have the Cucumber Eclipse plugin installed (if you are using Eclipse IDE). * Make sure that your project is built correctly. * Make sure that you are running the command from the correct directory. I hope this helps
@suruchigarg57
@suruchigarg57 Жыл бұрын
Thanks Raghav for responding. Finaaly i got the resolution. May be you can include in current videos as well. In POM file we need to add the folder path and the runner file path as well. MaY BE THERE WOULD BE OTHER SOLUTIONS AS WELL, BUT I FOUND THIS SUITABLY WORKED OUT. src/test/resources true AND maven-surefire-plugin 2.8 **/*runner.java Thanks a ton Raghav. Stay blessed!
@RaghavPal
@RaghavPal Жыл бұрын
Thanks for adding Suruchi
@mithunsurve
@mithunsurve 2 жыл бұрын
@28:58 I got this error, Could anybody help Unknown lifecycle phase ".options=--help". You must specify a valid lifecycle phase or a goal in the format : or :[:]:. Available lifecycle phases are: validate, initialize, generate-sources, process-sources, generate-resources, process-resources, compile, process-classes, generate-test-sources, process-test-sources, generate-test-resources, process-test-resources, test-compile, process-test-classes, test, prepare-package, package, pre-integration-test, integration-test, post-integration-test, verify, install, deploy, pre-clean, clean, post-clean, pre-site, site, post-site, site-deploy. -> [Help 1]
@RaghavPal
@RaghavPal 2 жыл бұрын
Hi Mithun, The cucumber.options property was deprecated and removed. You have to pass each option as a single property. mvn test -Dcucumber.filter.tags='@smoke and not @ignore' github.com/cucumber/cucumber-jvm/blob/main/release-notes/v5.0.0.md#property-based-options stackoverflow.com/questions/64704059/dcucumber-options-ignored-with-mvn-test
@mithunsurve
@mithunsurve 2 жыл бұрын
@@RaghavPal Thank you
@rutuja20
@rutuja20 7 ай бұрын
1. mvn test -Dcucumber.options="--help" -> showing same result as mvn test, not showing any options in result 2. Run specific scenario command and specific tag command showing results as "Tests run 2, Failure: 0, Errors: 0, Skipped: 0" Not like same in this video 3. Also Html reports command not working
@RaghavPal
@RaghavPal 7 ай бұрын
Rutika Let's address each of your issues one by one: 1. mvn test -Dcucumber.options="--help": - It appears that the `-Dcucumber.options="--help"` command is not displaying the expected options. This behavior is because the `cucumber.options` property has been deprecated and removed. - Instead, you should pass each option as an individual property. For example, to display the help message, use the following command: ``` mvn test -Dcucumber.filter.tags='@smoke and not @ignore' ``` - This will show the available options for your Cucumber tests¹². 2. Running Specific Scenarios or Tags: - When running specific scenarios or tags, the result you're seeing ("Tests run 2, Failure: 0, Errors: 0, Skipped: 0") indicates that the specified scenarios or tags were executed successfully. - If you're expecting different behavior, ensure that your feature files and step definitions are correctly tagged and that the runner class specifies the correct options. - If you have a specific video reference, please share it, and I'll provide more tailored guidance. 3. HTML Reports Command: - To generate HTML reports for your Cucumber tests, you can use plugins like `cucumber-reporting` or `cucumber-html-report`. - First, make sure you have the appropriate dependencies in your `pom.xml` file. - Then, configure your runner class to use the desired plugin. For example: ```java @RunWith(Cucumber.class) @CucumberOptions( features = {"classpath:features"}, plugin = {"pretty", "html:target/cucumber-reports"} ) public class CucumberTestRunner { } ``` - After running your tests, you'll find the HTML reports in the specified directory (e.g., `target/cucumber-reports`). Remember to check your project setup, dependencies, and runner class configuration to ensure everything aligns with your expectations.
@sagarregmi7975
@sagarregmi7975 5 ай бұрын
Hi Raghav, Can you please make one video to resolve this issue -May 31, 2024 2:47:42 PM cucumber.api.cli.Main run WARNING: You are using deprecated Main class. Please use io.cucumber.core.cli.Main 0 Scenarios 0 Steps 0m0.030s
@RaghavPal
@RaghavPal 5 ай бұрын
Sagar The error message you're encountering-"WARNING: You are using deprecated Main class. Please use io.cucumber.core.cli.Main"-indicates that the `cucumber.api.cli.Main` class is deprecated, and you should use the `io.cucumber.core.cli.Main` class instead. To resolve this issue, follow these steps: 1. Update Your Dependencies: - Make sure you're using the latest version of Cucumber in your project. Outdated versions may still reference the deprecated class. - Update your `pom.xml` (if you're using Maven) or your build.gradle (if you're using Gradle) to use the latest Cucumber dependencies. 2. Replace the Main Class: - In your Cucumber runner class (usually named something like `TestRunner`), change the import statement for the main class from: ```java import cucumber.api.cli.Main; ``` to: ```java import io.cucumber.core.cli.Main; ``` 3. Recompile and Run: - Recompile your project to ensure that the changes take effect. - Run your Cucumber tests again. The warning should no longer appear. Remember to verify your project configuration and ensure that you're using the correct dependencies --
@jaylai6294
@jaylai6294 2 жыл бұрын
Hi Raghav, I follow your "How to run Cucumber from command line"" session to create project and test case, then run "mvn test" ; the result does show "Build Success" but "Test Run" shows "0" Do you know why? Really appreciate if I can get some hints from you ------------------------------------------------------- T E S T S ------------------------------------------------------- Running runners.TestRunner Configuring TestNG with: org.apache.maven.surefire.testng.conf.TestNG652Configurator@5c0369c4 Tests run: 0, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.271 sec Results : Tests run: 0, Failures: 0, Errors: 0, Skipped: 0 [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ [INFO] Total time: 4.828 s [INFO] Finished at: 2022-09-01T13:49:42-04:00 [INFO] ------------------------------------------------------------------------
@RaghavPal
@RaghavPal 2 жыл бұрын
Hi Jay, pls check do you have both junit and testng dependencies added in your project In your cucumber runner class, check what dependency is used This can help: stackoverflow.com/questions/33938393/why-running-cucumber-test-with-maven-return-result-tests-run-0
@prabhasrinivasan8274
@prabhasrinivasan8274 Жыл бұрын
_Dcucumber.options="--help" does not work
@RaghavPal
@RaghavPal Жыл бұрын
will need more details Prabha
Selenium Cucumber Java BDD Framework 12 | How To Create HTML Reports
17:39
Automation Step by Step
Рет қаралды 82 М.
Selenium Cucumber Java BDD Framework 9 - Hooks | Step by Step
37:32
Automation Step by Step
Рет қаралды 84 М.
Мама у нас строгая
00:20
VAVAN
Рет қаралды 10 МЛН
If people acted like cats 🙀😹 LeoNata family #shorts
00:22
LeoNata Family
Рет қаралды 5 МЛН
СКОЛЬКО ПАЛЬЦЕВ ТУТ?
00:16
Masomka
Рет қаралды 3,2 МЛН
Selenium Cucumber Java BDD Framework 10  | Background | Step by Step
17:14
Automation Step by Step
Рет қаралды 56 М.
Selenium Cucumber Java BDD Framework 1 - Setup | Step by Step | Raghav Pal
43:25
Automation Step by Step
Рет қаралды 761 М.
Gradle Course for Beginners | Get Going with Gradle
56:59
Tom Gregory Tech
Рет қаралды 35 М.
Selenium Cucumber Java BDD Framework 8 - Tags | Step by Step
18:03
Automation Step by Step
Рет қаралды 75 М.