Jump to content
Sign in to follow this  
acidbat

Need some scripting assistance

Recommended Posts

acidbat

Hi everyone,I need some help with forms using IE.The form I am working has lots of fields with values I can select from.Good news is that I managed to script just about all of them except for 1.The troublesome one is a "Date of Birth" field and the source code looks like this:

<div class="corp-form-part"><div id="" style="" class="corp-form-item"><label>Birth Date<span class="mandatory">*</span></label><input type="text" name="subject.birthDate" value="" id="subject.birthDate" class="corp-calendar "></div>

My script looks like this:

$dob = _IEFormElementGetObjByName ($oform1, "subject.birthDate")
_IEFormElementSetValue($dob, "12121966")

But when I execute my script nothing happens and there is no error in my Scite Console either.

I used _IEFormElementGetObjByName & _IEFormElementSetValue for all my other fields without any issues but for this DOB it just wont enter anything.

Any help would be grealty appriciated.

Cheers

Edited by acidbat

Share this post


Link to post
Share on other sites
czardas

Hmm, I'm guessing a little here. Have you checked that the html the same for all fields, or is there something different about the DOB?

Edited by czardas

Share this post


Link to post
Share on other sites
acidbat

The difference is that most of the fields are a dropdown list with values and some are a free text field (you can type anything you want).

The DOB has the option to enter text or you can click on the calendar icon on the side to specify the date you want from there.

Hope that makes sense?

Share this post


Link to post
Share on other sites
czardas

I'm out of my depth a bit here, because I haven't done this before. Do you get @error = 0 after getting the object name?

$dob = _IEFormElementGetObjByName($oform1, "subject.birthDate")
msgbox(0, "Error Code", @error)

Argh the new forum software keeps messing up the code.

Edited by czardas

Share this post


Link to post
Share on other sites
acidbat

From memory yes, but I will confirm the exact return message from Scite tomorrow.

Share this post


Link to post
Share on other sites
czardas

Well that's the first check I would run. If the error value is not zero then the input isn't recognized. I'm not sure how to solve that, but that doesn't mean it can't be done.

Share this post


Link to post
Share on other sites
acidbat

I ran the code you mentioned above and the messagebox returned 0.

Share this post


Link to post
Share on other sites
czardas

Looking at you code again, I was presuming that the two statements are on two separate lines, since it would not work for the other cases if you had made that mistake.

$dob = _IEFormElementGetObjByName($oform1, "subject.birthDate")
_IEFormElementSetValue($dob, "12121966")

Due to a recent forum upgrade there have been some problems with code boxes. Perhaps the second statement is not working properly. Test it using the same msgbox. If that fails, it will be hard to advise you without seeing the actual webpage (so we can run our own tests) or at least more of your code.

Share this post


Link to post
Share on other sites
acidbat

Looking at you code again, I was presuming that the two statements are on two separate lines, since it would not work for the other cases if you had made that mistake.

$dob = _IEFormElementGetObjByName($oform1, "subject.birthDate")
_IEFormElementSetValue($dob, "12121966")

Due to a recent forum upgrade there have been some problems with code boxes. Perhaps the second statement is not working properly. Test it using the same msgbox. If that fails, it will be hard to advise you without seeing the actual webpage (so we can run our own tests) or at least more of your code.

Yes, the statements are on two seperate lines :mellow:

I ran the msgbox again (hoping I did this correct) with the following syntax:

$dob = _IEFormElementSetValue($dob, "12121966")
msgbox(0, "Error Code", @error)

Which returned 0

The site is an internal site.

I'll try and paste more snippets of my code:

$oForm1 = _IEFormGetObjByName ($oIE, "checkSubmitForm")
$office = _IEFormElementGetObjByName($oform1, "officeCode")
$ctype = _IEFormElementGetObjByName($oform1, "type")
$catg = _IEFormElementGetObjByName($oform1, "category")
$purp = _IEFormElementGetObjByName($oform1, "purpose")
$primaryN = _IEFormElementGetObjByName($oform1, "subject.names(1000).type")
$famname = _IEFormElementGetObjByName($oform1, "subject.names(1000).familyName")
$givenname = _IEFormElementGetObjByName($oform1, "subject.names(1000).firstGivenName")
$dob = _IEFormElementGetObjByName($oform1, "subject.birthDate") <-- No errors
$gender = _IEFormElementGetObjByName($oform1, "subject.gender")
$country1 = _IEFormElementGetObjByName($oform1, "subject.birthPlace.country")
$addrtype1 = _IEFormElementGetObjByName($oform1, "subject.addresses(1000).type")
$addrtype2 = _IEFormElementGetObjByName($oform1, "subject.addresses(1000).line")
$country2 = _IEFormElementGetObjByName($oform1, "subject.addresses(1000).country")
$notes = _IEFormElementGetObjByName($oform1, "note")
 
; Set field values in the form
_IEFormElementSetValue($office, "FF")
_IEFormElementSetValue($ctype, "INDIV")
_IEFormElementSetValue($catg, "IMMI")
_IEFormElementSetValue($purp, "Automation Test")
_IEFormElementSetValue($primaryN, "PRIM")
_IEFormElementSetValue($famname, "test")
_IEFormElementSetValue($givenname, "test")
_IEFormElementSetValue($dob, "12121966") <-- Not typing
_IEFormElementSetValue($gender, "M")

As said before, everything works except for the DOB,

I can email you the screenshot and\or part of the HTML code if this internal site if you like?

Edited by acidbat

Share this post


Link to post
Share on other sites
czardas

I don't understand why it isn't working. It seems strange that there are no errors, yet it isn't filling in the field. Perhaps you can interact with the actual calendar and click the date. It might be a bit complicated to set up the webpage using the html. I'm going to be a bit busy over the next few days, but you can always try emailing me. I can't promise anything but if you send the html, send it either as text or in a zip file.

Edited by czardas

Share this post


Link to post
Share on other sites
acidbat

Noticed now that the DOB field also has a button on the side which brings up a calendar when clicked.

Appears to be a DHTML (Dynamic HTML with some Ajax code).

Not sure if that helps or not, but i'll keep investigating the issue.

Share this post


Link to post
Share on other sites
acidbat

Seems like an odd format to enter a DOB, have you tried other ways such as "12/12/1966" etc...

Yup, tried that too - even 12\12\1966 just to see but nothing is hitting the DOB field (as in, no text is entered - it remains untouched)

Share this post


Link to post
Share on other sites
acidbat

Just for kicks I added this in my script:

for $i = 0 to 10000
_IEFormElementSetValue($dob, "12/12/1960")
Next

Just thinking, maybe the script is running too fast? But it still runs and attempts to add a value there 10000 times without luck.

Edited by acidbat

Share this post


Link to post
Share on other sites
acidbat

I see the name and id are the same, I dont know how significant that if but try

_IEGetObjById instead of by name

I tried that too (being super excited) but same behaviour there too.

$dob = _IEGetObjById ($oform1, "subject.birthDate")
_IEFormElementSetValue($dob, "12/12/1960")

Share this post


Link to post
Share on other sites
acidbat

Alright I am little closer now.

With this code I had before:

$dob = _IEFormElementGetObjByName ($oform1, "subject.birthDate")
_IEFormElementSetValue($dob, "12/12/1960")

It does write the 12/12/1960 value in the calendar (and not the text field.....)

I discovered that when I ran this code:

_IEImgClick ($oform1, "cal.gif", "src")

It pops up the calendar window and I can see that the values are there.

However, next problem I have now is to close the window (if I confirm with the Enter key it will close), but if I try and send("{ENTER}") it does not actually do anything.

So my next issue is to close the window by confirming with the enter key or..

Find out why it sticks the value in the calendar and not on the text field next to it...

Any ideas?

Share this post


Link to post
Share on other sites
selvan27

sir, i am an new baby

what wrong with this script

WinActivate("[CLASS:Notepad]", "")

WinMenuSelectItem("[CLASS:Notepad] ", "", "&File", "Page Set&up..." )

the script did not work , it did not launch page setup from note pad

please help me to solve this problem, thankyou

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.