Reputation: 28
I have been working on a Wizard application with Spring Web Flow and JSP/Tiles as View Technology. We have written UI Acceptance tests with webDriver/Selenium to test specific pages but have hit a showstopper.
Here is the current strategy ...
As you can see, Problem with this strategy is that the order of the tests matters (meaning you can not test 2nd page until you have not passed 1st page) If we were to test each page standalone, we would have to start from login screen everytime, and that means the time to run all the tests will increase EXPONENTIALLY.
Within a page, Which test is run first also matters (meaning by successfully clicking some link (if available), you should be able to see a pop-up)
Also with Junit testSuite we can only run ALL the tests within a class and not pick a few.
So my question is :
Thanks for you help in advance ...
Upvotes: 0
Views: 639
Reputation: 136633
How about making each group independent ?
This way you can tradeoff test-level independence for execution time. Now if I want to run one specific page2 test X, time = time for [Go to Page1, then Page2] + [TestX]
Seems like you're using JUnit, should work. We do this with NUnit for our acceptance tests. If you're writing Unit tests, however each test MUST be independent and fast.
Upvotes: 1
Reputation: 14748
You can also use PageObject approach where every page will be new object. Example
public class FirstPage{
private WebDriver driver;
public FirstPage(){
driver = new FirefoxDriver();
}
public WebDriver getDriver(){
return driver;
}
public void testSomething(){
// some test on first page
}
public SecondPage goToSecondPage(){
return new SecondPage(this)
}
}
public class SecondPage{
private FirstPage firstPage //that way you can access all variables in first page
public SecondPage(FirstPage first){
this.firstPage = first;
}
public void testSometingElse(){
firstPage.getDriver().findElement // thats how you access to the driver for instance
}
}
In nutshell - every WebElement of First page should be inside FirstPage
class and so on. You can still access the driver via public calls. I use similar approach and that way I know where I am in test and am sure that whenever I use method of SecondPage
class, I am on Second page.
Upvotes: 0
Reputation: 815
I don't know which test framework do you use for driving the Selenium test. If you employ TestNG, it may fit your requirement, for example
<test name="test_one" preserve-order="true">
<classes>
<class name="org.your.test.testclass">
<methods>
<include name="base_login" />
<include name="navigate_page_one" />
<include name="test_one" />
</methods>
</class>
</classes>
</test>
<test name="test_two" preserve-order="true">
<classes>
<class name="org.your.test.testclass">
<methods>
<include name="base_login" />
<include name="navigate_page_one" />
<include name="test_two" />
</methods>
</class>
</classes>
</test>
Meanwhile, you can achieve this by better organizing your test code. It has nothing to do with Selenium....
Upvotes: 0