c# - referring functions of 1st cs page in 2nd cs page -
can define function in 1 cs page , refer function in cs page functions designed in 2nd cs page executed 1st cs page function?
such like..in 1st cs page
iwebdriver driver; driver=new firefoxdriver();
in 2nd cs page, have many functions included based on above function, how can refer function in 2nd cs page code simplicity exists?
this badly worded question can assume trying achieve have ability call functions 1 test in test, or rather 1 class class.
this basic c#.
your code should split out in way means achievable. means tests totally seperate actual logic.
using page objects 1 way go:
http://code.google.com/p/selenium/wiki/pageobjects
this mean have page like:
public class loginpage { public homepage login(string username, string password) { // login stuff // return home page } } public class homepage { // logic related user can see on home page. }
you'd call in test like:
var loginpage = new loginpage(); homepage homepage = loginpage.login(username, password);
since it's seperated, call loginpage.login()
anywhere.
the key here, not bundle logic tests themselves. in, don't copy/paste login code login website each test. store it, above. tests should steps take, page objects should define how steps taken. way can achieve goal.