run feature files sequentially in cucumber - selenium

I have two questions.
I have 2 feature files . Loginpage (which is the first) and then Login(this is the 2nd). But when i run , always the second is picked up first because its alphabetically sorted. How do i make it in sequential way.
I have two step definitions files. Now, the first runs ok but the second gives me a null pointer exception. How do i make the driver object catch that session from the first and continue executing for the second.
Thanks,
Sriharsha

For this you can have the feature files listed in yml file, and then running each and every feature file in a sequential way by creating a gem. You can have a look at https://github.com/nareshnavinash/testbdd to get the idea of how this can be implemented.
I think you have to kill the driver at the end of first feature and initiate a new driver for your second feature file. If you badly want to use the same driver, then you have to merge two feature files.

I think if you want to test the Loginpage navigation and the login itself, you should separate them.
So the login test could include the navigation step and both can run independently.

Related

is there a way to run all the tagged scenarios from a single feature file using cucumber hooks?

i have a feature file with more than one scenario, in my cucumber hooks class i have #before which will open the browser at the beginning of every scenario, how ever every time i execute to scenarios at once, only one scenario will execute and run all the steps but the other scenario will just open the browser but it wont actually go to the website
I would appreciate your help, thanks

Is it possible to skip fixture or whole file in testcafe if one test fails?

There is only one option in testcafe --stop-on-first-fail which stops the whole test run not only fixture or file. Is it possible to somehow separate or isolate the fixtures or files? My goal is to separate files in failure, so if there is a failure in the test, it will stop the whole file/fixture and the test run will continue to another file/fixture. I assume, this feature is not implemented yet and I will have to use javascript.
There is no such functionality in TestCafe right now, and I can't see any workaround for this scenario. I recommend you create a suggestion in the TestCafe github repository using this form.

Execute one feature at a time during application execution

I'm using Karate in this way; during application execution, I get the test files from another source and I create feature files based on what I get.
then I iterate over the list of the tests and execute them.
My problem is that by using
CucumberRunner.parallel(getClass(), 5, resultDirectory);
I execute all the tests at every iteration, which causes tests to be executed multiple times.
Is there a way to execute one test at a time during application execution (I'am fully aware of the empty test class with annotation to specify one class but that doesn't seem to serve me here)
I thought about creating every feature file in a new folder so that I can specify the path of the folder that contains only one feature at a time, but CucumberRunner.parallel() accepts Class and not path.
Do you have any suggestions please?
You can explicitly set a single file (or even directory path) to run via the annotation:
#CucumberOptions(features = "classpath:animals/cats/cats-post.feature")
I think you already are aware of the Java API which can take one file at a time, but you won't get reports.
Well you can try this, set a System property cucumber.options with the value classpath:animals/cats/cats-post.feature and see if that works. If you add tags (search doc) each iteration can use a different tag and that would give you the behavior you need.
Just got an interesting idea, why don't you generate a single feature, and in that feature you make calls to all the generated feature files.
Also how about you programmatically delete (or move) the files after you are done with each iteration.
If all the above fails, I would try to replicate some of this code: https://github.com/intuit/karate/blob/master/karate-junit4/src/main/java/com/intuit/karate/junit4/Karate.java

Multiple login tests on mobile app with UFT

I am trying to test the Login feature of my Android app with multiple user-password entries that I have in an Excel. I have already been able to import that data from the Excel successfully and run the same test with each row (with "Run on all Rows" option), but now I am facing a problem that I am not being able to solve.
After a test runs with one row, one the test starts over with a new row, it will not restart the app, but start at the same point where the previous one finished. I think this is not the expected behaviour, in general, since most of the GUI testing tools restart the app when testing a feature with parametrization (data from Excel, mostly). Anyway, I "fixed" this by logging out in my app.
In this case there was an "easy solution" by logging out. But what if I was testing a different feature in which I cannot simply "log out". The problem is that in those different cases I would have to navigate back or do something that may fail and has nothing to do with the feature I am testing.
I am not sure if I am not using the right approach. Is there a good general solution for this issue?
I would suggest the following two ways to solve your problem if you cannot simply use logout as the last step.
Use App.Launch function you can add one line to the top of your script like Device("iPhone 7").App("myApp").Launch NotInstall, Restart . Here the device and the app can be TO in object repository or identified using descriptive programing like Device("id:=123456")
Check options in Test Settings Please check the latest UFT version maybe 12.53 or later if there are any options in Test Settings for users to choose to restart or reinstall app for iterations.
Thanks

Prefill new test cases in Selenium IDE

I'm using Selenium IDE 2.3.0 to record actions in my web application and create tests.
Before every test I have to clear all cookies, load the main page, log in with a specific user and submit the login form. These ~10 commands are fix and every test case needs them, but I don't want to record or copy them from other tests every time.
Is there a way to configure how "empty" test cases are created?
I know I could create a prepare.html file or something and prepend it to a test suite. But I need to be able to run either a single test or all tests at once, so every test case must include the commands.
Ok I finally came up with a solution that suits me. I wrote custom commands setUpTest and tearDownTest, so I only have to add those two manually to each test.
I used this post to get started:
Adding custom commands to Selenium IDE
Selenium supports object-oriented design. You should create a class that takes those commands that you are referring to and always executes those, in each of the tests that you are executing you could then make a call to that class and the supporting method and then execute it.
A great resource for doing this is here.