SpecFlow | SpecFlow automates | Functional Testing library
kandi X-RAY | SpecFlow Summary
kandi X-RAY | SpecFlow Summary
SpecFlow is a pragmatic BDD solution for .NET. It provides test automation for .NET (.NET Framework, .NET Core and Mono), based on the Gherkin specification language and integrates to Visual Studio. For questions please post them in our community discussion group. For issues/bugs please use the issue tracker on GitHub.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of SpecFlow
SpecFlow Key Features
SpecFlow Examples and Code Snippets
Community Discussions
Trending Discussions on SpecFlow
QUESTION
Hellow, i have pop-up window with 'select' element in chrome browser, i need to click this 'select' element in my ui-test scenario. It is on image: my web page
I am using c# and TechTalk.SpecFlow. I am trying to click it like this:
...ANSWER
Answered 2022-Apr-11 at 11:48A couple of suggestions. I would try suggestion 1 first. If that doesn't work, try suggestion 2 as well:
Don't Use Exact XPaths — I see this frequently. Use a combination of tag names, attributes and parent elements to make your locators more robust. In fact, the
tag has an Id. Use that. Id attributes must be unique in the HTML document (if they aren't, it is a bug that should be fixed): Browser.ClickWebElementNew("//select[@id = 'state']", FoundBy.XPath); This can help keep your tests passing when minor HTML changes are made in the future. Use An Explicit Wait — You will likely need this as well. You will need to wait for the element to be clickable. If using Selenium 3 or if you have the DotNetSeleniumExtras NuGet package installed, use ExpectedConditions in the ClickWebElementNew method: public void ClickWebElementNew(string findElement, FoundBy f) { var wait = new WebDriverWait(_chromeDriver, TimeSpan.FromSeconds(30)); By locator = null; if (f == FoundBy.XPath) { locator = By.XPath(findElement) } else if (f == FoundBy.CssSelector) { locator = By.CssSelector(findElement); } else { throw new InvalidOperationException("Unsupported FoundBy"); } var element = wait.Until(ExpectedConditions.ElementToBeClickable(locator)); element.Click(); } If using Selenium 4 and you don't have the DotNetSeleniumExtras package installed, this should work: var element = wait.Until(d => { d.FindElement(locator).Click(); return true; }); element.Click(); The main reason for "waiting for the element to be clickable" is because certain user interface animations prevent Selenium from interacting with elements. These can be subtle, but important. Any movement, or fade-in can cause issues with interacting with the page. If ideas 1 and 2 do not work, look to see if the element is inside a frame or iframe. You need to switch to the frame before interacting with its elements. Also look for elements that overlap that same region of the page. This can cause problems too, especially if running in headless mode and you are not setting a window size.
QUESTION
Sendkeys is entering the value for below search dropdown only in debug mode.It doesn't work in full run even after adding waits or clicking and entering the value. Using Javascript, I'm able to enter the value in full run but search results are not shown which is not allowing me to select the value from the list of search results. HTML code: code image
Code for sendkeys used:
driver.FindElement(FirstDestination).SendKeys("italy");
Code for javascript used:
...ANSWER
Answered 2022-Apr-10 at 14:55You can use WebDriverWait
to send the keys like below:
QUESTION
I write test cases in Visual Studio - Specflow feature file. Post that, I use "AzureDevops Test Connector" to migrate test cases into Azure Devops - Test Plan -> Test Suite(Which are already created in Azure Devops by me).
My requirement is to update, "Area Path" and "Iteration" for the newly created test cases.
I am able to update "Area Path" and "Iteration" for Test Plan and Test suite using Azure Devops Services Rest APIs. But, there is no provision to update these values in Test Case. Any lead will be much appreciated. Below is what i tried. Thanks in advance!
.
PATCH CALL TO UPDATE AREA PATH AND ITERATION PATH - BUT IT IS NOT WORKING | SCREENSHOT FROM POSTMAN
...ANSWER
Answered 2022-Apr-02 at 14:40I was able to achieve this by using "work item" instead of "Test Case". Using this, I am able to update all the field values.
Postman - add Content-Type = application/json-patch+json | under headers separately. Keep body as "raw" and "JSON" in drop down.
QUESTION
I'm trying to run Cosmos Emulator on Linux, to run tests using SpecFlow.
After installing it following these instructions, and successfully running it, a variable number of tests randomly failed all the times I tried to run them.
The failed tests throw a CosmosException
with a 503 (Service Unavailable)
status code.
All these tests work just fine on Windows and, depending on how I run them, either via the terminal or VSCode, the number of failures differs.
...ANSWER
Answered 2022-Mar-25 at 00:30The problem was with the docker command provided within the documentation:
QUESTION
I'd like to give a library + SpecFlow project to a client and let them add new SpecFlow scenarios without needing to generate source code / compile.
Is it possible to load a set of tests from a text file and run those?
...ANSWER
Answered 2022-Mar-18 at 14:19SpecFlow scenarios are just plain text files. There is nothing stopping your client from opening up Notepad or any other text editor and writing new scenarios or features. They could even just write them in an e-mail and send it to you.
Visual Studio and the SpecFlow extension just make it easier to write new scenarios, because it enables auto-complete for steps. If your client doesn't need step suggestions, then any text editor will do.
Once you have their new scenarios, you can add new feature files to your test project. This will enable the step bindings and allow you to run the tests.
If you want the client to write scenarios and be able to run them, you are out of luck. That isn't supported unless you create a windows app that imports your step definitions, test dependencies and then parses the feature files into test classes before executing them.
So, you can partially get what you want.
- Clients can write new scenarios in any text editor they want.
- You would need to copy those scenarios into feature files in your test project.
- You would be the one running the tests, not the client.
QUESTION
I am creating automated tests with selenium and specflow using C#. Today I had to update Selenium.WebDriver to version 4.0.0-beta4 because of logging functionality, which has a bug in previous versions with AvailableLogTypes property, which was always throwing null reference exceptions. After updating to selenium 4, another problem raised up. Build works fine without errors or warnings but when I run tests, following exception is thrown:
...ANSWER
Answered 2021-Sep-10 at 06:24So here is how I fixed this:
- I removed DotNetSeleniumExtras packages from code.
After that, I was finally able to gather performance logs from browser because I got rid of errors shown in my question. - After removal of DotNetSeleniumExtras package I lost PageFactory for initialization of page objects.
I fixed this problem by converting all web elements (properties of page object) into computed properties:
QUESTION
I reviewed the code of Specflow in github and found a tricky issue that I cannot understand.
Line 69 in https://github.com/SpecFlowOSS/SpecFlow/blob/master/TechTalk.SpecFlow/ScenarioContext.cs
...ANSWER
Answered 2022-Mar-10 at 07:44Because of InternalsVisibleTo. This enables access to internal types, methods, etc. to every object calling from the authorized assembly.
In https://github.com/SpecFlowOSS/SpecFlow/blob/master/TechTalk.SpecFlow/AssemblyAttributes.cs the assembly TechTalk.SpecFlow is decorated with some of this attributes, exposing all the internal methods to the listed assemblies:
- TechTalk.SpecFlow.RuntimeTests
- TechTalk.SpecFlow.PluginTests
It's a very common and useful technique used to test methods that should not be accessible to anyone, but that need to be tested.
QUESTION
ANSWER
Answered 2022-Feb-22 at 10:28I have never used SpecFlow or AWS CodeCommit, but a little bit of experimentation (for lack of thorough available documentation) strongly suggests that AndrewF's suspicion is correct:
Syntax highlighting rules highlight invalid statements for a SpecFlow feature file (example found on toolsqa.com) are highlighted with red background. On the left, the same rule seems to cause the grey background for removed invalid statements.
The highlighting rules seem to support And
clauses, just not in the Then
part of a scenario, although the language grammar seems to allow this. I blame a bad syntax highlighting rule.
However, I have a hard time finding a formal grammar specification for Cuccumber/Gherkin that would tell me exactly what is and isn't allowed where (and what a compliant parser would make of it).
EditWhy didn't I think of checking the source view first? Looking at the HTML/CSS rules of the above diff, one can see the markup in black and white: Red background equals . The same applies to the grey
Foo
on the left side of the diff.
QUESTION
I did a recent migration of my company's legacy app from packages.config to PackageReferences. We have 5 projects: the main ASP.NET web app, a SQL connector model project, an xUnit test project, a FluentAssertions test project, and a SpecFlow project (and no I did not set this all up). My current goal was to move all of the packages.config to properly use NuGet in PackageReference in the csproj files for an eventual move from .NET Framework 4.6.1 to .NET Core. Unfortunately, we are not ready for such a move yet.
I have done the migration for all the projects. With some fiddling, all of them build and most run correctly. Our web project builds and runs (we still need proper smoke testing but it looks good so far). Our FluentAssertions and XUnit projects also build and run all of their tests flawlessly. We do have some warnings, but there is less of them then there was before this migration.
What is not working is the SpecFlow tests. Specifically, the SpecFlow tests are not being populated in the Test Explorer automatically in Visual Studio 2019. They were before this migration. We need these tests to run (for now) in our automated build process. We are fixing our technical debt in stages.
I have investigated online for the past couple of days and can make the following claims about our SpecFlow project:
- We have NUnit3 added in the Extensions and it appears to be "functioning". Same with SpecFlow for Visual Studio 2019 extension.
- We have all of the NUnit3, MSTest, and SpecFlow NuGet packages from before the migration (in the same versions) as NuGet references post-migration.
- If I run the tests from the project's context menu, it says there are 0 tests run.
ANSWER
Answered 2022-Feb-17 at 13:22If you still have the Visual Studio Extension (VSIX) for the NUnit Visual Studio Test Adapter (and it appears you do from your comment "We have NUnit3 added in the Extensions"), you need to disable or remove it. The VSIX adapter will be used over the Nuget packaged adapter and causes conflicts with the Nuget packaged adapter. The VSIX extension also shouldn't be used in VS 2017 or higher. You can check in Main Menu -> Tools-> Extensions and Updates and look for Nunit3TestAdapter.
Using VSIX extensions was the old way to use test adapters and runners. It was brittle because you had one version installed in VS that needed to support many different projects and the VS extensions framework is pretty convoluted with awkward hooks into the build life cycle. The new way is to package test adapters and runners as NuGet packages. There is nothing to install and Visual Studio finds the version-specific test adapter and runner libraries for your project besides your test assemblies. You need to use one or the other, and Nuget packages are preferred now, or Visual Studio will fight against you and you'll have issues similar to what you are seeing.
The Visual Studio Test Explorer cache sometimes gets out of whack. Try closing all copies of Visual Studio and cleaning its temp files and folders at C:\Users{$username}\AppData\Local\Temp\VisualStudioTestExplorerExtensions\
You might be running into an issue where the test process is running on the is selecting the wrong architecture of the adapter or other library during test discovery orchestration. Try changing the default processor architecture for tests (Main Menu Test -> Test Settings). Try changing x86 to x64 or vice versa.
QUESTION
I use Specflow with SpecRunner+ I am using the Deafult.srprofile to to re-run failed tests 3 times in visual studio it shows 2passed 1 failed but the status of the test is a failure, the same goes for azure devops if a re-ran test passes the outcome of the run is a failure. The Failures are sometimes caused by locator timeouts or server timeouts not often but saw it happen few time thats why we decided to implement a re-run.
Could anyone help on this?
...ANSWER
Answered 2022-Feb-10 at 14:22The behavior of the report is the correct one and sadly this can't be configured to be changed.
What you can do is to adjust how the results are reported back to Azure DevOps.
You can configure it via the VSTest
element in the srProfile- File.
This example means, that at least one retry has to be passing:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install SpecFlow
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page