I was having problem with learning cucumber from other sources. But the way you explain i didnt have any problem understanding. It feels like i found my source of learning all things from you. Thank you very much for working so hard to teach others.
@@RaghavPal Also i dont know if its appropriate to ask here or not. I am working as mechanical Quality engineer from past 10 years but now i watch to switch to IT domain . I have learnt Cucumber with Selenium and also have certification on Selenium with java . Now every recruiter needs experienced people. Do i have any chance to get an interview call as fresher at age of 32. Is it possible to join as fresher in selenium web testing??
Hi, you can learn some more relevant tools and platforms and make some personal projects, upload your projects on GitHub and add the links in your Resume, this will give your profile more weightage and will help in interviews
Hi Raghav, I have watched and recommend this playlist to all my friends and must say its really helpful and easy to understand through your videos. I have one question, can I parameterize rows with no fix column? Such as in 1st row there are 5 column and and in second only 4 and so on. Can I do it using Scenario Outline?
Thanks, Raghav for very well explained the Parameterization and Data-Driven Testing. Can we use data files i.e CSV, Excel, and database(Oracle.etc) instead of mentioned data details in the feature files? If yes could you please add that video in near future?
Thank you Raghav, u made us very simple to learn...please make video on how to handle Multiple Feature files with different combinations in reality and how to handle Datatables with Maps
Thank you very much Raghav, thoroughly explained. could you please make videos for 1. data driven testing using properties file as an input 2. how to test sqls/unix commands in cucumber. 3. how to test soap/rest API's using cucumber. it would be a great help:)
Nice explanation, glad that I found your videos on many topics - very clear and you make them so simple to remember. great effort and keep going and help all the curious learners. Have one question, as here passed 2 sets of data, but if we have multiple sets of data(may be 100 sets) then how to parameterize. Should we use a third party file like .xls or .xslx. If so then how to read the data from the file.
Hi, for a large data set, it is always useful to externalize the data and use options like excel, csv, json files. I will create a session on this. For now this can help you - ua-cam.com/video/B4G2tMDYjRQ/v-deo.html
Hi Raghav, As always, thanks for the tutorial. I've followed this tutorial and saw some exceptions as I switched to use gecko/FireFox (geckodriver-v0.27.0-win64 and Firefox 81.0 64 bit). For any scenario, at the final step I see the exception: " org.openqa.selenium.NoSuchWindowException: Browsing context has been discarded" Here is the exception from Eclipse terminal: Scenario Outline: Check login is successfull with valid crredentials # src/test/resources/Features/LoginDemo.feature:13 Inside Step: browser is open projectPath = C:\Working\Git\GitRepos\eclipse-workspace\CucumberJava 1601168425609 geckodriver INFO Listening on 127.0.0.1:11548 1601168426121 mozrunner::runner INFO Running command: "C:\\Program Files\\Mozilla Firefox\\firefox.exe" "--marionette" "-foreground" "-no-remote" "-profile" "C:\\Users\\steve\\AppData\\Local\\Temp\ ust_mozprofileBO7fNN" Can't find symbol 'eglSwapBuffersWithDamageEXT'. JavaScript error: resource://gre/modules/XULStore.jsm, line 66: Error: Can't find profile directory. console.error: SearchCache: "_readCacheFile: Error reading cache file:" (new Error("", "(unknown module)")) 1601168431595 Marionette INFO Listening on port 49198 1601168431950 Marionette WARN TLS certificate errors will be ignored for this session Sep 26, 2020 8:00:32 PM org.openqa.selenium.remote.ProtocolHandshake createSession INFO: Detected dialect: W3C Given browser is open # StepDefinitions.LoginDemoSteps.browser_is_open() Inside Step: user is on login page And user is on login page # StepDefinitions.LoginDemoSteps.user_is_on_login_page() When user enters Esther and 12345 # StepDefinitions.LoginDemoSteps.user_enters_username_and_password(java.lang.String,java.lang.String) And user clicks on login # StepDefinitions.LoginDemoSteps.user_clicks_on_login() org.openqa.selenium.NoSuchWindowException: Browsing context has been discarded Build info: version: '4.0.0-alpha-6', revision: '5f43a29cfc' System info: host: 'ONGS-41', ip: '192.168.1.97', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '14.0.2' Driver info: org.openqa.selenium.firefox.FirefoxDriver Capabilities {acceptInsecureCerts: true, browserName: firefox, browserVersion: 81.0, javascriptEnabled: true, moz:accessibilityChecks: false, moz:buildID: 20200917005511, moz:geckodriverVersion: 0.27.0, moz:headless: false, moz:processID: 31584, moz:profile: C:\Users\steve\AppData\Loca..., moz:shutdownTimeout: 60000, moz:useNonSpecCompliantPointerOrigin: false, moz:webdriverClick: true, pageLoadStrategy: normal, platform: WINDOWS, platformName: WINDOWS, platformVersion: 10.0, rotatable: false, setWindowRect: true, strictFileInteractability: false, timeouts: {implicit: 0, pageLoad: 300000, script: 30000}, unhandledPromptBehavior: dismiss and notify} Session ID: f78aa9b9-95d9-4ff2-b31c-1f4e478091b5 *** Element info: {Using=id, value=login} 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.newInstanceWithCaller(Constructor.java:500) at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:481) at org.openqa.selenium.remote.codec.w3c.W3CHttpResponseCodec.createException(W3CHttpResponseCodec.java:196) at org.openqa.selenium.remote.codec.w3c.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:129) at org.openqa.selenium.remote.codec.w3c.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:53) at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:160) at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:83) at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:582) at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:333) at org.openqa.selenium.remote.RemoteWebDriver.findElementById(RemoteWebDriver.java:381) at org.openqa.selenium.By$ById.findElement(By.java:194) at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:325) at StepDefinitions.LoginDemoSteps.user_clicks_on_login(LoginDemoSteps.java:45) at ✽.user clicks on login(file:///C:/Working/Git/GitRepos/eclipse-workspace/CucumberJava/src/test/resources/Features/LoginDemo.feature:7) Then user is navigate to the home page # StepDefinitions.LoginDemoSteps.user_is_navigate_to_the_home_page() Failed scenarios: file:///C:/Working/Git/GitRepos/eclipse-workspace/CucumberJava/src/test/resources/Features/LoginDemo.feature:13# Check login is successfull with valid crredentials 2 Scenarios (1 failed, 1 passed) 10 Steps (1 failed, 1 skipped, 8 passed) 0m33.959s .... Any help would be appreciated.
Update on this issue: If I code the last step like this: ------------------------------ @Then("user is navigate to the home page") public void user_is_navigate_to_the_home_page() throws InterruptedException { driver.findElement(By.id("saved")).isDisplayed(); Thread.sleep(2000); driver.close(); Thread.sleep(2000); // driver.quit(); } ------------------------------ ... Then I am able to pass all scenarios (I still seeing an error, though) : -------------------------- Given browser is open # StepDefinitions.LoginDemoSteps.browser_is_open() Inside Step: user is on login page And user is on login page # StepDefinitions.LoginDemoSteps.user_is_on_login_page() When user enters Esther and 12345 # StepDefinitions.LoginDemoSteps.user_enters_username_and_password(java.lang.String,java.lang.String) And user clicks on login # StepDefinitions.LoginDemoSteps.user_clicks_on_login() 1601171372702 Marionette INFO Stopped listening on port 50483 ###!!! [Child][RunMessage] Error: Channel closing: too late to send/recv, messages will be lost ###!!! [Child][MessageChannel::SendAndWait] Error: Channel error: cannot send/recv Then user is navigate to the home page # StepDefinitions.LoginDemoSteps.user_is_navigate_to_the_home_page() 2 Scenarios (2 passed) 10 Steps (10 passed) 0m32.412s ------------------------------
Thank you so much sir, it's very easy to understand the way you explain. Words fall short to thank you for this service. I jus wanted to ask you can we implement in the same way in real time too?
Hi Seyma, there are diff ways to match a text using regular expression. This story can help you understand better - automationstepbystep.com/2020/05/05/a-story-of-regex/
Hi Raghav, Thanks for sharing knowledge, appreciate all your efforts and help..I have one query as below, could you please guide me on the same. What if I want open a browser only once and then scenario needs to run multiple time with scenario outline with multiple data mentioned in example, how I can I achieve this. For e.g. - I have simple scenario to select report name from the drop-down and click on view button and verify report header, along with data and row count is available.(likewise I have 5 reports in drop-down) So in this scenario I just want to open the browser only once and navigate to the page and perform the scenario I mentioned
Thanks, Raghav very well explained. Can we use data files as CSV or excel for parameterization instead of examples in feature file ? If yes, could you make a video for the same .
Hi Raghav, Great tutorial. I have a small doubt. Why do we have to use ^$ in the When statement. In regex they are used to restrict and match groups. How does using them resolve the error which was thrown first?
@@RaghavPal No need for the trouble of checking deeper. Just was curious. Thank you so much for the response. If I find out the reason, I will try and post in the comments. Cheers!
Hi Raghav, Thanks I was able to login to some other website following your video.One query, I have why we have not created a "Test Runner " here and run the feature file here unlike previous videos.Regards.
Hi raghav. Thankyou so much for this valuable sessions.. but we want to do this in Intellij Ide so could you please make more sessions by using intellij not with eclips.
Hi Raghav, good tutorial. Very understandable and precise. Only issue I currently have is I am getting duplicate step definition error which I need to figure out. Let me know how to overcome it. Thanks
@@RaghavPal I have mentioned exactly what I am doing below: Feature 1 Scenario 1 Given User opens chrome browser Feature 2 Scenario 1 Given User opens chrome browser StepDefinition class for Feature 1 I have used Given User opens chrome browser StepdDefinition class for Feature 2 I have used Given User opens chrome browser Hence when I run them it throws duplicate step definition error (Which is what we discussed earlier) If I remove it from Feature 2 it fails after chrome browser opens giving an error driver is null for the next function. So wanted to know how to use the same step in feature 2 StepDefinition class.
Do not remove from feature, but from step definition, So there are 2 ways, either remove the function from one of the step definition OR use a different statement (unique) in 2nd feature and update the step definition accordingly OR another way will be to use the runner class and provide the path of the exact step definition you want to use stackoverflow.com/questions/55659393/getting-cucumber-runtime-duplicatestepdefinitionexception-despite-adding-backgro/55659727
Hi Raghav, I have a query when i run logindemo.feature file data is not inserted user name is enter like this i am using ur same code.code is running only one time.
If you are using parameterized values within conical brackets, then you should provide data table in Examples section and the values should be given as arguments in the corresponding function in Step Definition. Check in the video again
Thank you so much for the detailed explanation,🙌 Your video genuinely helped me a lot...!🙏🙏 while executing, the only changed i observed is if we want to give the sets of username and password then in steps file we have to insert (.+) instead of (.*) and we have to mention the username and password keyword of feature file in instead of " " as the keyword mentioned in " " is static. These changes might differ according to the systems and the softwares. Please correct me if i am wrong..!
Hi Raghav, Thanks for your tutorial on parameterization. Could you please tell me how we do drive the test data from excel using SQL queries? Thanks in advance.
Hi @Raghav which version of Eclipse did you use ? I am getting error and cannot install Cucumber plugin for Eclipse 2020-12 developer Version. Need your help for this please
Hi Trilok Yes, you can read examples data in the feature file from external files like CSV, Excel, or JSON using a data provider. Here are the steps to do it: Add the data provider library to your project, such as Apache POI for Excel or OpenCSV for CSV. Create a class to read data from the external file and return it in a format that can be used by your step definitions. For example, you can create a method that reads data from a CSV file and returns a list of maps, where each map represents a row in the CSV file and contains key-value pairs for each column in the row. Annotate your scenario with the data provider and specify the method that reads the external file as the data provider. You can also specify the data format, such as "csv" or "excel". Can find some examples and code online
I do not have a specific focussed video on this, but if you check the video using @DataProvider annotation, the same can be used here ua-cam.com/video/B4G2tMDYjRQ/v-deo.html
Hi, I came across one scenarios, where I need to run the TestRunner class using cucumber Cli, but the TestRunner is not able to genearte any report can you, Please sugggest any ideas/approach to achieve that? cucumberCliExampple - jars - test - stepdefinitions - *.java - features - *.feature - TestRunner.java
If there 2 two scenarios here.. in 1 we are testing valid login and in another we are testing invalid login with wrong credentials, then for both the scenarios we have to write "Scenario Outline"? or for first scenario it would be "Scenario Outline" and for 2nd it would be just "Scenario"?
You can use a scenario outline for both the scenarios, or you can use a scenario for the first scenario and a scenario outline for the second scenario. It depends on how you want to parameterize your tests. If you want to test multiple valid login credentials, then you can use a scenario outline. For example, the following scenario outline would test the login functionality with three different valid login credentials: ``` Scenario Outline: Login with valid credentials Given I am on the login page When I enter the username "" And I enter the password "" And I click the login button Then I should be logged in Examples: | username | password | | johndoe | password | | janedoe | password | | admin | admin | ``` If you only want to test a single valid login credential, then you can use a scenario. For example, the following scenario would test the login functionality with the username "johndoe" and the password "password": ``` Scenario: Login with valid credentials Given I am on the login page When I enter the username "johndoe" And I enter the password "password" And I click the login button Then I should be logged in ``` If you want to test multiple invalid login credentials, then you can use a scenario outline. For example, the following scenario outline would test the login functionality with three different invalid login credentials: ``` Scenario Outline: Login with invalid credentials Given I am on the login page When I enter the username "" And I enter the password "" And I click the login button Then I should see an error message Examples: | username | password | | invalid | invalid | | username | wrong_password | | wrong_username | password | ``` If you only want to test a single invalid login credential, then you can use a scenario. For example, the following scenario would test the login functionality with the username "invalid" and the password "invalid": ``` Scenario: Login with invalid credentials Given I am on the login page When I enter the username "invalid" And I enter the password "invalid" And I click the login button Then I should see an error message ``` Ultimately, the decision of whether to use a scenario or a scenario outline depends on your specific needs and preferences.
Hello Raghav, I really appreciate the way you are providing details. It is really helping me. I request to solve this issue when I do your cucumber above part 5, am getting an error as "Null Pointer Exception" though I declared webdriver driver=null. Please help, I stuck here and I tried all the ways making static , public that webdriver.
@@RaghavPal thanks for fast answer, I thought about it, but as you didnt code assertion in your video I thought i can achieve the same result by for example declaring boolean login.logoutDisplayed(); (where logoutDisplayed is a function to locate logout button ofc), but it was not working. Ok i got it assertion is needed. Thank you for your videos man!
Hi Raghav thanks for the video.i have implemented same but every time when I run i am getting steps as undefined and test is being skipped.Can you help on this please
Hi Raghav, please help me. My parameterisation is not working. @When("^user enters valid (.*) and valid (.*) and login$") public void user_enters_valid_username_and_valid_passward_and_login(String str1, String str2) {
} Tried this eclipse (after running as cucumber file) is giving wrong code tidy gherkin is giving code with .+ , but not working. I practiced before they worked but now eclipse is behaving different. why? I have recently changed my java version though (to practice jerkins). before it was 16, now I am using jdk11. what to do? I want to make a selenium cucumber framework but this problem is happening.I am frastrated. first data set is passing through but others not . Thanks in advance
@@RaghavPal Thanks . not for java. Because I have installed again new eclipse. java 16. Something is happening after converting the maven project to cucumber project. May be some problem with latest cucumber plugin in eclipse. don't know .Any way really thanks for your reply. I was thinking to practice to build a cucumber selenium framework but now decided to do selenium testng first . Thanks
Hi Vipin, it can be typo Can check this stackoverflow.com/questions/62261565/io-cucumber-core-gherkin-featureparserexception-failed-to-parse-resource-at
Abhisek In Cucumber, adding `^$` to the beginning and end of a step definition serves two primary purposes: 1. **Restricting Step Matching:** The `^` (caret or hat) symbol at the beginning of the step definition indicates that the entire step text should match the Gherkin step text. This helps prevent unintended step matches and ensures that the step definition is only triggered when the exact step text is used. 2. **Anchoring Regular Expressions:** The `$` (dollar sign) symbol at the end of the step definition anchors the regular expression used to match the step text. This prevents the regular expression from matching beyond the specified step text, ensuring that the step definition only captures the intended information. By using `^$`, you can ensure that your step definitions are triggered only when the exact step text is used and that the regular expressions used for matching are properly anchored. This helps maintain the clarity and accuracy of your step definitions and prevents unintended matches during test execution.
I see that you can run it directly from the feature file. But when I run it from the feature file, it will not execute. I have to run it using the runner class. Please advise.
Hi Raghav!! so i tried the exact same thing you did but with a awebsite of my own. You change your driver to friefox but i stayed in chrome as it opened for me. but the thing is chrome is opening and the website i added is also opening but its not taking the username and password automatically and clicking login as its supposed to. What can i do to fix it?
Leela it can be due to the locators of the text boxes (username, password) are not correct or the elements are not loaded, you can try checking the locators and also add some wait time before this step. Check the logs, what do they say after failure
Hi Jyoti, you can use command line to run tests and use different browsers in options, You can also take help from cloud services like Browserstack, Saucelabs etc
Hi sir. I followed everything you did and it did not work. I then removed the angle brackets at the 'When' statement and it worked. Is this a concern to be worried about?
@@RaghavPal I added another account to test and when i ran the test it went through the first account in my outline twice. Rather than the first account followed by the second.
Parameterizing SOAP requests using Scenario Outline in Selenium Java Cucumber involves defining a Scenario Outline with placeholders for the SOAP request parameters and then providing a set of examples to populate those placeholders. Here's a step-by-step guide: 1. **Create a Scenario Outline:** ```gherkin Scenario Outline: Send SOAP Request with Parameters Given I send a SOAP request to "" Then the SOAP response status code should be ``` 2. **Define Placeholders for Parameters:** Replace `` and `` with placeholders for the SOAP request endpoint URL and expected status code, respectively. 3. **Create Examples Table:** ```gherkin Examples: | endpoint | statusCode | | example.com/soap/ | 200 | | example2.com/soap/ | 404 | | example3.com/soap/ | 500 | ``` Replace the example URLs and status codes with your actual values. 4. **Implement Step Definitions:** Create step definitions for the `Given` and `Then` steps: ```java @Given("I send a SOAP request to {string}") public void sendSOAPRequest(String endpoint) { // Implement SOAP request logic using a SOAP client library } @Then("the SOAP response status code should be {int}") public void verifySOAPResponseStatus(int expectedStatusCode) { // Verify the SOAP response status code } ``` 5. **Run Cucumber Tests:** Execute the Cucumber tests using a Cucumber Runner or a test automation framework like JUnit. The Scenario Outline will be executed for each set of data provided in the Examples table, effectively parameterizing the SOAP requests.
How will we make browser driver dynamic as its version keep changing, now 83, tomorrow it will be 90, so scripts will not work other system, how can we fix this?
Hi Raghav, I tried with chrome and gecko drivers, getting the below when trying with gmail as the website. Any suggestions? This browser or app may not be secure. Learn more Try using a different browser. If you’re already using a supported browser, you can try again to sign in. Regards Rakesh
Hi raghav . I am facing some issues . I am getting error as cucumber.api.cli.main run and it's saying as warning you are using deprecated main class. Please use if.cucumber.cli.main it's saying . What should I need to do to clear this error??
Examples: | Webpage | Category | SearchMethod | ResultNumber | | site1 | Trucks stop | 91911 | 1 | | site2 | Bus stop | 20785 | 1 | If I try to run this it - Opens both site 1 & 2 using its category but it only uses the search method 91911 The Gherkin syntax does not show the step and I cant add an additional step without a (duplicate step) error, could you point me to minute/video explaining this, please? Thanks, @Raghav!!!
Hlo sir i have provided the url from the cucumber table and my scenario is passed but it is not launching the browser.when i hard corded the Url then its working fine.Please sugest me that where is the prob ?
Sakshi The issue you're describing, where Cucumber-Selenium-Java isn't launching the browser when the URL comes from a Cucumber table but works with a hardcoded URL, can have several causes. Here are some possibilities and suggestions: 1. Data Parsing Error: - Check your step definition. Ensure it properly parses the URL data from the Cucumber table. Verify your `String` parameter receives the value correctly. - Double-check typos and whitespace. Minor inconsistencies in the parameter name or table syntax can cause parsing errors. 2. WebDriver Initialization: - Confirm WebDriver configuration. Ensure the WebDriver instance is properly created and initialized to work with the dynamic URL from the table. - Test WebDriver creation separately. Run a step definition that just prints the URL obtained from the table to confirm it's correct. 3. Browser Launching Logic: - Review your browser launching code. Verify it uses the URL variable obtained from the table when navigating. - Check for conditional logic. Ensure there isn't any logic accidentally skipping browser launch when using a dynamic URL. 4. Debugging Tips: - Print debug messages. Add logs within your step definitions and WebDriver setup to track the URL value at different stages and identify potential parsing or usage issues. - Run single scenario. Debug the specific scenario related to the dynamic URL to isolate the problem.
Hi Raghav, I have tried same Parameterization data, but while running the file it is taking 6 digit password and i have mentioned same data what ever you have mentioned, I tried to print the Password then it is showing 5 digits but in screen it is entered 6 digit and showing invalid password
@@RaghavPal implemented print statement it is showing as 12345 but in application it is taking 6 digit and getting invalid password Thanks for your reply
Hi Shanthi, you will need to do some initial analysis and if required can share your understanding with me, I may not be able to take out time for troubleshooting from scratch. Can check this - ua-cam.com/video/745IUcLg7B4/v-deo.html
Hi Raghav, Thanks for your videos. When I am trying to log in to Instagram using the automation testing , the username and password cannot be opened automatically. Can you help me?
Ajay There are a few possible reasons why the username and password fields on the Instagram login page may not be opening automatically when you are using Selenium Java for automation testing: *The username and password fields are not visible on the page.* This could be because they are hidden by CSS or JavaScript. *The username and password fields are not interactive.* This could be because they are disabled or because they are using a custom input type. *There is a race condition between the Selenium Java code and the Instagram login page.* This could be because the username and password fields are being loaded and initialized asynchronously. To troubleshoot this issue, you can try the following: 1. *Check the visibility of the username and password fields.* You can use the `isDisplayed()` method to check if a web element is visible on the page. 2. *Check the interactivity of the username and password fields.* You can use the `isEnabled()` method to check if a web element is interactive. 3. *Add wait statements to your Selenium Java code to give the Instagram login page enough time to load and initialize the username and password fields.* You can use the `WebDriverWait` class to add wait statements. Here is an example of how to add a wait statement to your Selenium Java code: ```java WebDriverWait wait = new WebDriverWait(driver, 10); wait.until(ExpectedConditions.visibilityOf(usernameField)); wait.until(ExpectedConditions.elementToBeClickable(usernameField)); ``` This code will wait for 10 seconds for the username field to become visible and interactive. If the username field does not become visible and interactive within 10 seconds, the test will fail. If you are still having trouble logging in to Instagram using Selenium Java, you can try using a different automation testing framework, such as Cypress or TestCafe. These frameworks are specifically designed for testing web applications, and they may be able to log in to Instagram more reliably than Selenium Java.
Hi ,my previously working project stopped by giving this error .WARNING: You are using deprecated Main class. Please use io.cucumber.core.cli.Main Can you please help me on this?
Hi, ^user enters (.*) and (.*)$ is not working for me. I'm unable to enter password, instead username is filled with both the strings of username and password. Can I know what's the solution for this?
Hello sir ,your videos are very helpfull. I am facing one issue in above concept .I am giving the password as 12345 in config file,still after running the code it is showing password invalid and login is unsuccessful. Could you pls help
I have no doubt selenium is very powerful but like QTP why didn't they enhance it to be record and playback? After all it's web applications testing.... Record, stop, playback then add code to modify as needed! Why didn't they do that? Beats me 😆 🤔
Kris Selenium has it - Selenium IDE www.selenium.dev/selenium-ide/. Can also find my tutorials on this here - ua-cam.com/video/4I7xay_NV8A/v-deo.html ua-cam.com/video/uO8_Dfe4pd4/v-deo.html ua-cam.com/video/bzGsHmEyea0/v-deo.html
@@RaghavPal THX. So can people learn that selenium IDE package directly? And learn minimal Java coding and be good enough to call themselves automation tester? The way I see it, you only need to tweak code if needed. Add delays, conditions, loops ETC.i mean we're not building, we're testing what was built!
it will be very helpful during automation. You can do recording and generate the code and use in your framework projects. I will suggest learning basic programming will help and take you long way
Hi, Raghav, Thanks for the beautiful explanation. Can we use "WebDriverManager.chromedriver().setup();" to avoid these driver versions related issues ?(mvnrepository.com/artifact/io.github.bonigarcia/webdrivermanager). If we use this, then we don't need to keep "chromdriver.exe" files in the Framework Is this recommended ??
Raghav sir, With latest version of cucumber, I'm getting the below issue. Can you please suggestion any solutions Could not find or load main class cucumber.api.cli.Main
Nagraj the error message "Could not find or load main class `cucumber.api.cli.Main`" typically occurs when the specified class cannot be located or loaded during runtime. Let's explore some potential solutions: 1. Check Your Run Configuration: - Verify that your run configuration is correctly set up. Sometimes, after refactoring or module changes, the run configuration might default to an incorrect setup. - Delete all existing configurations (you can find the dropdown in the top right of the IntelliJ IDEA window) and remove the Cucumber Java configuration. - Right-click on the main application you want to run and select "Run" or use the shortcut `Ctrl + Shift + F10`. 2. Update Dependencies: - Ensure that you are using the latest version of Cucumber dependencies. Update the version numbers in your build tool configuration file (e.g., `pom.xml` for Maven or `build.gradle` for Gradle). - Run the following commands to download the latest dependencies: - For Maven: `mvn clean install` - For Gradle: `gradle clean build` 3. Use the Correct Class Name: - The class `cucumber.api.cli.Main` is deprecated. Instead, use `io.cucumber.core.cli.Main`. - Make sure to update your code to reference the correct class name. Remember to adjust your project settings and dependencies accordingly. If you follow these steps, you should be able to resolve the issue.
Hi Sir, Here is the full error message May 07, 2024 11:59:53 PM cucumber.api.cli.Main run WARNING: You are using deprecated Main class. Please use io.cucumber.core.cli.Main io.cucumber.core.exception.CompositeCucumberException: There were 2 exceptions. The details are in the stacktrace below. at io.cucumber.core.runtime.RethrowingThrowableCollector.getThrowable(RethrowingThrowableCollector.java:57) at io.cucumber.core.runtime.CucumberExecutionContext.getThrowable(CucumberExecutionContext.java:109) at io.cucumber.core.runtime.Runtime.run(Runtime.java:78) at io.cucumber.core.cli.Main.run(Main.java:87) at cucumber.api.cli.Main.run(Main.java:30) at cucumber.api.cli.Main.main(Main.java:15) Suppressed: java.lang.UnsupportedClassVersionError: org/openqa/selenium/WebDriver has been compiled by a more recent version of the Java Runtime (class file version 55.0), this version of the Java Runtime only recognizes class file versions up to 52. at java.lang.ClassLoader.defineClass(ClassLoader.java:756) at java.net.URLClassLoader$1.run(URLClassLoader.java:363) at java.security.AccessController.doPrivileged(Native Method) at java.lang.Class.getDeclaredMethods0(Native Method) at io.cucumber.java.MethodScanner.safelyGetMethods(MethodScanner.java:39) at io.cucumber.java.MethodScanner.scan(MethodScanner.java:32) at io.cucumber.java.JavaBackend.lambda$loadGlue$2(JavaBackend.java:41) at java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:184) at io.cucumber.core.runtime.SingletonRunnerSupplier.createRunner(SingletonRunnerSupplier.java:44) Suppressed: java.lang.UnsupportedClassVersionError: org/openqa/selenium/WebDriver has been compiled by a more recent version of the Java Runtime (class file version 55.0), this version of the Java Runtime only recognizes class file versions up to 52.0 at java.lang.ClassLoader.defineClass1(Native Method) I installed the new eclipse and fallowed your videos also but getting the same error. Any paid support call from you sir? I need to implement a new project for my company
Let's break down the error messages and address them step by step: 1. Deprecated Main Class Warning: - The warning message indicates that you're using a deprecated Main class for running Cucumber tests. - To resolve this, update your test runner class to use the new `io.cucumber.core.cli.Main` class instead of the deprecated one. - Make sure your test runner class (the one annotated with `@RunWith(Cucumber.class)`) references the correct classpath for your feature files. For example: ```java import org.junit.runner.RunWith; import cucumber.api.CucumberOptions; import cucumber.api.junit.Cucumber; @RunWith(Cucumber.class) @CucumberOptions(features = "classpath:com/yourgroup/yourartifact/cucumber/features") public class RunCucumberTest { // Your test configuration } ``` - Replace `"classpath:com/yourgroup/yourartifact/cucumber/features"` with the actual path to your feature files. 2. UnsupportedClassVersionError: - This error occurs because the `org.openqa.selenium.WebDriver` class has been compiled with a newer version of Java (class file version 55.0), but your current Java Runtime only recognizes class file versions up to 52. - To fix this, ensure that your project is using a compatible Java version. You can check your Java version by running `java -version` in your terminal. - If you're using an older Java version, consider upgrading to a more recent one (Java 8 or higher). 3. Eclipse Configuration: - Since you mentioned installing a new Eclipse, make sure you've configured your project correctly within Eclipse. - Verify that your project is using the correct Java SDK (matching the version you want to use). - Also, check if your project build path includes the necessary Selenium and Cucumber dependencies. 4. Implementing a New Project: - If you're starting a new project for your company, consider the following steps: - Create a new Maven or Gradle project (depending on your preference). - Add the necessary dependencies for Selenium (e.g., `webdriver`, `webdrivermanager`) and Cucumber (e.g., `cucumber-java`, `cucumber-junit`). - Set up your feature files, step definitions, and test runner class. - Write your BDD scenarios in Gherkin syntax within the feature files. - Implement the step definitions to map Gherkin steps to Java code. - Run your tests using the updated test runner class. Remember to keep your Java version consistent across your project and ensure that all dependencies are correctly configured ---
watching all Cucumber java videos one by one..really helpful...Thanks
You are most welcome Shaji
I was having problem with learning cucumber from other sources. But the way you explain i didnt have any problem understanding. It feels like i found my source of learning all things from you. Thank you very much for working so hard to teach others.
Most welcome
@@RaghavPal Also i dont know if its appropriate to ask here or not. I am working as mechanical Quality engineer from past 10 years but now i watch to switch to IT domain . I have learnt Cucumber with Selenium and also have certification on Selenium with java . Now every recruiter needs experienced people. Do i have any chance to get an interview call as fresher at age of 32. Is it possible to join as fresher in selenium web testing??
Hi, you can learn some more relevant tools and platforms and make some personal projects, upload your projects on GitHub and add the links in your Resume, this will give your profile more weightage and will help in interviews
Thank you Raghav. your sessions are soo good. This session will sure helps the fresher or manual tester to kick start their automation skill
Most welcome Preethi
Hi Raghav, I have watched and recommend this playlist to all my friends and must say its really helpful and easy to understand through your videos. I have one question, can I parameterize rows with no fix column? Such as in 1st row there are 5 column and and in second only 4 and so on. Can I do it using Scenario Outline?
Glad to know this Raj, you can do but will need to have a logic mostly scripted in step definition as per your needs and scenario.
Thank you Raghav sir, you have explained it and clearing out all of our clarifications 👍
Thanks, Raghav for very well explained the Parameterization and Data-Driven Testing. Can we use data files i.e CSV, Excel, and database(Oracle.etc) instead of mentioned data details in the feature files? If yes could you please add that video in near future?
Yes, we can do that Mayank, will plan to add a session on that
only word i can say after watching the video is amazing and thank you for making such videos.
Thank you so much 😀
Thank you, sir, you made it very simple and easy. I am very grateful.
You are welcome Ali
Thank you Raghav, u made us very simple to learn...please make video on how to handle Multiple Feature files with different combinations in reality and how to handle Datatables with Maps
Sure I will Rajesh
Thank you very much Raghav, thoroughly explained.
could you please make videos for
1. data driven testing using properties file as an input
2. how to test sqls/unix commands in cucumber.
3. how to test soap/rest API's using cucumber.
it would be a great help:)
Yes, soon Supriya
Informative and nice explanation. Thank you !
Glad it was helpful Sireesha
Thank u Raghav...This is an amazing video for beginners
Glad you liked it Pallavi
Thank you Raghav ! very helpful and clear explanation.
Most welcome Adel
HI RAGHAV YOU R A GENIUS 🙏
humbled, thanks Jigar
Nice explanation, glad that I found your videos on many topics - very clear and you make them so simple to remember. great effort and keep going and help all the curious learners.
Have one question, as here passed 2 sets of data, but if we have multiple sets of data(may be 100 sets) then how to parameterize. Should we use a third party file like .xls or .xslx. If so then how to read the data from the file.
Hi, for a large data set, it is always useful to externalize the data and use options like excel, csv, json files. I will create a session on this. For now this can help you - ua-cam.com/video/B4G2tMDYjRQ/v-deo.html
super Raghav👌nice lecture to data driven testing in cucumber
Thank you so much Ganesh.. keep watching
Thanks Raghav. Its Really helpful. Could you please make a video on how to register a website using Datatable in BDD Cucumber.
Hi Suvendu, sure, pls also give me the scenario example of this
@@RaghavPal Suppose we have to register for one or more user on Gillette India website.
Okay, I will plan
@@RaghavPal Thanks a lot.❤️
Hi Raghav, This video was very helpful for me.Thank you very much.👍👍
Glad to hear that Ismail
Hi Raghav,
As always, thanks for the tutorial. I've followed this tutorial and saw some exceptions as I switched to use gecko/FireFox (geckodriver-v0.27.0-win64 and Firefox 81.0 64 bit).
For any scenario, at the final step I see the exception:
" org.openqa.selenium.NoSuchWindowException: Browsing context has been discarded"
Here is the exception from Eclipse terminal:
Scenario Outline: Check login is successfull with valid crredentials # src/test/resources/Features/LoginDemo.feature:13
Inside Step: browser is open
projectPath = C:\Working\Git\GitRepos\eclipse-workspace\CucumberJava
1601168425609 geckodriver INFO Listening on 127.0.0.1:11548
1601168426121 mozrunner::runner INFO Running command: "C:\\Program Files\\Mozilla Firefox\\firefox.exe" "--marionette" "-foreground" "-no-remote" "-profile" "C:\\Users\\steve\\AppData\\Local\\Temp\
ust_mozprofileBO7fNN"
Can't find symbol 'eglSwapBuffersWithDamageEXT'.
JavaScript error: resource://gre/modules/XULStore.jsm, line 66: Error: Can't find profile directory.
console.error: SearchCache: "_readCacheFile: Error reading cache file:" (new Error("", "(unknown module)"))
1601168431595 Marionette INFO Listening on port 49198
1601168431950 Marionette WARN TLS certificate errors will be ignored for this session
Sep 26, 2020 8:00:32 PM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Detected dialect: W3C
Given browser is open # StepDefinitions.LoginDemoSteps.browser_is_open()
Inside Step: user is on login page
And user is on login page # StepDefinitions.LoginDemoSteps.user_is_on_login_page()
When user enters Esther and 12345 # StepDefinitions.LoginDemoSteps.user_enters_username_and_password(java.lang.String,java.lang.String)
And user clicks on login # StepDefinitions.LoginDemoSteps.user_clicks_on_login()
org.openqa.selenium.NoSuchWindowException: Browsing context has been discarded
Build info: version: '4.0.0-alpha-6', revision: '5f43a29cfc'
System info: host: 'ONGS-41', ip: '192.168.1.97', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '14.0.2'
Driver info: org.openqa.selenium.firefox.FirefoxDriver
Capabilities {acceptInsecureCerts: true, browserName: firefox, browserVersion: 81.0, javascriptEnabled: true, moz:accessibilityChecks: false, moz:buildID: 20200917005511, moz:geckodriverVersion: 0.27.0, moz:headless: false, moz:processID: 31584, moz:profile: C:\Users\steve\AppData\Loca..., moz:shutdownTimeout: 60000, moz:useNonSpecCompliantPointerOrigin: false, moz:webdriverClick: true, pageLoadStrategy: normal, platform: WINDOWS, platformName: WINDOWS, platformVersion: 10.0, rotatable: false, setWindowRect: true, strictFileInteractability: false, timeouts: {implicit: 0, pageLoad: 300000, script: 30000}, unhandledPromptBehavior: dismiss and notify}
Session ID: f78aa9b9-95d9-4ff2-b31c-1f4e478091b5
*** Element info: {Using=id, value=login}
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.newInstanceWithCaller(Constructor.java:500)
at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:481)
at org.openqa.selenium.remote.codec.w3c.W3CHttpResponseCodec.createException(W3CHttpResponseCodec.java:196)
at org.openqa.selenium.remote.codec.w3c.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:129)
at org.openqa.selenium.remote.codec.w3c.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:53)
at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:160)
at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:83)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:582)
at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:333)
at org.openqa.selenium.remote.RemoteWebDriver.findElementById(RemoteWebDriver.java:381)
at org.openqa.selenium.By$ById.findElement(By.java:194)
at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:325)
at StepDefinitions.LoginDemoSteps.user_clicks_on_login(LoginDemoSteps.java:45)
at ✽.user clicks on login(file:///C:/Working/Git/GitRepos/eclipse-workspace/CucumberJava/src/test/resources/Features/LoginDemo.feature:7)
Then user is navigate to the home page # StepDefinitions.LoginDemoSteps.user_is_navigate_to_the_home_page()
Failed scenarios:
file:///C:/Working/Git/GitRepos/eclipse-workspace/CucumberJava/src/test/resources/Features/LoginDemo.feature:13# Check login is successfull with valid crredentials
2 Scenarios (1 failed, 1 passed)
10 Steps (1 failed, 1 skipped, 8 passed)
0m33.959s
.... Any help would be appreciated.
Update on this issue:
If I code the last step like this:
------------------------------
@Then("user is navigate to the home page")
public void user_is_navigate_to_the_home_page() throws InterruptedException {
driver.findElement(By.id("saved")).isDisplayed();
Thread.sleep(2000);
driver.close();
Thread.sleep(2000);
// driver.quit();
}
------------------------------
... Then I am able to pass all scenarios (I still seeing an error, though) :
--------------------------
Given browser is open # StepDefinitions.LoginDemoSteps.browser_is_open()
Inside Step: user is on login page
And user is on login page # StepDefinitions.LoginDemoSteps.user_is_on_login_page()
When user enters Esther and 12345 # StepDefinitions.LoginDemoSteps.user_enters_username_and_password(java.lang.String,java.lang.String)
And user clicks on login # StepDefinitions.LoginDemoSteps.user_clicks_on_login()
1601171372702 Marionette INFO Stopped listening on port 50483
###!!! [Child][RunMessage] Error: Channel closing: too late to send/recv, messages will be lost
###!!! [Child][MessageChannel::SendAndWait] Error: Channel error: cannot send/recv
Then user is navigate to the home page # StepDefinitions.LoginDemoSteps.user_is_navigate_to_the_home_page()
2 Scenarios (2 passed)
10 Steps (10 passed)
0m32.412s
------------------------------
Hi believe this is coming only for Firefox (Gecko Driver ). check this github.com/mozilla/geckodriver/issues/1279
@@RaghavPal
I agreed. Thanks for looked it up.
Hi raghav, thanks for the tutorial,
do you mind show me how to create a logger for cucumber? Thank you in advance..
I will check on this Intan
Hi Raghav, I really like your way of explaining i have one question what is difference between data table and scenario outline ??
Hi Sonali, check this priyank-it.medium.com/cucumber-difference-between-examples-table-data-table-21501f2becbd
Thanks nice explained.
You are welcome
Thanks for Sharing 🙏🏻🙏🏻
So nice of you
Thank you so much sir, it's very easy to understand the way you explain.
Words fall short to thank you for this service.
I jus wanted to ask you can we implement in the same way in real time too?
You are most welcome Supriya, yes this is how we implement real projects, Basics remain same and then you can grow over it as per the needs
Thanks Raghav. Wonderful videos. These are extremely helpful as I am completely new to automation. Can I use the same framework with Appium also.
Yes, you can Sujatha, You can also check other tutorials here - automationstepbystep.com/
At 8:31 , line 41, you said put (.*) for a string. What is the difference between {string} and (.*)? My eclipse didn't run on (.*) (MAC computer)
Hi Seyma, there are diff ways to match a text using regular expression. This story can help you understand better - automationstepbystep.com/2020/05/05/a-story-of-regex/
Thank you very much sir, amazing work
Most welcome Dimuthu
Hi Raghav,
Thanks for sharing knowledge, appreciate all your efforts and help..I have one query as below, could you please guide me on the same.
What if I want open a browser only once and then scenario needs to run multiple time with scenario outline with multiple data mentioned in example, how I can I achieve this.
For e.g. - I have simple scenario to select report name from the drop-down and click on view button and verify report header, along with data and row count is available.(likewise I have 5 reports in drop-down) So in this scenario I just want to open the browser only once and navigate to the page and perform the scenario I mentioned
Hi, you can put the browser open and navigate to url steps in Background
Thanks, Raghav very well explained. Can we use data files as CSV or excel for parameterization instead of examples in feature file ? If yes, could you make a video for the same .
Yes, we can, will try a session on this
Sir apart from giving direct values can we add some Excel file here??
In data driven?
Yes, we can, This video will be helpful - ua-cam.com/video/B4G2tMDYjRQ/v-deo.html
@@RaghavPal sir with Java +selenium I know to read the data...
But i was asking about in cucumber how to attach the Excel file for data driven ?
The basic code with remain the same (java Code) can check some examples online
@@RaghavPal ok sir thank you so much for your time 🙏
Hi Raghav, Great tutorial. I have a small doubt. Why do we have to use ^$ in the When statement. In regex they are used to restrict and match groups. How does using them resolve the error which was thrown first?
Hi Shanjay, although I may have to go a little deeper and check on that, looks like its some syntax in cucumber.
@@RaghavPal No need for the trouble of checking deeper. Just was curious. Thank you so much for the response. If I find out the reason, I will try and post in the comments. Cheers!
Very nicely explained, Thanks Raghav!! ..Can you tell how we can read or write from excel in this?
Hi Soumya, will create a session. For now this can help you - ua-cam.com/video/B4G2tMDYjRQ/v-deo.html
Raghav, can we use jdbc driver to connect database in cucumber?
Does cucumber perform database testing ?
Hi Suhas, Yes, can do
Hello Raghav
Dont we need to use test runner class to run the test?
You can, just follow the steps
Hi Raghav, Thanks I was able to login to some other website following your video.One query, I have why we have not created a "Test Runner " here and run the feature file here unlike previous videos.Regards.
Hi Monica, you can run using Test Runner too, I gave examples to show all options
@@RaghavPal Ok thanks.Have you created some content on api testing with karate framework.
Pls ignore it Raghav,I am referring your series on Karate.Thanks.
Hi Raghav, Do you provide private training as well.
No Navdeep
Hi raghav. Thankyou so much for this valuable sessions.. but we want to do this in Intellij Ide so could you please make more sessions by using intellij not with eclips.
I will plan Sowmya
Thank you so much 😄
Most welcome Hari
Thanks raghav .
Most welcome
Thanks a lot really helpful!
You're welcome Abdul
Hi Raghav, good tutorial. Very understandable and precise. Only issue I currently have is I am getting duplicate step definition error which I need to figure out. Let me know how to overcome it. Thanks
Hi, please check if there are any functions have same feature file annotation i.e. referencing similar statements of any feature files
@@RaghavPal Yes I have used similar statements in 2 feature files. How to overcome this since I need those statements in both my features > scenarios.
So you can keep a single function in step definition for this if they are doing the same actions
@@RaghavPal I have mentioned exactly what I am doing below:
Feature 1
Scenario 1
Given User opens chrome browser
Feature 2
Scenario 1
Given User opens chrome browser
StepDefinition class for Feature 1 I have used Given User opens chrome browser
StepdDefinition class for Feature 2 I have used Given User opens chrome browser
Hence when I run them it throws duplicate step definition error (Which is what we discussed earlier)
If I remove it from Feature 2 it fails after chrome browser opens giving an error driver is null for the next function.
So wanted to know how to use the same step in feature 2 StepDefinition class.
Do not remove from feature, but from step definition, So there are 2 ways, either remove the function from one of the step definition OR use a different statement (unique) in 2nd feature and update the step definition accordingly
OR another way will be to use the runner class and provide the path of the exact step definition you want to use
stackoverflow.com/questions/55659393/getting-cucumber-runtime-duplicatestepdefinitionexception-despite-adding-backgro/55659727
Hi raghav, can u make a video. For selenium grid tests to. Run selenium tests with different. Nodes. Especially Android tablets as a node
I will plan Jino
Hi Raghav, I have a query when i run logindemo.feature file data is not inserted user name is enter like this i am using ur same code.code is running only one time.
If you are using parameterized values within conical brackets, then you should provide data table in Examples section and the values should be given as arguments in the corresponding function in Step Definition. Check in the video again
Hi Raghav, could you please explain us how to fetch data from excel in cucumber.
Hi Sneha, can check this: ua-cam.com/video/B4G2tMDYjRQ/v-deo.html
Can you please make a video on creating runner file and what is its significance?
Hi Sagar, I must have covered that in some of the video in this series
Thank you so much for the detailed explanation,🙌
Your video genuinely helped me a lot...!🙏🙏
while executing, the only changed i observed is if we want to give the sets of username and password then in steps file we have to insert (.+) instead of (.*) and we have to mention the username and password keyword of feature file in instead of " " as the keyword mentioned in " " is static.
These changes might differ according to the systems and the softwares.
Please correct me if i am wrong..!
Thanks for adding Omkar
Hi Raghav, Thanks for your tutorial on parameterization. Could you please tell me how we do drive the test data from excel using SQL queries? Thanks in advance.
Hi Asritha, I will plan to create a session on this
@@RaghavPal thank you:)
Hi @Raghav which version of Eclipse did you use ? I am getting error and cannot install Cucumber plugin for Eclipse 2020-12 developer Version. Need your help for this please
Hi Meena, Eclipse 2020-12 should be fine, what exactly is the issue you are facing, can also check online
nice video bro keep uploading
Thank you, I will Amit
Thanks so much raghav. Could make a video for BDD-datadriven using JSON file as a input.
I will plan
@@RaghavPal thx for your response 👍
Nicely explained with Basics Thanks a lot sir ji
Hi raghav,
Is there any way to read examples data in feature file from external file like CSV, Excel or json?, Since my data is huge
Hi Trilok
Yes, you can read examples data in the feature file from external files like CSV, Excel, or JSON using a data provider. Here are the steps to do it:
Add the data provider library to your project, such as Apache POI for Excel or OpenCSV for CSV.
Create a class to read data from the external file and return it in a format that can be used by your step definitions. For example, you can create a method that reads data from a CSV file and returns a list of maps, where each map represents a row in the CSV file and contains key-value pairs for each column in the row.
Annotate your scenario with the data provider and specify the method that reads the external file as the data provider. You can also specify the data format, such as "csv" or "excel".
Can find some examples and code online
@@RaghavPal ,
Thanks raghav for quick response ❤️, please share me if we already have any video tutorial, raghav
I do not have a specific focussed video on this, but if you check the video using @DataProvider annotation, the same can be used here ua-cam.com/video/B4G2tMDYjRQ/v-deo.html
What is the use of expression ^ and $?
These are used for regular expressions. Can check this - automationstepbystep.com/2020/05/05/a-story-of-regex/
Thanks Guru
Most welcome
Hi, I came across one scenarios, where I need to run the TestRunner class
using cucumber Cli, but the TestRunner is not able to genearte any report
can you, Please sugggest any ideas/approach to achieve that?
cucumberCliExampple
- jars
- test
- stepdefinitions
- *.java
- features
- *.feature
- TestRunner.java
Hi Dushmanta, do you get any logs for this. I will need to check the setup. Try to check some online examples too
Hi Raghav is it enough to understand cucumber framework
Hi Sanjeeva, If you complete this playlist, it will be enough
If there 2 two scenarios here.. in 1 we are testing valid login and in another we are testing invalid login with wrong credentials, then for both the scenarios we have to write "Scenario Outline"? or for first scenario it would be "Scenario Outline" and for 2nd it would be just "Scenario"?
You can use a scenario outline for both the scenarios, or you can use a scenario for the first scenario and a scenario outline for the second scenario. It depends on how you want to parameterize your tests.
If you want to test multiple valid login credentials, then you can use a scenario outline. For example, the following scenario outline would test the login functionality with three different valid login credentials:
```
Scenario Outline: Login with valid credentials
Given I am on the login page
When I enter the username ""
And I enter the password ""
And I click the login button
Then I should be logged in
Examples:
| username | password |
| johndoe | password |
| janedoe | password |
| admin | admin |
```
If you only want to test a single valid login credential, then you can use a scenario. For example, the following scenario would test the login functionality with the username "johndoe" and the password "password":
```
Scenario: Login with valid credentials
Given I am on the login page
When I enter the username "johndoe"
And I enter the password "password"
And I click the login button
Then I should be logged in
```
If you want to test multiple invalid login credentials, then you can use a scenario outline. For example, the following scenario outline would test the login functionality with three different invalid login credentials:
```
Scenario Outline: Login with invalid credentials
Given I am on the login page
When I enter the username ""
And I enter the password ""
And I click the login button
Then I should see an error message
Examples:
| username | password |
| invalid | invalid |
| username | wrong_password |
| wrong_username | password |
```
If you only want to test a single invalid login credential, then you can use a scenario. For example, the following scenario would test the login functionality with the username "invalid" and the password "invalid":
```
Scenario: Login with invalid credentials
Given I am on the login page
When I enter the username "invalid"
And I enter the password "invalid"
And I click the login button
Then I should see an error message
```
Ultimately, the decision of whether to use a scenario or a scenario outline depends on your specific needs and preferences.
Hello Raghav, I really appreciate the way you are providing details. It is really helping me. I request to solve this issue when I do your cucumber above part 5, am getting an error as "Null Pointer Exception" though I declared webdriver driver=null. Please help, I stuck here and I tried all the ways making static , public that webdriver.
Hi Praveen, what does the logs say, hope you have added all libraries
I added to Scenario Outline Examples invalid credentials and test still passed. Could you explain why?
Have you added any assertions, test will pass or fail based on your assertions
@@RaghavPal thanks for fast answer, I thought about it, but as you didnt code assertion in your video I thought i can achieve the same result by for example declaring boolean login.logoutDisplayed(); (where logoutDisplayed is a function to locate logout button ofc), but it was not working. Ok i got it assertion is needed. Thank you for your videos man!
Hi Raghav thanks for the video.i have implemented same but every time when I run i am getting steps as undefined and test is being skipped.Can you help on this please
Hi Deepika, check your test (class) names. It should start with Test or have this in the name.
Hi Raghav, please help me. My parameterisation is not working.
@When("^user enters valid (.*) and valid (.*) and login$")
public void user_enters_valid_username_and_valid_passward_and_login(String str1, String str2) {
}
Tried this
eclipse (after running as cucumber file) is giving wrong code tidy gherkin is giving code with .+ , but not working. I practiced before they worked but now eclipse is behaving different. why? I have recently changed my java version though (to practice jerkins). before it was 16, now I am using jdk11. what to do? I want to make a selenium cucumber framework but this problem is happening.I am frastrated.
first data set is passing through but others not .
Thanks in advance
Hi, I will need to check, not sure if this is due to java
@@RaghavPal Thanks . not for java. Because I have installed again new eclipse. java 16. Something is happening after converting the maven project to cucumber project. May be some problem with latest cucumber plugin in eclipse. don't know .Any way really thanks for your reply. I was thinking to practice to build a cucumber selenium framework but now decided to do selenium testng first . Thanks
Hi raghav getting this error in data driven framework io.cucumber.core.gherkin.FeatureParserException while running feature file ?
Hi Vipin, it can be typo
Can check this stackoverflow.com/questions/62261565/io-cucumber-core-gherkin-featureparserexception-failed-to-parse-resource-at
Please show how to use data table in Cucumber.
Hi Rajendra, did that in earlier video of this series. Pls check automationstepbystep.com/
Could anyone please confirm, why ^$ is added on the step definition(part 5 video,at 14.00 minutes)
thank you
Abhisek
In Cucumber, adding `^$` to the beginning and end of a step definition serves two primary purposes:
1. **Restricting Step Matching:** The `^` (caret or hat) symbol at the beginning of the step definition indicates that the entire step text should match the Gherkin step text. This helps prevent unintended step matches and ensures that the step definition is only triggered when the exact step text is used.
2. **Anchoring Regular Expressions:** The `$` (dollar sign) symbol at the end of the step definition anchors the regular expression used to match the step text. This prevents the regular expression from matching beyond the specified step text, ensuring that the step definition only captures the intended information.
By using `^$`, you can ensure that your step definitions are triggered only when the exact step text is used and that the regular expressions used for matching are properly anchored. This helps maintain the clarity and accuracy of your step definitions and prevents unintended matches during test execution.
I see that you can run it directly from the feature file. But when I run it from the feature file, it will not execute. I have to run it using the runner class. Please advise.
Hi Henry, Pls check the setup and all the steps again, Hope you have got the cucumber plugin, restart eclipse
@@RaghavPal I got it. It was my "run as" configuration issue. Thanks!
Hi Raghav, how do i read from .yaml file? thanks!
Hi Adrienne, I will consider this in a session. for now pls take online help
Hi Raghav!! so i tried the exact same thing you did but with a awebsite of my own. You change your driver to friefox but i stayed in chrome as it opened for me. but the thing is chrome is opening and the website i added is also opening but its not taking the username and password automatically and clicking login as its supposed to. What can i do to fix it?
Leela
it can be due to the locators of the text boxes (username, password) are not correct or the elements are not loaded, you can try checking the locators and also add some wait time before this step.
Check the logs, what do they say after failure
how can we run secnario outline in parallel form..? And in Different browser at a same time.?
Hi Tanmay, we can use options like TestNG
@@RaghavPal Can you please add a video tutorial of that..?
I will plan
How to perform cross Browser testing in cucumber ... Could you please help
Hi Jyoti, you can use command line to run tests and use different browsers in options, You can also take help from cloud services like Browserstack, Saucelabs etc
Selenium database testing please
I will plan
Hi sir. I followed everything you did and it did not work. I then removed the angle brackets at the 'When' statement and it worked. Is this a concern to be worried about?
should be okay if its working
@@RaghavPal I added another account to test and when i ran the test it went through the first account in my outline twice. Rather than the first account followed by the second.
ok
Hi raghav , your demo site is not working in my system, what to do ?
will need more details on this.What exactly and which step
How to parameterize soap requests using scenario outline
Parameterizing SOAP requests using Scenario Outline in Selenium Java Cucumber involves defining a Scenario Outline with placeholders for the SOAP request parameters and then providing a set of examples to populate those placeholders.
Here's a step-by-step guide:
1. **Create a Scenario Outline:**
```gherkin
Scenario Outline: Send SOAP Request with Parameters
Given I send a SOAP request to ""
Then the SOAP response status code should be
```
2. **Define Placeholders for Parameters:**
Replace `` and `` with placeholders for the SOAP request endpoint URL and expected status code, respectively.
3. **Create Examples Table:**
```gherkin
Examples:
| endpoint | statusCode |
| example.com/soap/ | 200 |
| example2.com/soap/ | 404 |
| example3.com/soap/ | 500 |
```
Replace the example URLs and status codes with your actual values.
4. **Implement Step Definitions:**
Create step definitions for the `Given` and `Then` steps:
```java
@Given("I send a SOAP request to {string}")
public void sendSOAPRequest(String endpoint) {
// Implement SOAP request logic using a SOAP client library
}
@Then("the SOAP response status code should be {int}")
public void verifySOAPResponseStatus(int expectedStatusCode) {
// Verify the SOAP response status code
}
```
5. **Run Cucumber Tests:**
Execute the Cucumber tests using a Cucumber Runner or a test automation framework like JUnit.
The Scenario Outline will be executed for each set of data provided in the Examples table, effectively parameterizing the SOAP requests.
@@RaghavPal thank teacher
How will we make browser driver dynamic as its version keep changing, now 83, tomorrow it will be 90, so scripts will not work other system, how can we fix this?
We can use Webdriver Manager, Check this - ua-cam.com/video/8vWTgyoG0nc/v-deo.html
I have used the ^ and $ but it is not worked and thrown an error like "you cannot use anchors (^ or $) in Cucumber expressions"
check some examples online and try
Hi Raghav,
I tried with chrome and gecko drivers, getting the below when trying with gmail as the website. Any suggestions?
This browser or app may not be secure. Learn more
Try using a different browser. If you’re already using a supported browser, you can try again to sign in.
Regards
Rakesh
Hi Rakesh, this can help - stackoverflow.com/questions/59380356/how-to-handle-browser-or-app-may-not-be-secure-issue-with-web-driver-selenium-py
Please ,how do i change feature file to português (Brazil)?. For him to generate in my language.
Not sure on this Mike, will need to check online
sir , while running program password is invalid comes in both d times i set pass 12345 for both username so whts d problem?
Hi Snehal, not sure, send me the url
@@RaghavPal thanks sir for your reply..problem has been resolved.. the password was taking extra white space so I used the trim method.
@@snehaldatir2419 i have the same issue, how can iuse the trim method ?
Hi raghav . I am facing some issues . I am getting error as cucumber.api.cli.main run and it's saying as warning you are using deprecated main class. Please use if.cucumber.cli.main it's saying . What should I need to do to clear this error??
Hi Keerthana, in case its only warning, you can continue
Web is not opening
will need more details, may be your browser and driver ver not compatible
Examples:
| Webpage | Category | SearchMethod | ResultNumber |
| site1 | Trucks stop | 91911 | 1 |
| site2 | Bus stop | 20785 | 1 |
If I try to run this it - Opens both site 1 & 2 using its category but it only uses the search method 91911
The Gherkin syntax does not show the step and I cant add an additional step without a (duplicate step) error,
could you point me to minute/video explaining this, please? Thanks, @Raghav!!!
I can't seem to use both integer and string from the same column
that solved the issue, thanks ton for your vids!
great to know
How to create automation mobile with flutter driver ?
Hi, As of now, I have not worked on this
Hlo sir i have provided the url from the cucumber table and my scenario is passed but it is not launching the browser.when i hard corded the Url then its working fine.Please sugest me that where is the prob ?
Sakshi
The issue you're describing, where Cucumber-Selenium-Java isn't launching the browser when the URL comes from a Cucumber table but works with a hardcoded URL, can have several causes. Here are some possibilities and suggestions:
1. Data Parsing Error:
- Check your step definition. Ensure it properly parses the URL data from the Cucumber table. Verify your `String` parameter receives the value correctly.
- Double-check typos and whitespace. Minor inconsistencies in the parameter name or table syntax can cause parsing errors.
2. WebDriver Initialization:
- Confirm WebDriver configuration. Ensure the WebDriver instance is properly created and initialized to work with the dynamic URL from the table.
- Test WebDriver creation separately. Run a step definition that just prints the URL obtained from the table to confirm it's correct.
3. Browser Launching Logic:
- Review your browser launching code. Verify it uses the URL variable obtained from the table when navigating.
- Check for conditional logic. Ensure there isn't any logic accidentally skipping browser launch when using a dynamic URL.
4. Debugging Tips:
- Print debug messages. Add logs within your step definitions and WebDriver setup to track the URL value at different stages and identify potential parsing or usage issues.
- Run single scenario. Debug the specific scenario related to the dynamic URL to isolate the problem.
Hi Raghav,
I have tried same Parameterization data, but while running the file it is taking 6 digit password and i have mentioned same data what ever you have mentioned, I tried to print the Password then it is showing 5 digits but in screen it is entered 6 digit and showing invalid password
Hi Shanthi, try to use print statements to check what value is referred.
@@RaghavPal implemented print statement it is showing as 12345 but in application it is taking 6 digit and getting invalid password
Thanks for your reply
Will need to check and troubleshoot this Shanthi.
@@RaghavPal could you please share mail id to send my code
Hi Shanthi, you will need to do some initial analysis and if required can share your understanding with me, I may not be able to take out time for troubleshooting from scratch. Can check this - ua-cam.com/video/745IUcLg7B4/v-deo.html
Hi Raghav,
Thanks for your videos. When I am trying to log in to Instagram using the automation testing , the username and password cannot be opened automatically. Can you help me?
Ajay
There are a few possible reasons why the username and password fields on the Instagram login page may not be opening automatically when you are using Selenium Java for automation testing:
*The username and password fields are not visible on the page.* This could be because they are hidden by CSS or JavaScript.
*The username and password fields are not interactive.* This could be because they are disabled or because they are using a custom input type.
*There is a race condition between the Selenium Java code and the Instagram login page.* This could be because the username and password fields are being loaded and initialized asynchronously.
To troubleshoot this issue, you can try the following:
1. *Check the visibility of the username and password fields.* You can use the `isDisplayed()` method to check if a web element is visible on the page.
2. *Check the interactivity of the username and password fields.* You can use the `isEnabled()` method to check if a web element is interactive.
3. *Add wait statements to your Selenium Java code to give the Instagram login page enough time to load and initialize the username and password fields.* You can use the `WebDriverWait` class to add wait statements.
Here is an example of how to add a wait statement to your Selenium Java code:
```java
WebDriverWait wait = new WebDriverWait(driver, 10);
wait.until(ExpectedConditions.visibilityOf(usernameField));
wait.until(ExpectedConditions.elementToBeClickable(usernameField));
```
This code will wait for 10 seconds for the username field to become visible and interactive. If the username field does not become visible and interactive within 10 seconds, the test will fail.
If you are still having trouble logging in to Instagram using Selenium Java, you can try using a different automation testing framework, such as Cypress or TestCafe. These frameworks are specifically designed for testing web applications, and they may be able to log in to Instagram more reliably than Selenium Java.
Code not visible properly due to subtitles
will need more details and context to help on this Sunil
you can change subtitle size and locations on your own
Hi ,my previously working project stopped by giving this error .WARNING: You are using deprecated Main class. Please use io.cucumber.core.cli.Main
Can you please help me on this?
Hi Suchi, can try changing cucumber ver
Hi, ^user enters (.*) and (.*)$ is not working for me. I'm unable to enter password, instead username is filled with both the strings of username and password. Can I know what's the solution for this?
Hi Apoorva, pls check if you have used exactly the same syntax as shown, Can copy from some website having similar examples
Hello sir ,your videos are very helpfull.
I am facing one issue in above concept .I am giving the password as 12345 in config file,still after running the code it is showing password invalid and login is unsuccessful. Could you pls help
Hi Rajat, where did you set this password
@@RaghavPal in the feature file itself
will need to check the syntax
That means Firefox are not in the game yet looking at the gecko driver they are still developing
it is used for automation testing, but yes chrome is most widely used today
I have no doubt selenium is very powerful but like QTP why didn't they enhance it to be record and playback? After all it's web applications testing....
Record, stop, playback then add code to modify as needed! Why didn't they do that? Beats me 😆 🤔
Kris
Selenium has it - Selenium IDE www.selenium.dev/selenium-ide/. Can also find my tutorials on this here -
ua-cam.com/video/4I7xay_NV8A/v-deo.html
ua-cam.com/video/uO8_Dfe4pd4/v-deo.html
ua-cam.com/video/bzGsHmEyea0/v-deo.html
@@RaghavPal THX. So can people learn that selenium IDE package directly? And learn minimal Java coding and be good enough to call themselves automation tester?
The way I see it, you only need to tweak code if needed. Add delays, conditions, loops ETC.i mean we're not building, we're testing what was built!
it will be very helpful during automation. You can do recording and generate the code and use in your framework projects. I will suggest learning basic programming will help and take you long way
Hi, Raghav, Thanks for the beautiful explanation.
Can we use "WebDriverManager.chromedriver().setup();" to avoid these driver versions related issues ?(mvnrepository.com/artifact/io.github.bonigarcia/webdrivermanager). If we use this, then we don't need to keep "chromdriver.exe" files in the Framework
Is this recommended ??
Yes you can Shiva. Pls watch this - ua-cam.com/video/8vWTgyoG0nc/v-deo.html
Raghav sir,
With latest version of cucumber, I'm getting the below issue. Can you please suggestion any solutions
Could not find or load main class cucumber.api.cli.Main
Nagraj
the error message "Could not find or load main class `cucumber.api.cli.Main`" typically occurs when the specified class cannot be located or loaded during runtime. Let's explore some potential solutions:
1. Check Your Run Configuration:
- Verify that your run configuration is correctly set up. Sometimes, after refactoring or module changes, the run configuration might default to an incorrect setup.
- Delete all existing configurations (you can find the dropdown in the top right of the IntelliJ IDEA window) and remove the Cucumber Java configuration.
- Right-click on the main application you want to run and select "Run" or use the shortcut `Ctrl + Shift + F10`.
2. Update Dependencies:
- Ensure that you are using the latest version of Cucumber dependencies. Update the version numbers in your build tool configuration file (e.g., `pom.xml` for Maven or `build.gradle` for Gradle).
- Run the following commands to download the latest dependencies:
- For Maven: `mvn clean install`
- For Gradle: `gradle clean build`
3. Use the Correct Class Name:
- The class `cucumber.api.cli.Main` is deprecated. Instead, use `io.cucumber.core.cli.Main`.
- Make sure to update your code to reference the correct class name.
Remember to adjust your project settings and dependencies accordingly. If you follow these steps, you should be able to resolve the issue.
Hi Sir,
Here is the full error message
May 07, 2024 11:59:53 PM cucumber.api.cli.Main run
WARNING: You are using deprecated Main class. Please use io.cucumber.core.cli.Main
io.cucumber.core.exception.CompositeCucumberException: There were 2 exceptions. The details are in the stacktrace below.
at io.cucumber.core.runtime.RethrowingThrowableCollector.getThrowable(RethrowingThrowableCollector.java:57)
at io.cucumber.core.runtime.CucumberExecutionContext.getThrowable(CucumberExecutionContext.java:109)
at io.cucumber.core.runtime.Runtime.run(Runtime.java:78)
at io.cucumber.core.cli.Main.run(Main.java:87)
at cucumber.api.cli.Main.run(Main.java:30)
at cucumber.api.cli.Main.main(Main.java:15)
Suppressed: java.lang.UnsupportedClassVersionError: org/openqa/selenium/WebDriver has been compiled by a more recent version of the Java Runtime (class file version 55.0), this version of the Java Runtime only recognizes class file versions up to 52.
at java.lang.ClassLoader.defineClass(ClassLoader.java:756)
at java.net.URLClassLoader$1.run(URLClassLoader.java:363)
at java.security.AccessController.doPrivileged(Native Method)
at java.lang.Class.getDeclaredMethods0(Native Method)
at io.cucumber.java.MethodScanner.safelyGetMethods(MethodScanner.java:39)
at io.cucumber.java.MethodScanner.scan(MethodScanner.java:32)
at io.cucumber.java.JavaBackend.lambda$loadGlue$2(JavaBackend.java:41)
at java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:184)
at io.cucumber.core.runtime.SingletonRunnerSupplier.createRunner(SingletonRunnerSupplier.java:44)
Suppressed: java.lang.UnsupportedClassVersionError: org/openqa/selenium/WebDriver has been compiled by a more recent version of the Java Runtime (class file version 55.0), this version of the Java Runtime only recognizes class file versions up to 52.0
at java.lang.ClassLoader.defineClass1(Native Method)
I installed the new eclipse and fallowed your videos also but getting the same error.
Any paid support call from you sir? I need to implement a new project for my company
Let's break down the error messages and address them step by step:
1. Deprecated Main Class Warning:
- The warning message indicates that you're using a deprecated Main class for running Cucumber tests.
- To resolve this, update your test runner class to use the new `io.cucumber.core.cli.Main` class instead of the deprecated one.
- Make sure your test runner class (the one annotated with `@RunWith(Cucumber.class)`) references the correct classpath for your feature files. For example:
```java
import org.junit.runner.RunWith;
import cucumber.api.CucumberOptions;
import cucumber.api.junit.Cucumber;
@RunWith(Cucumber.class)
@CucumberOptions(features = "classpath:com/yourgroup/yourartifact/cucumber/features")
public class RunCucumberTest {
// Your test configuration
}
```
- Replace `"classpath:com/yourgroup/yourartifact/cucumber/features"` with the actual path to your feature files.
2. UnsupportedClassVersionError:
- This error occurs because the `org.openqa.selenium.WebDriver` class has been compiled with a newer version of Java (class file version 55.0), but your current Java Runtime only recognizes class file versions up to 52.
- To fix this, ensure that your project is using a compatible Java version. You can check your Java version by running `java -version` in your terminal.
- If you're using an older Java version, consider upgrading to a more recent one (Java 8 or higher).
3. Eclipse Configuration:
- Since you mentioned installing a new Eclipse, make sure you've configured your project correctly within Eclipse.
- Verify that your project is using the correct Java SDK (matching the version you want to use).
- Also, check if your project build path includes the necessary Selenium and Cucumber dependencies.
4. Implementing a New Project:
- If you're starting a new project for your company, consider the following steps:
- Create a new Maven or Gradle project (depending on your preference).
- Add the necessary dependencies for Selenium (e.g., `webdriver`, `webdrivermanager`) and Cucumber (e.g., `cucumber-java`, `cucumber-junit`).
- Set up your feature files, step definitions, and test runner class.
- Write your BDD scenarios in Gherkin syntax within the feature files.
- Implement the step definitions to map Gherkin steps to Java code.
- Run your tests using the updated test runner class.
Remember to keep your Java version consistent across your project and ensure that all dependencies are correctly configured
---
@@RaghavPal Thanks for your quick response Sir. Ya as you said , it was a jav version issue. Did the changes in build path Java 8 to 11 then it worked
Thanks a lot really helpful!
You're welcome Darshana