0

I am using PhantomJS to execute JS code on a webpage to automate a script for me, In this example I am trying to login through this webpage. It is kinda not like ordinary web logins, it uses JS as a submit button not a FORM.

so anyways here is the problem i am facing.

my problem

as you can see. it actually submited the page. the problem is as you can see the values of Username and Passwords were not added to the webpage. I am using this:

document.getElementById("txtUsername").vlaue="plaplapla";
document.getElementById("txtPassword").vlaue="plapalpla";

HTML code for Login :

<a id="btnLogin" href="javascript:WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions(&quot;btnLogin&quot;, &quot;&quot;, true, &quot;&quot;, &quot;&quot;, false, true))"><b>Login</b></a>

HTML code for Username and password :

<input name="txtUsername" type="text" id="txtUsername" style="width:190px;" /><br>
<input name="txtPassword" type="password" id="txtPassword" style="width:190px;" /><br>

Also, I have no access to the HTML to change it. I will be using JS to do all the work.

any Ideas ?

Skyliquid
  • 374
  • 1
  • 5
  • 23

1 Answers1

0

try

document.getElementById("txtUsername").value="plaplapla";
document.getElementById("txtPassword").value="plapalpla";
//add this line
alert("hello!");

To test this, the code has been executed

sunysen
  • 2,265
  • 1
  • 12
  • 13
  • alert will not work, I am using phantomJS, and I know its working as there is a red text that say u have to enter these fields, it doesnt normally show the, unless I use the JS code. I guess the issue comes that there is no VALUE field in the HTML so I cant insert what I need to Textarea, Any Ideas ? – Skyliquid Oct 06 '13 at 13:39