views:

63

answers:

2

Hi, In my selenium test suite (html), I define a first test case to initialize variable called in the next test case.

Sample :

In first script :

store|//div[@id="myfield"]|myvar

In my second script :

type|${myvar}|myvalue

But when I start test runner (from maven), it returns an error telling that ${myvar} is not found The value contained in the stored var is not used.

Any suggestion ?

Thans a lot

+1  A: 

As far as I know you cannot reference variables declared in a different test when running HTML suites.

What you need is Test and/or Suite "Setup" and "Teardown" functionality.

Test setup and teardown happen before and after each test. Suite setup and teardown only happen once, before and after the suite is run.

As you are using Maven, I assume that your development is in Java, so you could use JUnit

http://www.junit.org/

This has both test and suite setup and teardown:
Test Setup
http://kentbeck.github.com/junit/javadoc/latest/org/junit/Before.html
Test Teardown
http://kentbeck.github.com/junit/javadoc/latest/org/junit/After.html

Suite Setup
http://kentbeck.github.com/junit/javadoc/latest/org/junit/BeforeClass.html
Suite Teardown
http://kentbeck.github.com/junit/javadoc/latest/org/junit/AfterClass.html

Bigwave
Hi, I don't want to use JUnit because all selenium script are recorded by non developper and it's time consuming to convert more than 1000 script from html to java code.So, the user create a test suite, put it into the repository svn and the continous integration tool run the test as htmlSuite.
+1  A: 

Maybe you could use cookies to store variable?

createCookie is in selenium and to read it you might use javascrpt(getEval)

01