The Web Design Group

... Making the Web accessible to all.

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> GetElementbyPOST
techstudent01
post May 28 2016, 10:46 PM
Post #1





Group: Members
Posts: 2
Joined: 28-May 16
Member No.: 24,281



Hey everyone. I'm new to this group and I could use a little help. I'm creating an auto login powershell script. With most of the webistes, I use the GetElementByID tag and use that to input my values.

I have 2 email accounts (live.com and msn.com) that I need to automate and here'es the problem.

The login in page for for both emails is
QUOTE
login.live.com
When you pull the page up there is some css hints that are already in the field of email and password.

When I use the GetElementByID and try to replace the values, the hints are still there and my input values (my username and password) actually append on top of the hints. In my code, the page errors out when the submit button even is triggered because it acts like I didn't enter anything.

How can I replace the hint values with my input values? I tried using GetElementsByName and that did not work either.

It looks like when i type something with the inspect element open, my input goes into a "postValue" tag. I don't know how to GetElementByPostValue? I just don't know how to write the code correctly??

Thank you everyone in advance for your help. If you would like to see my code, I can post it. Being new to this forum and an IT student, I'm just trying to get into the flow of how this works. I hope what I'm saying makes sense.

Thanks again for your help,
Techstudent01
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Christian J
post May 31 2016, 06:43 PM
Post #2


.
********

Group: WDG Moderators
Posts: 9,656
Joined: 10-August 06
Member No.: 7



QUOTE(techstudent01 @ May 29 2016, 05:46 AM) *

Hey everyone.

Hi, sorry for late reply...

QUOTE
I'm creating an auto login powershell script.

Afraid I don't know anyhting about that.

QUOTE
With most of the webistes, I use the GetElementByID tag and use that to input my values.

FWIW, getElementByID (note the beginning lowercase "g") is a javascript method, not an HTML tag.

QUOTE
I have 2 email accounts (live.com and msn.com) that I need to automate and here'es the problem.

When you pull the page up there is some css hints that are already in the field of email and password.

There is no such thing as "CSS hints". Do you perhaps mean the form field's PLACEHOLDER attribute?

QUOTE
When I use the GetElementByID and try to replace the values, the hints are still there and my input values (my username and password) actually append on top of the hints. In my code, the page errors out when the submit button even is triggered because it acts like I didn't enter anything.

Could you post the code showing this?

QUOTE
How can I replace the hint values with my input values?

Normally the PLACEHOLDER text disappears in the browser as soon as you start typing in a form field.

QUOTE
It looks like when i type something with the inspect element open, my input goes into a "postValue" tag.

There's no tag called "postValue", do you perhaps mean an ID, NAME or CLASS value?

QUOTE
I don't know how to GetElementByPostValue?

There is no such thing. For ID, NAME or CLASS, you might use getElementById, getElementsByName or getElementsByClassName.

QUOTE
If you would like to see my code, I can post it.

Please do!
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
techstudent01
post Jun 1 2016, 09:46 AM
Post #3





Group: Members
Posts: 2
Joined: 28-May 16
Member No.: 24,281



Hey Christian. Thanks for your reply.

Here's the login.live code I'm looking at:
This is the actual form field code:

<input type="email" name="loginfmt" id="i0116" maxlength="113" lang="en" class="form-control ltr_override" aria-describedby="usernameError" data-bind="textInput: value, value: value.delayed, hasFocusEx: focused, placeholder: $placeholderText, ariaLabel: str['CT_PWD_STR_Email_Example'], css: { 'has-error': error }, attr: inputAttributes" aria-label="Email or phone">

This is the placeholder text:

<div class="phholder" style="left: 0px; top: 0px; width: 100%; position: absolute; z-index: 5;" data-bind="visible: !textInput(), click: focus"><div aria-hidden="true" style="cursor: text;" data-bind="text: hintText, css: hintCss" class="placeholder">Email or phone</div></div>
<div aria-hidden="true" style="cursor: text;" data-bind="text: hintText, css: hintCss" class="placeholder">Email or phone</div>

This is the postvalue elements that I want to write to:

<input type="hidden" name="login" data-bind="value: postValue" value="user_input_is_written here">

Does this help?
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
pandy
post Jun 1 2016, 11:49 AM
Post #4


🌟Computer says no🌟
********

Group: WDG Moderators
Posts: 20,730
Joined: 9-August 06
Member No.: 6



Who knows what's available in power shell. I assume it's Windows scripting of some kind, not JavaScript
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Christian J
post Jun 1 2016, 03:53 PM
Post #5


.
********

Group: WDG Moderators
Posts: 9,656
Joined: 10-August 06
Member No.: 7



QUOTE(techstudent01 @ Jun 1 2016, 04:46 PM) *

This is the actual form field code:

<input type="email" name="loginfmt" id="i0116" maxlength="113" lang="en" class="form-control ltr_override" aria-describedby="usernameError" data-bind="textInput: value, value: value.delayed, hasFocusEx: focused, placeholder: $placeholderText, ariaLabel: str['CT_PWD_STR_Email_Example'], css: { 'has-error': error }, attr: inputAttributes" aria-label="Email or phone">

You might use

CODE
document.getElementById('i0116')


to change the VALUE attribute of the above. But its custom HTML5 attribute DATA-BIND suggests a script library is used to manipulate the form (perhaps from knockoutjs.com, which I know nothing about).

QUOTE
This is the postvalue elements that I want to write to:

<input type="hidden" name="login" data-bind="value: postValue" value="user_input_is_written here">

postValue seems to be a variable created by the script library.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post

Reply to this topicStart new topic
2 User(s) are reading this topic (2 Guests and 0 Anonymous Users)
0 Members:

 



- Lo-Fi Version Time is now: 24th April 2024 - 10:37 AM