c# - htmlunit .net MVC Views unit testing -
i using htmlunit java (converted run in .net) details here
using same logic example, using web client , works mvc3 razor code/views.
problem occurs when have [authorize]
above views webclient can't access page. there way around this? how (if possible) set automatically log on? if parse login page , submit admin/password.. carry on every page visited in "session"
i have tried:
[setup] public void setup() { //initiate webclient webclient = new webclient(); //login var loginpage = (htmlpage)webclient.getpage(properties.domainnametotest + "account/logon/"); ((htmlinput)loginpage.getelementbyname("username")).setvalueattribute(properties.adminusername); ((htmlinput)loginpage.getelementbyname("password")).setvalueattribute(properties.adminpassword); var action = (htmlpage)loginpage.getelementbyname("loginbutton").click(); }
this works fine.
htmlunit web browser. doesn't have graphical user interface: have tell using code. if you're able access page using regular web browser, same thing htmlunit, , work expected.
Comments
Post a Comment