using Selenium: how to use output from one test as input to another test using Selenium: how to use output from one test as input to another test selenium selenium

using Selenium: how to use output from one test as input to another test


And now something completely different:

Now I understand when you say "test", you mean a single assertion within one test case. So you want to use a value returned from a request as input for another request in the same test case.

Assuming you use selenium ide: To do this, use one of the "store..." commands in selenium ide and store the value into a variable. The contactID can be found using a matching selector with the storeText command. For example:

command: storeTexttarget: selector for element containing contactIdvalue: contactId

Then, use variable substitution and the type command to insert that text somewhere else.

command: typetarget: selector for target input boxvalue: ${contactId}

Hope this helps :)


(This answer is still correct I think if you interpret "test" as "test case". For another, totally different answer see below.)

You don't do this. Each test should be independent from all other tests. For your second test, just repeat the steps in the first test. This way, you can reproduce test success and failures in a reliable way.

If you have many tests which all start from a certain application state which requires many steps to reach, just write a private helper method to reach that state.

The alternative: All steps you describe can be put into a single test. There is no reason not to have several asserts in one test.