-
May 20th, 2014, 04:45 PM
#1
Thread Starter
Addicted Member
why is the value on this HTML input box not changing
I'm trying to set the value of the username and password input boxes on the website and nothing i'm doing is working. I even tried setting the value of each of the elements to "test" and nothing got put into the input boxes.
Code:
Public Sub CIP_claims()
Dim IE As Object
Dim element As IHTMLElement
Dim doc As HTMLDocument
Dim string1 As String
Dim x As Long
Dim zip As String
Dim npi As String
Dim username As String
Dim password As String
Dim insid As String
Dim nextdos As String
Dim sitearray() As String
Dim provider As String
Dim dos As String
Dim dob As String
Dim otherpayors() As String
Dim pcp() As String
Dim name1() As String
Dim fname As String
Dim lname As String
Dim amount As String
Dim ptid As String
Dim firstrecord As String
Dim claimamount As Currency
username = "test"
password = "test"
x = 2
Set IE = CreateObject("internetexplorer.application")
IE.Visible = True
IE.navigate "https://providerportal.careimprovementplus.com/"
Do: Loop Until IE.readyState = READYSTATE_COMPLETE
Do While IE.Busy
Wait (1)
Loop
Set doc = IE.document
'these lines of code are to login to the correct website with user name and password
'can't check eligibility without logging in
doc.getElementById("ctl00$CPHContent$txtUserID").Value = username
doc.getElementById("ctl00_CPHContent_txtUserID_TextBoxWatermarkExtender_ClientState").Value = username
doc.getElementById("ctl00$CPHContent$txtUserID_TextBoxWatermarkExtender_ClientState").Value = username
doc.getElementById("ctl00_CPHContent_txtUserID").Value = username
doc.getElementById("ctl00_CPHContent_txtUserID").setAttribute.Value = username
doc.getElementById("ctl00_CPHContent_txtPassword").Value = password
doc.getElementById("ctl00$CPHContent$txtPassword").Value = password
doc.getElementById("ctl00$CPHContent$txtPassword_TextBoxWatermarkExtender_ClientState").Value = password
doc.getElementById("ctl00_CPHContent_txtPassword_TextBoxWatermarkExtender_ClientState").Value = password
For Each element In doc.all
On Error Resume Next
element.Value = "test"
On Error GoTo 0
Next
doc.getElementById("ctl00$CPHContent$LoginButton").Click
Next
End Sub
-
May 20th, 2014, 04:51 PM
#2
Re: why is the value on this HTML input box not changing
How do you even know since you can't even see the IE object :/
I stopped reading after seeing On Error Resume Next and On Error GoTo 0
-
May 20th, 2014, 04:52 PM
#3
Thread Starter
Addicted Member
Re: why is the value on this HTML input box not changing
Originally Posted by ident
How do you even know since you can't even see the IE object :/
"IE.Visible = True"
Originally Posted by ident
I stopped reading after seeing On Error Resume Next and On Error GoTo 0
first off this is not a very constructive comment and second off if you wanted to set the value of every HTML element = "test" there will be an error because some elements can't have the value set. Putting on error resume next before the loop ensures that every element that can have the value set to "test" will have the value set to "test" and the elemenets that can't won't.
What is a better way of looping through every element and setting the value to "test"??
Code:
For Each element In doc.all
On Error goto novalue
element.Value = "test"
novalue:
Next
Here you go I removed the on error resume next and on error goto 0 now you can read it.
Last edited by iamcpc; May 20th, 2014 at 04:58 PM.
-
May 20th, 2014, 04:56 PM
#4
Re: why is the value on this HTML input box not changing
I dont need to be constructive, you are not programming in VB6 so it has no place being in VB.Net, same goes for GoTo. Exception swallowing is lazy and should not be done. Check any value can be set before setting it. Exception handling says it all. EXCEPTIONAL CIRCUMSTANCES.
as for busy wait loops like
Do: Loop Until Big no no no NO.
-
May 20th, 2014, 05:04 PM
#5
Thread Starter
Addicted Member
Re: why is the value on this HTML input box not changing
Originally Posted by ident
I dont need to be constructive, you are not programming in VB6 so it has no place being in VB.Net, same goes for GoTo. Exception swallowing is lazy and should not be done. Check any value can be set before setting it. Exception handling says it all. EXCEPTIONAL CIRCUMSTANCES.
as for busy wait loops like
Do: Loop Until Big no no no NO.
here you go i removed the on error goto. I also changed the syntax of like 3 lines of code so now it's officially VB.net. I don't care if the Do:Loop is a big no no no. Why do you even bother replying to this thread when you don't even do anything to answer my question or help me?
Code:
Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
Dim IE As Object
Dim element As mshtml.IHTMLElement
Dim doc As mshtml.HTMLDocument
Dim string1 As String
Dim x As Long
Dim zip As String
Dim npi As String
Dim username As String
Dim password As String
Dim insid As String
Dim nextdos As String
Dim sitearray() As String
Dim provider As String
Dim dos As String
Dim dob As String
Dim otherpayors() As String
Dim pcp() As String
Dim name1() As String
Dim fname As String
Dim lname As String
Dim amount As String
Dim ptid As String
Dim firstrecord As String
username = "test"
password = "test"
x = 2
IE = CreateObject("internetexplorer.application")
IE.Visible = True
IE.navigate("https://providerportal.careimprovementplus.com/")
Do : Loop Until IE.readyState = 4
Do While IE.Busy
Loop
doc = IE.document
'these lines of code are to login to the correct website with user name and password
'can't check eligibility without logging in
doc.getElementById("ctl00$CPHContent$txtUserID").Value = username
doc.getElementById("ctl00_CPHContent_txtUserID_TextBoxWatermarkExtender_ClientState").Value = username
doc.getElementById("ctl00$CPHContent$txtUserID_TextBoxWatermarkExtender_ClientState").Value = username
doc.getElementById("ctl00_CPHContent_txtUserID").Value = username
doc.getElementById("ctl00_CPHContent_txtPassword").Value = password
doc.getElementById("ctl00$CPHContent$txtPassword").Value = password
doc.getElementById("ctl00$CPHContent$txtPassword_TextBoxWatermarkExtender_ClientState").Value = password
doc.getElementById("ctl00_CPHContent_txtPassword_TextBoxWatermarkExtender_ClientState").Value = password
For Each element In doc.all
Try
element.Value = "test"
Catch
End Try
Next
doc.getElementById("ctl00$CPHContent$LoginButton").Click()
End Sub
Last edited by iamcpc; May 20th, 2014 at 05:08 PM.
-
May 21st, 2014, 01:18 PM
#6
Thread Starter
Addicted Member
Re: why is the value on this HTML input box not changing
Does anyone have any ideas about what's going on here?
-
May 21st, 2014, 03:37 PM
#7
Re: why is the value on this HTML input box not changing
Here is my question. "Search all my code for your self" This is why you got no response. Why should we? So you completely ignored DONT SWALLOW EXCEPTIONS. This shows me you dont care about learning. I said test for nothing yet you swallow it.
You post how many un needed lines? When is Dim pcp() As String used..... Never so why post it.... Post code we need to see.
There is no reason to use this garbage.
-
May 21st, 2014, 03:49 PM
#8
Thread Starter
Addicted Member
Re: why is the value on this HTML input box not changing
Originally Posted by ident
Here is my question. "Search all my code for your self" This is why you got no response. Why should we? So you completely ignored DONT SWALLOW EXCEPTIONS. This shows me you dont care about learning. I said test for nothing yet you swallow it.
You post how many un needed lines? When is Dim pcp() As String used..... Never so why post it.... Post code we need to see.
There is no reason to use this garbage.
I'm trying to figure out why I can't set the value of an html input box to "test". I'm NOT trying to figure out how to not swallow exceptions. Just to make you happy I added a debug.print for the elements that can't have their values changed. I added the extra code so someone wouldn't have to look at the HTML of the website to find the element ID.
Since you're going to be a rude unless I do exactly as you say then, by all means. teach me the best way to prevent from swallowing exceptions? Is my deubg print enough or should there be more?
Code:
Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
Dim IE As Object
Dim element As mshtml.IHTMLElement
Dim doc As mshtml.HTMLDocument
IE = CreateObject("internetexplorer.application")
IE.Visible = True
IE.navigate("https://providerportal.careimprovementplus.com/")
Do : Loop Until IE.readyState = 4
Do While IE.Busy
Loop
doc = IE.document
For Each element In doc.all
Try
element.Value = "test"
Catch
debug.print ("this element can't have the value changed")
End Try
Next
End Sub
-
May 21st, 2014, 03:53 PM
#9
Re: why is the value on this HTML input box not changing
why do you expect us to have mshtml.IHTMLElementetc installed? I'd need to google the dll and reference it. How about you post up the project removing all exes.
-
May 21st, 2014, 03:58 PM
#10
Thread Starter
Addicted Member
Re: why is the value on this HTML input box not changing
Originally Posted by ident
why do you expect us to have mshtml.IHTMLElementetc installed?
Because it's the microsoft HTML object library that comes installed on every windows computer.
Originally Posted by ident
How about you post up the project removing all exes.
I don't know how to.
-
May 21st, 2014, 04:01 PM
#11
Re: why is the value on this HTML input box not changing
Windows 8.1 says WRONG. Either way its not referenced. Send the projected with no exes or give up.
-
May 21st, 2014, 04:01 PM
#12
Re: why is the value on this HTML input box not changing
you use the delete button, it aitn hard.
-
May 21st, 2014, 04:02 PM
#13
Thread Starter
Addicted Member
Re: why is the value on this HTML input box not changing
Originally Posted by ident
Windows 8.1 says WRONG. Either way its not referenced. Send the projected with no exes or give up.
I don't know how to.
-
May 21st, 2014, 04:04 PM
#14
Thread Starter
Addicted Member
Re: why is the value on this HTML input box not changing
Originally Posted by ident
you use the delete button, it aitn hard.
I don't know what i should be using the delete button on.
-
May 21st, 2014, 04:13 PM
#15
Re: why is the value on this HTML input box not changing
if you want my help post up the solution file. If not i wont loose sleep.
-
May 22nd, 2014, 10:26 AM
#16
Thread Starter
Addicted Member
Re: why is the value on this HTML input box not changing
Originally Posted by ident
if you want my help post up the solution file. If not i wont loose sleep.
I tried to upload my windowsapplication1.sln file and, when I went to upload it to the forums, it said invalid file. Can anyone help me understand how to updload this file so that ident can continue to tell me how wrong my code is without actually answering any of my questions?
-
May 22nd, 2014, 02:50 PM
#17
Re: why is the value on this HTML input box not changing
Now when you say 'nothing is working', what exactly do you mean? Does it throw an exception at some point in the code? What are you expecting to happen?
I always add to the reputation of those whose posts are helpful, and even occasionally to those whose posts aren't helpful but who obviously put forth a valiant effort. That is, when the system will allow it.
My war with a browser-redirect trojan
-
May 22nd, 2014, 03:11 PM
#18
Thread Starter
Addicted Member
Re: why is the value on this HTML input box not changing
Originally Posted by dolot
Now when you say 'nothing is working', what exactly do you mean? Does it throw an exception at some point in the code? What are you expecting to happen?
I mean that if I do:
Code:
For each element in doc.all
try
element.value = "test"
catch
end try
next
The value of the username and password input boxes should be set to "test" but they are not.
also the code below is trying to reference specifically the username/password input boxes and it does not set the value to "test". There's no errors or exceptions just no "test" in the input boxes.
Code:
doc.getElementById("ctl00$CPHContent$txtUserID").Value = "test"
doc.getElementById("ctl00_CPHContent_txtUserID_TextBoxWatermarkExtender_ClientState").Value = "test"
doc.getElementById("ctl00$CPHContent$txtUserID_TextBoxWatermarkExtender_ClientState").Value = "test"
doc.getElementById("ctl00_CPHContent_txtUserID").Value = "test"
doc.getElementById("ctl00_CPHContent_txtPassword").Value = "test"
doc.getElementById("ctl00$CPHContent$txtPassword").Value = "test"
doc.getElementById("ctl00$CPHContent$txtPassword_TextBoxWatermarkExtender_ClientState").Value = "test"
doc.getElementById("ctl00_CPHContent_txtPassword_TextBoxWatermarkExtender_ClientState").Value = "test"
The value of the username and password input boxes should be set to "test" but they are not.
Last edited by iamcpc; May 22nd, 2014 at 03:14 PM.
-
May 22nd, 2014, 03:22 PM
#19
Re: why is the value on this HTML input box not changing
Uploading the solution file will not help. zip the folder up removing all exes and using the forums uploader upload the compressed file.
-
May 22nd, 2014, 03:32 PM
#20
Re: why is the value on this HTML input box not changing
works fine....setattribute not working here.
vb Code:
Public Class Form1 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim userName = Me.WebBrowser1.Document.GetElementById("ctl00_CPHContent_txtUserID") Dim password = Me.WebBrowser1.Document.GetElementById("ctl00_CPHContent_txtPassword") Dim enter = Me.WebBrowser1.Document.GetElementById("ctl00_CPHContent_LoginButton") If userName IsNot Nothing AndAlso password IsNot Nothing AndAlso enter IsNot Nothing Then userName.OuterText = "AnnoyingMember" password.OuterText = "password" ' not One comment, System.Threading.Thread.Sleep(200) enter.InvokeMember("click") End If End Sub End Class
-
May 22nd, 2014, 03:33 PM
#21
Re: why is the value on this HTML input box not changing
Notice how i did that with OUT ABUSING try catch. How can you tell any way there is no exception when you hide them?
-
May 22nd, 2014, 03:55 PM
#22
Thread Starter
Addicted Member
Re: why is the value on this HTML input box not changing
WindowsApplication1.zip
Originally Posted by ident
Uploading the solution file will not help. zip the folder up removing all exes and using the forums uploader upload the compressed file.
I attached the file
-
May 22nd, 2014, 04:14 PM
#23
Thread Starter
Addicted Member
Re: why is the value on this HTML input box not changing
Originally Posted by ident
Notice how i did that with OUT ABUSING try catch. How can you tell any way there is no exception when you hide them?
The problem is that the login button is based on what data is inside of the input box not on the outertext of the input box.
-
May 22nd, 2014, 05:32 PM
#24
Re: why is the value on this HTML input box not changing
What on earth are you talk about. Iv shown you above how to invoke the button.
-
May 23rd, 2014, 09:57 AM
#25
Thread Starter
Addicted Member
Re: why is the value on this HTML input box not changing
Originally Posted by ident
What on earth are you talk about. Iv shown you above how to invoke the button.
I didn't ask how to invoke the button. I asked how to set the value of the input boxes. Even more specifically why when i set the value of the input box that the value on this HTML input box does not change.
-
May 23rd, 2014, 02:46 PM
#26
Re: why is the value on this HTML input box not changing
Iv shown you how to set the bboxes. Jesus.
-
Jun 3rd, 2014, 06:11 PM
#27
Thread Starter
Addicted Member
Re: why is the value on this HTML input box not changing
Originally Posted by ident
Iv shown you how to set the bboxes. Jesus.
You didn't tell me how to set the value of the input boxes. You have shown me how to set the outertext of the input boxes. When I set the outertext of the input boxes and click login it does not read the outertext part of the input boxes.
if I manually type test as the username and password then click submit then
doc.getElementById("ctl00$CPHContent$txtUserID").Value = "annoying member"
will set the value of the input box to "annoying membmer" but it won't do that when the website first loads. I'm trying to figure out why.
Also thank you for doing such a good job for answering every question I didn't ask.
Last edited by iamcpc; Jun 3rd, 2014 at 06:45 PM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|