Multiple JUnit test in one browser session -


i’ve written program in selenium webdriver next project make more maintainable using better programming techniques. main part want focus on launching browser once (1 session) , run 10 different test close browser i’m not sure how this. using junit how have project laid out :

package example1; public class testbase { //main class  @before public void setup () { //launch browser }  @test //all test run here public void test1(){ login(); homepage(); }  @after public void teardown(){ //close browser } }  package example1; public class login(){ //do action }  package example1; public class homepage(){ //do action }  package example1; public class storemethods(){ //all methods stored called different classes } 

i’m not sure if @test annotation should in main class or if should in own class (login(), homepage()) because read somewhere test should not depend on each other. don’t have experience in java i’m more willing learn. need guidance on best practices , how write maintainable test if me out or point me in right direction i’d appreciate it.

while robbie wareham said correct, reusing browser not idea, said overall goal maintainability.

the techniques i've found increase maintainability page object pattern separate functions interact it.

the page object pattern separates selector rest of code. way, if element on page changes, , tests uses element 5 times...you change code in 1 spot. standard include isloaded(), function can used identify if on page need don't reload page.

i recommend having test not directly deal page created. if had toolbar had use go x page...and toolbar changed link wanted in sub-menu, every time in tests used link, have change method click on link. creating sets of selenium commands interact page make tests high-level , easy read.


Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -