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.
Related
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
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.
I have a small collection of integration tests that utilize selenium in a class. The idea is that these tests run every time there is a merge to the codebase, with the merge proceeding through the pipeline and having a series of tests running against the new code.
The thing is, these selenium tests have to run one at a time. They're using the browser to log into a website, and the account will just log out if more than one person tries to log into the account at once, it'll just log out, and the test will obviously fail, so I need these tests to run one at a time. I've tried using the #NotThreadSafe annotation, doesn't seem to have changed anything, and I've searched through for some sort of switch or parameter that defines how many tests run at once with no luck. These tests are using junit 4.12.
So my typical workflow is
I write a data driven test using TestNG in IntelliJ.
I supply hundreds of data items
Run the test and one or two of them fail
I see the list of passed/failed tests in the "Run" pane.
I would like the ability to just right click that "instance" of the test and run that test alone (with breakpoints). Currently IntelliJ does not seem to have that feature. I would have to right click the test and when I run, it runs the whole set of tests with hundreds of data points.
Is this possible?
TestNG supports this at the testng.xml level, where you can specify which indices of your data provider should be used. It's called "invocation-numbers" and you can see what it looks like by running a test with a data provider, failing some of its invocation numbers and looking at the testng-failed.xml that gets generated.
Back to your question: your IDE needs to support this feature in order to make it available in the UI, so I suggest you ask on the IDEA forums
The feature has been added as of Intellij 142.1217: https://youtrack.jetbrains.com/issue/IDEA-57906
I am testing a django application's frontend with selenium and that's first time I use it. I have multiple tests that test things after user logged in.
I want them to be separate tests, but I want to have only log in once, is that possible? (As oppose to what I do right now: I log in first, then execute my testing actions of test1, then log in again and execute my testing actions for test2, etc.)
You could try to run your first test, get the session ID, i.e. selenium.sessionId or so, and set that session ID, i.e. selenium.sessionId= after you call selenium = New DefaultSelenium(...) for the second time.
Basically, you want to keep the selenium = New DefaultSelenium(...) out of your tests and move it into some common setup code. You could have selenium be a class memeber that only gets initialized one time, and then is reused in all of the tests in that class.
See: Is there any way to speed up the Selenium Server load time?