Running feature file multiple times without passing a value from feature file - c#

I have a feature file like this.
Feature: Verify captured document values against CMS for
#test
Scenario: Verify user can open and view document
Given user is in QueueHandling home page Dashboard
And user has batches assigned to himself/herself
When user selects a batch from batch list
Then selected batch is opened in a new window
And user views all identified documents
#test
Scenario Outline: Verify data in document
When user selects "<documentType>" document and compare data
Examples:
| documentType |
| Settlement Coversheet|
| AssetLoanAgreement |
#test
Scenario: Verify user navigates back to QueueHandling home page Dashboard
Given user navigates back to QueueHandling home page Dashboard
I want to run it multiple times within the code.
"When user selects a batch from batch list" in this step I want to pass batch number one by one each time this feature is running.
I tried to add a loop to BeforeFeature like this.
[BeforeFeature]
[Obsolete]
public static void BeforeFeature()
{
while (queueNumberCurrentIndex < 2)
{
string featureAddOnText = queueNumberList[queueNumberCurrentIndex];
feature = extent.CreateTest(FeatureContext.Current.FeatureInfo.Title + " \"" + featureAddOnText + "\"", FeatureContext.Current.FeatureInfo.Description);
Hooks.testlog = extentLog.CreateTest(Properties.getProperty("projectname"));
feature.AssignCategory("Regression");
}
}
But this keeps on running forever. What should I do?

Cucumber is not an environment to program in.
If you need to program, you need to either push the programming down into your step definitions or better yet helper methods called by your step definitions, or pull the code up, so you do things like have scripts that dynamically create features.
Most of the time pushing the programming down is the simplest answer. If you implement a step definition as a single call, you end up in a pretty powerful programming environment in your programming language of choice. Here you can loop, collate, connect to external resources etc. etc.
In you example the programming is all focused on how something is being done. The first step to pushing this down is to understand WHAT your scenario is trying to do and WHY that is important. Currently your scenario fails to do this. It claims that WHAT it is about is that a user can open and view a document. If this was actually the case your scenario would be
Given the user has a document
When they open their document
Then they should see their document
But your scenario is all about batches verification settlement, loans. You won't make any progress without expressing a much clearer description of WHAT the combined effects of all these interactions are for, and WHY this particular combination of interactions is important.

Related

Best way to create multiple users with different variable in BeforeTestRun Hook - Specflow

Hi I have a question,
Currently I am creating an user under the users location and i also want to create a user under an admin location.
My Specflow Scenario looks like this.
#createUser
Scenario Outline: Do Something to created users
Given A user has already been created under <location>
When I do something with the user
Then I expected something to happen
Examples:
| location |
| admin |
| users |
And my BeforeTestRun looks like this:
[BeforeTestRun()]
public static void BeforeTestRun(string location // I would like to pass this
variable from the scenario examples table)
{
CreateEmployeeForTestRun(location);
...
}
I only want the users to be created once at the start of the execution and i clean them up at the end, The above scenario is just a simplified version of my complex one.
I also have multiple scenarios that will use this 2 different users under different location.
Also more location will be added in the future hence I am looking to pass the table variable as a parameter into the BeforeTestRun hook, I have not been successful as of yet and not sure if its possible to do with specflow, Also I am sure that there might be a better solution to this, I want to avoid as much of repetition as I can.
Any Ideas/Help appreciated.
Given there is an admin user
And there is a user
Is a good starting point. It would be better if you could be more precise about the non-admin user e.g.
Given there is an admin user
And there is a customer
You should implement these steps, something like
Given 'there is an admin' do
#admin = create_admin
end
Given 'there is a customer' do
#customer = create_customer
end
and defer how you create users to helper methods.
Once you have that you can create
Given there is an admin and a customer
and implement as
Given 'there is an admin and a customer' do
#admin, #customer = create_admin, create_customer
end
Your helper methods would be something like
module UserCreationStepHelper
def create_admin
...
def create_customer
...
end
World UserCreationStepHelper
caveat: Above is ruby cucumber, you will need to translate. You should be able to get help with this at cucumber.io

Run User Compare with ERPConnect (Theobald)

I would like to know if anyone knows if it is possible to run a SAP User Compare from c# using ERPConnect 4 from Theobald? If so, how?
I can open a connection to SAP and run functions - just don't know how to do User Compare.
EDIT:
It seems like we have to run the report PFCG_TIME_DEPENDENCY.
If anyone knows how to run a report with ERPConnect, or if there exists a functional module in SAP that can run a report, that will also help.
I am not exactly sure what your comparison has to include, but I assume, that you want to compare attributes of the users. If that is the case, you could download the users data from the SAP tables. Here is a starting point for what tables you probably need: http://www.tcodesearch.com/sap-tables/detail?id=USR01
USER01 is the user master record, containing all user with it's main attributes. You can find other interesting related user table through the link above.
To read a table using Erpconnect, look at this link: https://my.theobald-software.com/index.php?/Knowledgebase/Article/View/21/23/reading-sap-tables-directly
You need to create an instance of the ReadTable class. Then you add the fields you are interested in using the AddField method (e.g. MANDT and BNAME for the USR01 table). You could but don't have to enter filter criteria using the AddCriteria method. If you do add multiple creteria, be sure to add boolean operators like "and" or "or":
table.AddCriteria("LANGU = 'D'");
table.AddCriteria("AND MANDT = '007'");
Finally set the table name of the table you want to download and execute the Run-Method. After that you can loop through the results stored in <your RunTable-Instance>.Result.Rows
Sascha

Is it possible to run multiple Examples in a Scenario Outline without closing the browser?

So we are using SpecFlow (C# with Selenium WebDriver) in order to do functional testing.
I am still pretty new to using SpecFlow and Selenium. My mentor has told me that they want scenarios written in a way that only has one when and then (you set up your test, you my perform an action or two and then assert).
So I have a Scenario Outline, like so:
Scenario Outline: Outline label
Given I am on the proper page
When I apply filter "" with ""
And I click filter
Then the data should be filtered
Examples:
| filter | params |
| Date | Today |
| Name | Some Name |
| ... [20+ more] ... |
However my mentor said it would be best to instead to do something like this:
Scenario: Scenario label
Given I am on the proper page
When I apply and filter with
| filter | params |
| Date | Today |
| Name | Some Name |
| ... [20+ more] ... |
Then the data should be filtered
The point is so that the browser doesn't have to close and re-open for each of the filter tests. Instead the filter would be cleared before the next.
However, I am unsure of how best to approach this task in the best way. Since each of the filters would need to be verified before the next is done, where would the assertion be done? Within the "When I apply and filter with" and then the "Then the data should be filtered" just checks to make sure nothing failed? That seems a bit odd as the "When" case should stop as soon as one fails.
Alternatively the "When" could just store everything in the table and the "Then" would apply the filters and do the assertion -- but it then ceases to be a then as it is doing something more than asserting the expected conditions have been met.
I've been browsing around for trying to similar problems with solutions, but I haven't found anything.
I guess my basic problem here is how do I perform multiple, different yet similar, steps without having to open/close the browser for each individual example (as occurs with the Scenario Outline)? Is this even good practice or possible (without having to do multiple when/thens in a single scenario)? Is doing multiple when/thens (e.g. When ... Then ... When ... Then ...) a bad idea as well?
Thanks in advance! I've been trying to research related issues for a couple days but have found nothing that helps.
A good option to avoid having to close/re-open the browser between tests is to look at Hooks in SpecFlow. You can use a [BeforeFeature] or [BeforeTestRun] hook (or more variations) to launch the browser once, then run numerous tests before closing the browser at the end of the tests.
If you need to get your system back to a certain state after/before each test, you could have one [BeforeFeature]/[BeforeTestRun] hook to launch the browser at the beginning, then one or more [AfterScenario] / [BeforeScenario] hooks to clean up any scenario-specific data so that you keep each test clean but avoid closing the browser to clean up your session/cookies/etc. You could even clear the filter in an [AfterScenario] hook with WebDriver if you needed to, before the next test starts.
This is how I solved the issue... SpecFlow Browser Document
You'll notice that I used a singleton dictionary to store the open browser instances for the life of the feature. Then in the AfterFeature hook, I go through and close all the open browsers.
Here are my thoughts on the subject,
First of all, it seems more like a Specflow question, rather then a Selenium one.
Do you know the difference between Scenario and Scenario Outline?
Scenario is a single test. It can have table inside, but that just to organize that specific step. You can take the arguments out of the sentence and put them into a table which gives you somewhat more dynamic step.
Instead of:
When I apply filter filter_a with kuku
You can write:
When I apply filter with
|filter | param |
|filter_a | kuku |
On the other hand, Scenario Outline is a template for different tests with the same format, so each table row is actually a different set of parameters for each scenario.Here is one example from many others in Google: How can I repeat steps in a Specflow Scenario Outline
So that's about Scenario and Scenarios Outline.
How do you handle closing of the webdriver between the tests is your choice. I guess that depends on the logic. One thing I can tell about the validation - it would be much easier for you if you validate the filters in each step and not in the end because in the latter if the tests fails it would be harder to debug and find what caused the issue. Also if one of the filters fails there is no point to process farther, right? That's of course in case I understood your question and the table is just a set of parameters for one test.

Umbraco Architecture with query string parameters for document

I have a client web app that I've been asked to make some updates to. I have a small number of development hours to work within so a redesign of the system is not an option at this time.
The app was written using classic asp with logic to pull certain content dynamically from a custom database and to write back certain user actions to the same custom database. There is an admin area for viewing these logged user actions.
At some point in time portions of the web app were migrated to use Umbraco 4 for the cms. I've been tasked with migrating some additional content, that is still being pulled from the original custom database, into the context of the CMS.
The content in question is structured so that the content node's document type points to a special masterpage. The master page has codebehind logic that checks for a query string parameter and uses that parameter to query the database for content specific to that parameter. In then populates one specific section on the page with that content.
The logic also uses the query string parameter when writing user actions back to the custom database.
I need to maintain the url syntax and behavior of writing user actions back to the custom database but move the displayed content specific to that parameter into the CMS somewhere. Where should I place this content in the CMS and how can I access it from those pages via the query string parameter?
Url Examples:
/site_home/Node1/Node2/Node3/
/site_home/Node1/Node2/Node3/?partner=partner1
/site_home/Node1/Node2/Node3/?partner=partner2
/site_home/Node1/Node2/Node3/Review/
/site_home/Node1/Node2/Node3/Review/?partner=partner1
/site_home/Node1/Node2/Node3/Review/?partner=partner2
/site_home/Node1/Node2/Node3/Checkout/
/site_home/Node1/Node2/Node3/Checkout/?partner=partner1
/site_home/Node1/Node2/Node3/Checkout/?partner=partner2
If you can provide a bit clearer explanation of what you are trying to accomplish, I am sure that I can assist you further. However, the code below and link to the discussion from which I pulled it may help get you on the path. Give me some feedback or edit your question and I will edit my answer to assist.
#{
if(!string.IsNullOrEmpty(Request.QueryString["query"]))
{
int result= 0;
if(Int32.TryParse(HttpContext.Current.Request.QueryString["query"].ToString(), out result))
{
umbraco.MacroEngines.DynamicNode node = new umbraco.MacroEngines.DynamicNode(result);
<h1> #node.Name </h1>
}
else
{
<h2>No query found</h2>
}
}
}
Umbraco Forums - Render Node content from querystring

Indexed databases in Random Access Memory

I'm currently writing a small test web application for a jobs search system.
I have a table Vacancies (the main table to talk about).
I need to make a rapid AJAX update of vacancies (in a suggest list below input control) matched to a user query. Different DBMS provide powerful programming extensions like Free Text Search in Microsoft SQL Server .. but I think that scanning a physical file takes plenty of time. And my idea is based on transfering the whole table Vacancies into RAM, so it, in my view, makes sense since in this case data retrieving demands less time.
So if a client types in a textbox something like "pro" - the suggest list shows up with suggestions:
-product manager
-professional designer
-programmer
-programmer C#
-programmer Java
-property administrator
-provision expert
when a user types another letter "g", the value of a textbox widens to "prog"
and the list is refreshed:
-programmer
-programmer C#
-programmer Java
To make that possible I plan to create a tree index with saved values in nodes, where a vacancy prefix will play a role of the index key and node values are the vacancy names. The index is built and populated only once with data from a data table. See what I mean below:
"pro" -> {
"product manager",
"professional designer",
"programmer",
"programmer C#",
"programmer Java"
"property administrator",
"provision expert"
}
So an index builder must analyze a string list and find the least prefixes of vacancy names.
Then when a builder finds a string with a letter after prior found prefix, it creates a child tree node ("prog") (the count of data values in that node decreases as it is constantly filtered) and adds itself up to the parent node ("pro")
"prog" -> {
"programmer",
"programmer C#",
"programmer Java"}
}
Can you advise me on the types of tree indexes that naturally fit to solve this problem?
What's the best of them by the seek time?
Thanks
This problem was solved years ago, you are recreating Lucene:
For what it's worth the type of tree you want is a Patricia Tree or a Radix Tree. In terms of storing all data in RAM, this is a bad idea because there are other applications that use RAM not just your index. Currently I am ripping out someone's custom database that they thought was a good idea to implement this way and replacing it with a real database solution.

Categories

Resources