testing of web pages with perl,2: simulating a logged-in user, and limitations
lots of pursuits in programming pass through a stage in which a difficult yet seemingly all-curing obstacle is overcome yet the result presents more unforeseen obstacles that almost render the achievement unusable.
i had written an automated test script for some web pages i created. when the users wanted to start using it and testing it, i had to include an authentication mechanism so that each logged-in user would get his/her customized web page. the test script could not pass through the username and password authentication that real people went through so i had to find another way. i thought once i could accomplish this, all testing could be automated.
by-passing the log-in page turned out to be as easy as setting a single cookie. therefore, programming this required two steps: first, the client (the simulated user) had to be able to receive cookies from the server. since the perl testing module (WWW::Mechanize) inherits from the module that simulates a browser user and receives cookies (LWP::UserAgent), this was easy. second, the server had to create the cookie and send it to the client. i created a web page that did nothing other than this. my test script had to first call this page to get its cookie set before calling the page that required the login cookie (the page i want to test).
once that hurdle was leaped, i started writing my test script. here i met some fairly large limitations. most of my tests were checking how the page would respond when certain radio buttons or drop-downs were manipulated. this is all done by client-side javascript and the test script could not run this (unless there is a way that i do not know about). not being able to test the JS functions meant i could not perform about 75% of the tests for this page that i wanted to.
and that is perhaps where i will leave off with testing web pages with perl: it is good for (1) testing initial page content, (2) the state of the database after a page form is submitted, and (3) testing the dynamic content of a page after data is submitted.
as far as i can tell, if you put lots of javascript in your page, there is not a way to write an automated test for it.
i had written an automated test script for some web pages i created. when the users wanted to start using it and testing it, i had to include an authentication mechanism so that each logged-in user would get his/her customized web page. the test script could not pass through the username and password authentication that real people went through so i had to find another way. i thought once i could accomplish this, all testing could be automated.
by-passing the log-in page turned out to be as easy as setting a single cookie. therefore, programming this required two steps: first, the client (the simulated user) had to be able to receive cookies from the server. since the perl testing module (WWW::Mechanize) inherits from the module that simulates a browser user and receives cookies (LWP::UserAgent), this was easy. second, the server had to create the cookie and send it to the client. i created a web page that did nothing other than this. my test script had to first call this page to get its cookie set before calling the page that required the login cookie (the page i want to test).
once that hurdle was leaped, i started writing my test script. here i met some fairly large limitations. most of my tests were checking how the page would respond when certain radio buttons or drop-downs were manipulated. this is all done by client-side javascript and the test script could not run this (unless there is a way that i do not know about). not being able to test the JS functions meant i could not perform about 75% of the tests for this page that i wanted to.
and that is perhaps where i will leave off with testing web pages with perl: it is good for (1) testing initial page content, (2) the state of the database after a page form is submitted, and (3) testing the dynamic content of a page after data is submitted.
as far as i can tell, if you put lots of javascript in your page, there is not a way to write an automated test for it.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home