selenium - Optimal Pattern or Model for parameterized data driven testing Webdriver & Java -
i should preface saying relative novice java quite easy 1 crack in terms of simple , efficient solution. haven’t familiarized patterns yet!
i have need automate population of form field data in web app using webdriver , java.
i have number of properties: “house1”, “house2”, “house3” select dropdown @ top of form.
if select “house1” must populate address “123 boulevard” if select “house2” must populate address “101 ocean drive” etc...
i can think of 2 ways of organizing in junit/webdriver/java setup:
1: use junit 4’s @runwith(parameterized.class) feature wherein read each house name in flat file (.csv example) , pass in test invoked once each time each of 3 rows of data (house names):-
@before public void setup(){ driver.get(this.house); } @test public void oakleaficonpresent(){ webelement formfieldone = driver.findelement(by.xpath(".//formfieldone")); switch (house) { case "house1": { formfieldone.sendkeys("123 boulevard"); } break; case "house2": { formfieldone.sendkeys("101 ocean drive"); } break; case "house3": { formfieldone.sendkeys("1 amityville"); }
this seems expensive me.
2.create bespoke method each house needs data population , call on demand when required:
private void fillformoneforhouseone(){ webelement formfieldone = driver.findelement(by.xpath(".//formfieldone")); formfieldone.sendkeys("123 boulevard"); } private void fillformoneforhousetwo(){ webelement formfieldone = driver.findelement(by.xpath(".//formfieldone")); formfieldone.sendkeys("101 ocean drive"); }
this seems worse.
any thoughts?
i'd recommend reading on page object model , selenium in general. check out selenium documents or here article page object model.
Comments
Post a Comment