Ask Question Forum:
Model Library:2025-02-08 Updated:A.I. model is online for auto reply question page
C
O
M
P
U
T
E
R
2
8
Show
#
ASK
RECENT
←
- Underline
- Bold
- Italic
- Indent
- Step
- Bullet
- Quote
- Cut
- Copy
- Paste
- Table
- Spelling
- Find & Replace
- Undo
- Redo
- Link
- Attach
- Clear
- Code
Below area will not be traslated by Google,you can input code or other languages
Hint:If find spelling error, You need to correct it,1 by 1 or ignore it (code area won't be checked).
X-position of the mouse cursor
Y-position of the mouse cursor
Y-position of the mouse cursor
Testcursor
caretPos
Attachment:===
Asked by Leo Torres
at 2024-08-30 01:28:53
Point:500 Replies:26 POST_ID:829205USER_ID:12082
Topic:
Powershell;.NET;C# Programming Language
What I find different about this page is that the html does not have a value="" field to store user name and password for login so how can it be done.
cls#if (!(Get-Variable ie -Scope global -ea SilentlyContinue)) { $global:ie = New-Object -comobject InternetExplorer.Application }$ie = New-Object -comobject InternetExplorer.Application$ie.visible = $true$ie.silent = $true$wc = New-Object System.Net.WebClient$login = "User"$password = "password#"$url = "https://ultidev/secure/Dashboard.jspa"[string] $content = $wc.DownloadString($URL)$ie.Navigate2($url) while ($ie.busy) { Start-Sleep -m 100 } while ($ie.Document.readyState -ne 'Complete') { Start-Sleep -m 100 }Start-Sleep -s 5$ie.Document.getElementsByTagName("input") | ? { $_.Id -eq 'login-form-username' } | % { $_.value = $login }$ie.Document.getElementsByTagName("input") | ? { $_.Id -eq 'login-form-password' } | % { $_.value = $password }$ie.Document.getElementsByTagName("button") | ? { $_.Type -eq 'login' } | % { $_.Click() } 1:2:3:4:5:6:7:8:9:10:11:12:13:14:15:16:17:18:19:20:21:22:23:24:25:
<"div class="view g-login">"<"div id="content">"<"form name="loginform" class="aui gdt" id="loginform" action="#" method="post">"<"div class="field-group">"<"label id="usernamelabel" accesskey="u" for="login-form-username">"<"u>"U<"/u>"sername<"/label>"<"input name="os_username" class="text medium-field" id="login-form-username" type="text">"<"/div>"<"div class="field-group password">"<"label id="passwordlabel" accesskey="p" for="login-form-password">"<"u>"P<"/u>"assword<"/label>"<"input name="os_password" class="text medium-field" id="login-form-password" type="password">"<"/div>"<"fieldset class="group">"<"div class="checkbox" id="rememberme">"<"input name="os_cookie" class="checkbox" id="login-form-remember-me" type="checkbox" value="true">"<"label id="remembermelabel" accesskey="r" for="login-form-remember-me">"<"u>"R<"/u>"emember my login on this computer<"/label>"<"/div>"<"/fieldset>"<"div class="field-group hidden" id="captcha">"<"label id="captchalabel" accesskey="c" for="login-form-captcha">"Please enter the word as shown below<"/label>"<"input name="os_captcha" class="text medium-field captcha-response" id="login-form-captcha" type="text">"<"div class="captcha-container">"<"img width="200" height="100" class="captcha-image" id="captchaimg" alt="" src="">"<"a tabindex="-1" title="Refresh the image" class="captcha-trigger" id="os-captcha-icon" href="#login-form-os-captcha">"<"span class="aui-icon captcha-reload icon-reload">"Refresh the image<"/span>"<"/a>"<"/div>"<"/div>"<"div class="field-group" id="publicmodeooff">"<"div id="publicmodeoffmsg">"Not a member? To request an account, please contact your <"a id="contact-admin" href="https://ultidev/secure/ContactAdministrators!default.jspa" target="_parent">"JIRA administrators<"/a>".<"/div>"<"/div>"<"div class="buttons-container">"<"div class="buttons">"<"input name="login" class="button" id="login" type="submit" value="Log In">"<"a class="button aui-button-cancel cancel" id="forgotpassword" href="https://ultidev/secure/ForgotLoginDetails.jspa" target="_parent">"Can't access your account?<"/a>"<"/div>"<"/div>"<"/form>"<"/div>"<"/div>" 1:
Expert: Qlemo replied at 2024-09-19 01:28:32
No, not saying that, but probably you are the only one able to check and solve. You are seeing different stuff than we do.
You'll have to dump part of the code PS sees at that moment you see the login, and then try to find the object with getElementByID or getElementsByXXX (tagname, name, type, ...). Play with it, don't be focussed on the static code for now. As soon as you are able to fill in login data with an assignment, you can put that into the code. That is the way I work with such stuff.
You'll have to dump part of the code PS sees at that moment you see the login, and then try to find the object with getElementByID or getElementsByXXX (tagname, name, type, ...). Play with it, don't be focussed on the static code for now. As soon as you are able to fill in login data with an assignment, you can put that into the code. That is the way I work with such stuff.
Author: Leo Torres replied at 2024-09-18 21:28:25
So your saying it cant be done?
Expert: Qlemo replied at 2024-09-15 06:35:20
Nope, seems to be active code instead of static fields. And that is probably the reason the PS code does not work.
Author: Leo Torres replied at 2024-09-15 04:04:57
Yes your right. I get the same thing.
I went to link then had it show source. copied pasted it did it twice to make sure. same thing.
if I do a get-content I get the same file .
How ever if I open the page and hit F12 and copy from the DOM Explorer I do see the login fields.
I have attached new html file here from DOM Explorer. Hope this works?
I went to link then had it show source. copied pasted it did it twice to make sure. same thing.
if I do a get-content I get the same file .
How ever if I open the page and hit F12 and copy from the DOM Explorer I do see the login fields.
I have attached new html file here from DOM Explorer. Hope this works?
Expert: Qlemo replied at 2024-09-15 03:39:18
This is what I see:
Author: Leo Torres replied at 2024-09-14 21:29:04
This is the site code here it is again
Here is what the page looks like
Here is what the page looks like
Any reason why you think this is not the code?
Expert: Qlemo replied at 2024-09-14 03:38:38
No, that is not the correct site code. It is the dashboard, and you need to click the "Log In" link to go to a login page.
Author: Leo Torres replied at 2024-09-13 22:12:03
Code produced this error.
The property 'value' cannot be found on this object. Verify that the property exists and can be set.At line:19 char:1+ ($ie.Document.getElementById("login-form-username") | select -first 1).value = $ ...+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidOperation: (:) [], RuntimeException + FullyQualifiedErrorId : PropertyNotFoundThe property 'value' cannot be found on this object. Verify that the property exists and can be set.At line:20 char:1+ ($ie.Document.getElementById("login-form-password") | select -first 1).value = $ ...+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidOperation: (:) [], RuntimeException + FullyQualifiedErrorId : PropertyNotFound 1:2:3:4:5:6:7:8:9:10:11:12:13:
I have also attached page source here.
Expert: Qlemo replied at 2024-09-13 04:54:06
Ok, try if
($ie.Document.getElementById("login-form-username") | select -first 1).value = 'x'
sets something in the username field. We do not have to do that with the HTML fragment you posted in the question, but maybe you have to on your real page.
If that works, use (I've removed some irrelevant code you might have to readd for your purpose):
($ie.Document.getElementById("login-form-username") | select -first 1).value = 'x'
sets something in the username field. We do not have to do that with the HTML fragment you posted in the question, but maybe you have to on your real page.
If that works, use (I've removed some irrelevant code you might have to readd for your purpose):
cls#if (!(Get-Variable ie -Scope global -ea SilentlyContinue)) { $global:ie = New-Object -comobject InternetExplorer.Application }$ie = New-Object -comobject InternetExplorer.Application$ie.visible = $true$ie.silent = $true$login = "User"$password = "pass"$url = "https://ultidev/secure/Dashboard.jspa"$ie.Navigate2($url)while ($ie.busy) { Start-Sleep -m 100 }while ($ie.Document.readyState -ne 'Complete') { Start-Sleep -m 100 }Start-Sleep -s 5($ie.Document.getElementById("login-form-username") | select -first 1).value = $login($ie.Document.getElementById("login-form-password") | select -first 1).value = $password$ie.Document.getElementsByTagName("button") | ? { $_.Type -eq 'login' } | % { $_.Click() } 1:2:3:4:5:6:7:8:9:10:11:12:13:14:15:16:17:18:19:20:
Author: Leo Torres replied at 2024-09-13 03:48:45
The web page comes up but the User name is not filled in
Author: Leo Torres replied at 2024-09-13 03:41:40
Here is the out put
Expert: Qlemo replied at 2024-09-12 05:28:33
Lines 21 and 22 should have some output - do they? You need not to execute the lines following those for now.
Author: Leo Torres replied at 2024-09-12 04:29:42
Guys sorry for the delay. I have been sick and out the past week. I will be back on the next for days
Code opens page put does not enter data into fields
Code opens page put does not enter data into fields
cls#if (!(Get-Variable ie -Scope global -ea SilentlyContinue)) { $global:ie = New-Object -comobject InternetExplorer.Application }$ie = New-Object -comobject InternetExplorer.Application$ie.visible = $true$ie.silent = $true$wc = New-Object System.Net.WebClient$login = "User"$password = "pass"$url = "https://ultidev/secure/Dashboard.jspa"[string] $content = $wc.DownloadString($URL)$ie.Navigate2($url) while ($ie.busy) { Start-Sleep -m 100 } while ($ie.Document.readyState -ne 'Complete') { Start-Sleep -m 100 }Start-Sleep -s 5$ie.Document.getElementById("login-form-username")$ie.Document.getElementById("content").getElementById("login-form-username")#$ie.Document.getElementById("content").getElementById("login-form-username") | ? { $_.Id -eq 'login-form-username' } | % { $_.value = $login }#$ie.Document.getElementById("login-form-username").value= "$login"#$ie.Document.getElementById("login-form-password").value = "$password"#$ie.Document.getElementsByTagName("input") | ? { $_.Id -eq 'login-form-username' } | % { $_.value = $login }#$ie.Document.getElementsByTagName("input") | ? { $_.Id -eq 'login-form-password' } | % { $_.value = $password }#$ie.Document.getElementsByTagName("button") | ? { $_.Type -eq 'login' } | % { $_.Click() }Write-Host $content 1:2:3:4:5:6:7:8:9:10:11:12:13:14:15:16:17:18:19:20:21:22:23:24:25:26:27:28:29:30:31:
Author: Leo Torres replied at 2024-09-01 18:42:22
Not at work now will try to test this tomorrow
Expert: Qlemo replied at 2024-09-01 08:47:57
rwniceing,
.value or .Value does not matter. Nor does .Navigate or .Navigate2. The latter is able to resolve more than an URL, e.g. a file with registered type, that is all.
In regard of the ready state, since IE isn't busy anymore, the document is available - it might be not ready yet (but should). That will not cause an issue.
Leo,
You should first see if typing
.value or .Value does not matter. Nor does .Navigate or .Navigate2. The latter is able to resolve more than an URL, e.g. a file with registered type, that is all.
In regard of the ready state, since IE isn't busy anymore, the document is available - it might be not ready yet (but should). That will not cause an issue.
Leo,
You should first see if typing
$ie.Document.getElementById("login-form-username")$ie.Document.getElementById("content").getElementById("login-form-username") 1:2:
shows any object.
Expert: rwniceing replied at 2024-09-01 02:37:30
while($ie.ReadyState -ne 4) is not while ($ie.Document.ReadyState -ne "Complete") that will cause issue since the document is not ready so there is no object with value Please check it out
Expert: rwniceing replied at 2024-09-01 02:24:16
What is url full path ?
Could you try to Navigate instead of Navigate2
On VBA, value should be Value , but probably on here , it is okay
for lower case of 'v" ?
Could you try to Navigate instead of Navigate2
On VBA, value should be Value , but probably on here , it is okay
for lower case of 'v" ?
Author: Leo Torres replied at 2024-09-01 02:06:01
Produced Error
The property 'value' cannot be found on this object. Verify that the property exists and can be set.At line:17 char:1+ $ie.Document.getElementById("login-form-username").value= "$login"+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidOperation: (:) [], RuntimeException + FullyQualifiedErrorId : PropertyNotFoundThe property 'value' cannot be found on this object. Verify that the property exists and can be set.At line:18 char:1+ $ie.Document.getElementById("login-form-password").value = "$password"+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidOperation: (:) [], RuntimeException + FullyQualifiedErrorId : PropertyNotFound 1:2:3:4:5:6:7:8:9:10:11:12:13:
Actual code
$login = "ID"$password = "passwd"$ie = New-Object -comobject InternetExplorer.Application$ie.visible = $true$ie.silent = $true$ie.Navigate2($url) while ($ie.busy) { Start-Sleep -m 100 } while ($ie.Document.readyState -ne 'Complete') { Start-Sleep -m 100 }$ie.Document.getElementById("login-form-username").value= "$login"$ie.Document.getElementById("login-form-password").value = "$password" 1:2:3:4:5:6:7:8:9:10:11:12:13:14:
Expert: rwniceing replied at 2024-08-30 22:41:55
$login = "User"
$password = "password#"
$ie.Document.getElementById("login-form-username").value= "$login"
$ie.Document.getElementById("login-form-password").value = "$password"
the userlogin name is at input tag with id , login-form-username , so you
just put your username at $login
where those two code you put ,please read the reference link
$password = "password#"
$ie.Document.getElementById("login-form-username").value= "$login"
$ie.Document.getElementById("login-form-password").value = "$password"
the userlogin name is at input tag with id , login-form-username , so you
just put your username at $login
where those two code you put ,please read the reference link
Author: Leo Torres replied at 2024-08-30 22:27:56
OK here is the code but I dont see the Username tag any where I wonder if its encrypted or something.
Here is the code thru DOM Explorer
Here is the code thru DOM Explorer
I cant see this in HTML Wonder if this is a deal breaker.
Expert: rwniceing replied at 2024-08-30 02:43:39
Could you post the whole code ? where you put those two lines in the code ?
This link is good reference to your question at EE link
http://www.experts-exchange.com/Programming/Languages/Scripting/Powershell/Q_28379350.html
This link is good reference to your question at EE link
http://www.experts-exchange.com/Programming/Languages/Scripting/Powershell/Q_28379350.html
Author: Leo Torres replied at 2024-08-30 02:35:28
Code does not work now it produces error.
The property 'value' cannot be found on this object. Verify that the property exists and can be set.At line:25 char:1+ $ie.Document.getElementById("login-form-username").value= "$login"+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidOperation: (:) [], RuntimeException + FullyQualifiedErrorId : PropertyNotFoundThe property 'value' cannot be found on this object. Verify that the property exists and can be set.At line:26 char:1+ $ie.Document.getElementById("login-form-password").value = "$password"+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidOperation: (:) [], RuntimeException + FullyQualifiedErrorId : PropertyNotFound 1:2:3:4:5:6:7:8:9:10:11:12:13:
Expert: rwniceing replied at 2024-08-30 02:28:47
it seems your post code is already done your need.
Actually did you try your code, working or not ? OR could you write more about your question
Actually did you try your code, working or not ? OR could you write more about your question
Expert: rwniceing replied at 2024-08-30 02:15:35
you can set the default value for input tage 's username and password inside the form so that you can submit the form with the username and password you set at
$login = "User"
$password = "password#"
$login = "User"
$password = "password#"
<form name="loginform" class="aui gdt" id="loginform" action="#" method="post"><div class="field-group"><label id="usernamelabel" accesskey="u" for="login-form-username"><u>U</u>sername</label><input name="os_username" class="text medium-field" id="login-form-username" type="text"></div><div class="field-group password"><label id="passwordlabel" accesskey="p" for="login-form-password"><u>P</u>assword</label><input name="os_password" class="text medium-field" id="login-form-password" type="password"></div>.....................</form> 1:2:3:4:5:6:7:8:
Author: Leo Torres replied at 2024-08-30 02:08:09
Add or Replace what I have with what you suggested?
Expert: rwniceing replied at 2024-08-30 01:53:56
You can try to add this
$ie.Document.getElementById("login-form-username").value= "$login"
$ie.Document.getElementById("login-form-password").value = "$password"
$ie.Document.getElementById("login-form-username").value= "$login"
$ie.Document.getElementById("login-form-password").value = "$password"



