Script running successfully on Firefox does not run successfully on Phantomjs (headless)

154 views
Skip to first unread message

Roffe

unread,
Sep 20, 2013, 4:37:45 AM9/20/13
to sa...@googlegroups.com
Hi.

I am trying to set up Sahi as an automated test framework for a large portal, and I need the speed of a headless browser.  I have the following simple script that runs successfuly on Firefox (anonymized):

_navigateTo("https://my.web.site.no"); 
_click(_link("Login")); 
_wait(10000,_exists(_div("username")));   // <-- this was an attempt to make it work in phantomjs, which also failed to improve the situation
_setValue(_textbox(0,_in(_div("username"))), "12345678901"); // <-- This is where it fails.
_click(_submit("Proceed")); 
_assertExists(_listItem("User name is not valid.")); 


It fails in line 4 on phantomjs with the following message in the sahi log: 
_setValue(_textbox(0,_in(_div("username"))), "12345678901"); - Error: The parameter passed to _in was not found on the browser at Sep 20, 2013 8:52:16 AM

Here is a html snippet from the page source in Firefox:

   <div class="username" id="username"> 
       <div class="col1"><span id="labelUsername">User name</span>:</div> 
       <div class="col2"> 
           <span class="textUI"> 
               <input type="text" name="security_authentication{pageFlow.authenticationFormBean.username}" value="" size="30"> 
           </span> 
           <span class="buttonUI"> 
               <input type="submit" name="security_authentication_action:selectedSomeType" value="Proceed"> 
           </span> 
       </div> 
   </div>


I have tried several ways to make set that value for the text box, but it seems like I am unable to access the elements on this page in Phantomjs, while sahi does this without that problem in Firefox.

Can someone with experience with Sahi and phantomjs show me the light?  :-)


kazi safaet mahmud Auvi

unread,
Sep 23, 2013, 2:15:56 AM9/23/13
to sa...@googlegroups.com
Hi Roffe,

I am doing like this. You can try.

_setValue(_textbox("loginName"), "yourUserName");
_setValue(_password("password"), "yourPassword");
_click(_submit("Proceed"));


Thanks
Safaet



--
You received this message because you are subscribed to the Google Groups "sahi" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sahi+uns...@googlegroups.com.
To post to this group, send email to sa...@googlegroups.com.
Visit this group at http://groups.google.com/group/sahi.
For more options, visit https://groups.google.com/groups/opt_out.

Roffe

unread,
Nov 19, 2013, 3:47:54 AM11/19/13
to sa...@googlegroups.com
Hi Safaet

Thank for the effort.  I guess your login page is built very differently from the one I am writing tests for.  _textbox("loginName") is far from sufficient to identify the textbox in question.  I sincerely believe this is a question about browser differences, and I find debugging headless browser tests extremely difficult, especially when the real browsers do not fail.

Regards,
Roffe

Gyanadeep S

unread,
Nov 19, 2013, 11:57:40 PM11/19/13
to sa...@googlegroups.com

I think u need to provide window name where u passing ur values. To get the window name u need to go in recording mode and then do the mouse over on that field. And u will get the window result.

Gyanadeep

Reply all
Reply to author
Forward
0 new messages