I'm using Visual Studio 2022 to create automated UI TestMethod(s) w/ Selenium.
Because of the benefit of using await Task.Delay(n) I decided to make my test methods async.
Is there any risks/concerns/issues with running ALL (or more than 1) UI tests asynchronously?
We normally use to run several tests in parallel to reduce the total run time, so you definitely can run tests asynchronously, however you will have to define the test cases for each test in a way so as will be no collisions between the simultaneously running tests.
Related
When using NUnit, you can pass in parameters to your tests using TestCaseSourceAttribute.
[Test, TestCaseSource(typeof(WebDriverFactory), "Drivers")]
What would be the best approach to doing the same for tests generated using specflow? Those tests do not use the 'Test' attribute. They use 'Given', 'And', 'Then' etc.
I'm trying to pass in different web drivers (selenium) so I don't have to manually change them to test across different browsers.
Specflow creates automatically test fixtures, so you cannot use [TestCaseSource]. You can try Test class generator to drive automated web ui tests with Selenium and SpecFlow.
However you should ask yourself if executing Specflow scenarios in different browsers brings a lot of benefits to your project, as execution time of your acceptance tests will double/triple. From my experience cross browser testing identifies UI changes and very rare functional (to be honest I've never encountered any). In our team testers perform it manually.
I would like to hear about your workflow for developing test case for Selenium 2 / webdriver. In JUnit, for example, a developer may start writing a test before he writes a functionality. Then he continuously runs that test against the functionality, possibly in a debugger, modifying code (which gets hot-swapped) to his heart's desires. Is there a more interactive way to write bits and pieces of Selenium code (java) and see immediate results? Do you use Selenium IDE to assist you?
https://stackoverflow.com/a/92250/374512
Right now, I have a bunch of PageObjects and a bunch of test codes that I wrote from scratch. Each time I make a change, I run the test and it has to go from the sequence of logging into the application, navigating a bunch of pages to get to the point of my test. Starting FF profile cold takes at least 5 seconds for the webdriver, and navigation takes another few seconds. How do you code and test a selenium test against a piece of UI functionality in an iterative manner. I want to be able to write a line of code and execute it against a UI in a particular state, a state that took some long sequence of steps to get to.
In my experience, there is no fast way to get to a certain state using a browser. Because Selenium tests start from scratch on each execution, there is that start up time to get to the point where you want to test, which makes browser integration testing inherently slow. If there was a way to execute the tests against the UI in a particular state, that would also speed up any regression tests, but I don't believe that's possible or the proper way to test a feature.
I've found it sufficient enough to program the actions in the page object, alongside your development of the UI functionality, and then writing your script to use the actions, similar to what you have been doing. As for when to execute it, I would say run it locally right before you commit to your repo and continuous integration environment. I think of running my tests as a checkpoint, or pre-requisite to committing code.
We are running selenium webdriver tests that have been written using mspec.
We fire these tests from team city using the built in mspec runner.
This is using firefox locally on the server to run the tests.
We seem to get random results with varying numbers of successful and failing tests and we believe it's down to the execution speed. Our test suite has wait for elements but these don't always seem to have the desired effect.
Is there a way we can slow down the entire test suite execution to try and alleviate this problem?
Or is there a better approach to automating the running of these tests.
When we run them locally in visual studio, we can get them all green.
Thanks
setSpeed in Selenium WebDriver using Ruby
Here is an article which describes the problem of random failures and a better approach to minimize them.
http://martinfowler.com/articles/nonDeterminism.html
Following webdriver documentation has details about Explicit and Implicit Waits... which help implement the same.
http://seleniumhq.org/docs/04_webdriver_advanced.html#explicit-and-implicit-waits
Hope this Helps !!
We have recently automated some "Coded UI Tests" (running in the selenium framework) which are run from within Microsoft Test Manager (MTM). However, I am struggling to find out how MTM can pass parameters (such as the URL of the application under test) through to the coded UI tests. It seems to me that this would be a fairly typical usage pattern, but I am struggling to see how it can be achieved.
Any suggestions would be appreciated.
Thanks,
David
Your after Data Driven Coded UI Tests
http://blogs.msdn.com/b/mathew_aniyan/archive/2009/03/17/data-driving-coded-ui-tests.aspx
http://msdn.microsoft.com/en-us/library/ee624082.aspx
If your linking yout Coded UI Test to a Test Case you can use the test cases parameters to feed the data into the coded ui test to drive it.
Is it better to write/record selenium tests in html format and run them directly in the server with "-htmlSuite" or to write the tests in java/C#/... and run them in the server using selenium-rc?
What is the recommended solution?
I would always recommend people writing their Selenium Tests in a programming language because it allows the tests to be a lot more expressive.
You can create common methods that all tests use and if that changes you can then update 1 method to get n tests passing because they all fail on that item. One example of this is the Page Object model which is a development method for tests that suggest you create a DSL for each page you interact with and then your tests read a lot more fluently to both technical and non-technical people.
If you write your tests in a programming language you can also take advantage of Selenium Grid which runs your tests in parallel to make them faster
I'd highly recommend you look at moving to Selenium in C#, Ruby,PHP or Python. I found many timing issues resolving once I got away from the HTML Selenese.
I might keep in mind how you plan on executing your recorded tests. For instance, it might be trivial to incorporate Selenium's generated JUnit tests into a pre-existing JUnit-based testing framework.