Jump to content

[SOLVED] How do I select one of these options using _IE*


Recommended Posts

On this site http://nationwide-intermediary.co.uk/calculators/aff_calc I can select the drop down for 'What would your customer like to do?' but I can't select one of the options.

So far I just have this:-

$oIE = _IECreate("http://nationwide-intermediary.co.uk/calculators/aff_calc")
$oIE = _IEAttach("Affordability Calculator | Nationwide for Intermediaries (NFI)")
_IELoadWait($oIE)

$oForm = _IEGetObjById($oIE, "application_type")
_IEAction($oForm, "click")

But I've been unsuccessful so far in selecting one of the options.

I've researched this forum and I think the answer may lie in using the _IETagNameAllGetCollection function but I haven't managed to do it yet.

Any help greatly appreciated.

Edited by Dent
Problem solved
Link to comment
Share on other sites

You can do something like this:

#include <IE.au3>

Local $oIE =  = _IECreate("http://nationwide-intermediary.co.uk/calculators/aff_calc")
If Not IsObj($oIE) Then Exit ConsoleWrite("Error in $oIE" & @CRLF)

Sleep(5000) ; just to make sure

Local $oClassReturn = $oIE.document.getElementsByClassName("pageContainer page0")
If Not IsObj($oClassReturn) Then Exit ConsoleWrite("Error in $oClassReturn" & @CRLF)

Local $oTagReturn = $oClassReturn.Item(0).getElementsByTagName("li")
If Not IsObj($oTagReturn) Then Exit ConsoleWrite("Error in $oTagReturn" & @CRLF)

$oTagReturn.Item(1).click() ; Item(1) = "Buy a new property" / Item(2) = "Remortgage"

Exit

 

Link to comment
Share on other sites

41 minutes ago, Dent said:

Argh, now I have run into trouble selecting the radio buttons on the same page. Are you able to help here?

Please ignore. I solved it using a variation of your previously posted code.

Link to comment
Share on other sites

May I enlist your help again, MichaelHB?

I've made good progress, however one set of drop-down options on the second page I can't seem to select, I've tried many different variations. I'll post my whole code up to that point so you can run it if it helps to reach the relevant section...

#include <IE.au3>
;#include <File.au3>


Local $oIE = _IECreate("http://nationwide-intermediary.co.uk/calculators/aff_calc")
If Not IsObj($oIE) Then Exit ConsoleWrite("Error in $oIE" & @CRLF)

Local $oIE = _IEAttach("Affordability Calculator | Nationwide for Intermediaries (NFI)")

_IELoadWait($oIE)

Local $oClassReturn = $oIE.document.getElementsByClassName("pageContainer page0")
If Not IsObj($oClassReturn) Then Exit ConsoleWrite("Error in $oClassReturn" & @CRLF)

Local $oTagReturn = $oClassReturn.Item(0).getElementsByTagName("li")
If Not IsObj($oTagReturn) Then Exit ConsoleWrite("Error in $oTagReturn" & @CRLF)

For $loop = 1 to 2
$oTagReturn.Item(1).click() ; Item(1) = "Buy a new property" / Item(2) = "Remortgage" | Running the command twice is require to close the drop-down
Next

Local $oMtgAmt = _IEGetObjByName($oIE, "bespAppCharsMiscLoanAmountRequested")
;_IEFormElementSetValue($oMtgAmt, "100000")
_IEAction($oMtgAmt, "focus")
Send("{DEL}")
Send("100000")

Local $oMtgTermYrs = _IEGetObjByName($oIE, "bespAppCharsMiscTermRequestedYY")
;_IEFormElementSetValue($oMtgTermYrs, "25")
_IEAction($oMtgTermYrs, "focus")
Send("25")

Local $oMtgTermMths = _IEGetObjByName($oIE, "bespAppCharsMiscTermRequestedMM")
;_IEFormElementSetValue($oMtgTermMths, "00")
_IEAction($oMtgTermMths, "focus")
Send("00")

Local $oTagReturn = $oClassReturn.Item(0).getElementsByTagName("input")
If Not IsObj($oTagReturn) Then Exit ConsoleWrite("Error in $oTagReturn" & @CRLF)
$oTagReturn.Item(4).click() ; Item(3) = One Applicant / Item(4) = Two Applicants

Local $oTagReturn = $oClassReturn.Item(0).getElementsByTagName("li")
If Not IsObj($oTagReturn) Then Exit ConsoleWrite("Error in $oTagReturn" & @CRLF)

For $loop = 1 to 2
$oTagReturn.Item(4).click() ; Item(4) = Standard / Item(5) = Equity Share / Item(6) = Right to Buy / Item(7) = Shared Ownership | Running the command twice is require to close the drop-down
Next

Local $oTagReturn = $oClassReturn.Item(0).getElementsByTagName("input")
If Not IsObj($oTagReturn) Then Exit ConsoleWrite("Error in $oTagReturn" & @CRLF)
$oTagReturn.Item(5).click() ; Item(5) = Have they found a new home yet 'Yes' / Item(6) = Have they found a new home yet 'No'

Local $oTagReturn = $oClassReturn.Item(0).getElementsByTagName("li")
If Not IsObj($oTagReturn) Then Exit ConsoleWrite("Error in $oTagReturn" & @CRLF)

For $loop = 1 to 2
$oTagReturn.Item(9).click() ; Item(9) = Freehold / Item(10) = Leasehold / Item(11) = Commonhold / Item(12) = Ownership Scotland | Running the command twice is require to close the drop-down
Next

For $loop = 1 to 2
$oTagReturn.Item(14).click() ; Item(14) = Detached House / Item(15) = Detached Bungalow / Item(16) = Semi-Detached Bungalow / Item(17) = Terraced Bungalow / Item(18) = Semi-Detached House / Item(19) = Terraced House / Item(20) = Purpose built flat/maisonette / Item(21) = Converted flat/maisonette | Running the command twice is require to close the drop-down
Next

Local $oPP = _IEGetObjByName($oIE, "bespAppCharsMiscExpectedPurchasePriceMSO")
;_IEFormElementSetValue($oPP, "200000")
_IEAction($oPP, "focus")
Send("{DEL}")
Send("200000")

Local $oDOBAppOne = _IEGetObjByName($oIE, "bespMainAppDateOfBirth")
;_IEFormElementSetValue($oDOBAppOne, "DD/MM/YYYY")
_IEAction($oDOBAppOne, "focus")
Send("01011990")

Local $oDOBAppOne = _IEGetObjByName($oIE, "bespJointAppDateOfBirth")
;_IEFormElementSetValue($oDOBAppOne, "DD/MM/YYYY")
_IEAction($oDOBAppOne, "focus")
Send("01011990")

Local $oClassReturn = $oIE.document.getElementsByClassName("pageContainer page1")
If Not IsObj($oClassReturn) Then Exit ConsoleWrite("Error in $oClassReturn" & @CRLF)

Local $oTagReturn = $oClassReturn.Item(0).getElementsByTagName("li")
If Not IsObj($oTagReturn) Then Exit ConsoleWrite("Error in $oTagReturn" & @CRLF)

For $loop = 1 to 2
$oTagReturn.Item(1).click() ; Item(1) = Male / Item(2) = Female | Applicant one
Next

For $loop = 1 to 2
$oTagReturn.Item(5).click() ; Item(4) = Male / Item(5) = Female | Applicant two
Next

Local $oTagReturn = $oClassReturn.Item(0).getElementsByTagName("input")
If Not IsObj($oTagReturn) Then Exit ConsoleWrite("Error in $oTagReturn" & @CRLF)
$oTagReturn.Item(2).click() ; Item(2) = Has dependents / Item(3) = No dependents | Applicant one
$oTagReturn.Item(4).click() ; Item(4) = Has dependents / Item(5) = No dependents | Applicant one

Local $oDependentsZeroToFiveAppOne = _IEGetObjByName($oIE, "bespMainAppMmrMDependantsAgeRange1")
;_IEFormElementSetValue($oDependentsZeroToFiveAppOne, "0-9")
_IEAction($oDependentsZeroToFiveAppOne, "focus")
Send("{DEL}")
Send("1")

Local $oDependentsSixToElevenAppOne = _IEGetObjByName($oIE, "bespMainAppMmrMDependantsAgeRange2")
;_IEFormElementSetValue($oDependentsSixToElevenAppOne, "0-9")
_IEAction($oDependentsSixToElevenAppOne, "focus")
Send("{DEL}")
Send("2")

Local $oDependentsTwelveToSeventeenAppOne = _IEGetObjByName($oIE, "bespMainAppMmrMDependantsAgeRange3")
;_IEFormElementSetValue($oDependentsTwelveToSeventeenAppOne, "0-1")
_IEAction($oDependentsTwelveToSeventeenAppOne, "focus")
Send("{DEL}")
Send("3")

Local $oDependentsEighteenPlusAppOne = _IEGetObjByName($oIE, "bespMainAppMmrMDependantsAgeRange4")
;_IEFormElementSetValue($oDependentsEighteenPlusAppOne, "0-1")
_IEAction($oDependentsEighteenPlusAppOne, "focus")
Send("{DEL}")
Send("4")

Local $oDependentsZeroToFiveAppTwo = _IEGetObjByName($oIE, "bespJointAppMmrJDependantsAgeRange1")
;_IEFormElementSetValue($oDependentsZeroToFiveAppTwo, "0-9")
_IEAction($oDependentsZeroToFiveAppTwo, "focus")
Send("{DEL}")
Send("1")

Local $oDependentsSixToElevenAppTwo = _IEGetObjByName($oIE, "bespJointAppMmrJDependantsAgeRange2")
;_IEFormElementSetValue($oDependentsSixToElevenAppTwo, "0-9")
_IEAction($oDependentsSixToElevenAppTwo, "focus")
Send("{DEL}")
Send("2")

Local $oDependentsTwelveToSeventeenAppTwo = _IEGetObjByName($oIE, "bespJointAppMmrJDependantsAgeRange3")
;_IEFormElementSetValue($oDependentsTwelveToSeventeenAppTwo, "0-1")
_IEAction($oDependentsTwelveToSeventeenAppTwo, "focus")
Send("{DEL}")
Send("3")

Local $oDependentsEighteenPlusAppTwo = _IEGetObjByName($oIE, "bespJointAppMmrJDependantsAgeRange4")
;_IEFormElementSetValue($oDependentsEighteenPlusAppTwo, "0-1")
_IEAction($oDependentsEighteenPlusAppTwo, "focus")
Send("{DEL}")
Send("4")

$oTagReturn.Item(15).click() ; Item(14) = Is retired / Item(15) = Not retired | Applicant one
$oTagReturn.Item(17).click() ; Item(16) = Is retired / Item(17) = Not retired | Applicant one

Local $oRetAgeAppOne = _IEGetObjByName($oIE, "bespMainAppMExpectedRetirementAge")
;_IEFormElementSetValue($oRetAgeAppOne, "YY")
_IEAction($oRetAgeAppOne, "focus")
Send("65")

Local $oRetAgeAppTwo = _IEGetObjByName($oIE, "bespJointAppJExpectedRetirementAge")
;_IEFormElementSetValue($oRetAgeAppTwo, "YY")
_IEAction($oRetAgeAppTwo, "focus")
Send("65")

Local $oTagReturn = $oIE.document.getElementsByTagName("button")
If Not IsObj($oTagReturn) Then Exit ConsoleWrite("Error in $oTagReturn" & @CRLF)
$oTagReturn.Item(1).Click()

Local $oClassReturn = $oIE.document.getElementsByClassName("pageContainer page3")
If Not IsObj($oClassReturn) Then Exit ConsoleWrite("Error in $oClassReturn" & @CRLF)

Local $oTagReturn = $oClassReturn.Item(0).getElementsByTagName("li")
If Not IsObj($oTagReturn) Then Exit ConsoleWrite("Error in $oTagReturn" & @CRLF)

For $loop = 1 to 2
$oTagReturn.Item(1).click() ; Item(1) = Employed / Item(2) = Self-employed (partner) / Item(3) = Self-employed (partner) / Item(4) = Director <=20% / Item(5) = Director =>20% / Item(6) = Retired / Item(7) = Homemaker / Item(8) = Student / Item(9) = Unemployed | Applicant one
Next

For $loop = 1 to 2
$oTagReturn.Item(11).click() ; Item(11) = Employed / Item(12) = Self-employed (partner) / Item(13) = Self-employed (partner) / Item(14) = Director <=20% / Item(15) = Director =>20% / Item(16) = Retired / Item(17) = Homemaker / Item(18) = Student / Item(19) = Unemployed | Applicant two
Next

For $loop = 1 to 2
$oTagReturn.Item(21).click() ; Item(21) = Permanent / Item(22) = Fixed term contract / Item(23) Sub-contractor fixed term / Item(24) Sub-contractor open ended / Item(25) Temporary | Applicant one
Next

For $loop = 1 to 2
$oTagReturn.Item(27).click() ; Item(27) = Permanent / Item(28) = Fixed term contract / Item(29) Sub-contractor fixed term / Item(30) Sub-contractor open ended / Item(31) Temporary | Applicant two
Next

Local $oTimeInJobAppOneYY = _IEGetObjByName($oIE, "bespMainAppMTimeWithCurrentEmployerYY")
;_IEFormElementSetValue($oTimeInJobAppOneYY, "YY")
_IEAction($oTimeInJobAppOneYY, "focus")
Send("10")

Local $oTimeInJobAppOneMM = _IEGetObjByName($oIE, "bespMainAppMTimeWithCurrentEmployerMM")
;_IEFormElementSetValue($oTimeInJobAppOneMM, "MM")
_IEAction($oTimeInJobAppOneMM, "focus")
Send("10")

Local $oTimeInJobAppTwoYY = _IEGetObjByName($oIE, "bespJointAppJTimeWithCurrentEmployerYY")
;_IEFormElementSetValue($oTimeInJobAppTwoYY, "YY")
_IEAction($oTimeInJobAppTwoYY, "focus")
Send("10")

Local $oTimeInJobAppTwoMM = _IEGetObjByName($oIE, "bespJointAppJTimeWithCurrentEmployerMM")
;_IEFormElementSetValue($oTimeInJobAppTwoMM, "MM")
_IEAction($oTimeInJobAppTwoMM, "focus")
Send("10")

Local $oAnnualSalaryAppOne = _IEGetObjByName($oIE, "bespMainAppMGrossAnnualIncome")
;_IEFormElementSetValue($oAnnualSalaryAppOne, "100000")
_IEAction($oAnnualSalaryAppOne, "focus")
Send("{DEL}")
Send("100000")

Local $oAnnualSalaryAppTwo = _IEGetObjByName($oIE, "bespJointAppJGrossAnnualIncome")
;_IEFormElementSetValue($oAnnualSalaryAppTwo, "100000")
_IEAction($oAnnualSalaryAppTwo, "focus")
Send("{DEL}")
Send("100000")

Local $oAnnualBonusAppOne = _IEGetObjByName($oIE, "bespMainAppMmrMainIncomeMBonus")
;_IEFormElementSetValue($oAnnualBonusAppOne, "100000")
_IEAction($oAnnualBonusAppOne, "focus")
Send("{DEL}")
Send("100000")

Local $oAnnualBonusAppTwo = _IEGetObjByName($oIE, "bespJointAppMmrMainIncomeJBonus")
;_IEFormElementSetValue($oAnnualBonusAppTwo, "100000")
_IEAction($oAnnualBonusAppTwo, "focus")
Send("{DEL}")
Send("100000")

Local $oAnnualOvertimeAppOne = _IEGetObjByName($oIE, "bespMainAppMmrMainIncomeMOvertime")
;_IEFormElementSetValue($oAnnualOvertimeAppOne, "100000")
_IEAction($oAnnualOvertimeAppOne, "focus")
Send("{DEL}")
Send("100000")

Local $oAnnualOvertimeAppTwo = _IEGetObjByName($oIE, "bespJointAppMmrMainIncomeJOvertime")
;_IEFormElementSetValue($oAnnualOvertimeAppTwo, "100000")
_IEAction($oAnnualOvertimeAppTwo, "focus")
Send("{DEL}")
Send("100000")

Local $oAnnualCommissionAppOne = _IEGetObjByName($oIE, "bespMainAppMmrMainIncomeMCommission")
;_IEFormElementSetValue($oAnnualCommissionAppOne, "100000")
_IEAction($oAnnualCommissionAppOne, "focus")
Send("{DEL}")
Send("100000")

Local $oAnnualCommissionAppTwo = _IEGetObjByName($oIE, "bespJointAppMmrMainIncomeJCommission")
;_IEFormElementSetValue($oAnnualCommissionAppTwo, "100000")
_IEAction($oAnnualCommissionAppTwo, "focus")
Send("{DEL}")
Send("100000")

Local $oTagReturn = $oClassReturn.Item(0).getElementsByTagName("input")
If Not IsObj($oTagReturn) Then Exit ConsoleWrite("Error in $oTagReturn" & @CRLF)
$oTagReturn.Item(32).click() ; Item(32) = Does applicant one have a second job 'Yes' / Item(33) = 'No' | Applicant one
$oTagReturn.Item(34).click() ; Item(34) = Does applicant one have a second job 'Yes' / Item(35) = 'No' | Applicant two

Local $oClassReturn = $oIE.document.getElementsByClassName("row")
If Not IsObj($oClassReturn) Then Exit ConsoleWrite("Error in $oClassReturn" & @CRLF)

Local $oTagReturn = $oClassReturn.Item(0).getElementsByTagName("li")
If Not IsObj($oTagReturn) Then Exit ConsoleWrite("Error in $oTagReturn" & @CRLF)
$oTagReturn.Item(2).click()

Exit

 

Edited by Melba23
Added code tags
Link to comment
Share on other sites

  • Moderators

Dent,

When you post code please use Code tags - see here how to do it.  Then you get a scrolling box and syntax colouring as you can see above now I have added the tags.

M23

 

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

You alway need to check and confirm that you are grabbing the right element, to do that you need to use msgbox/consolewrite and check the element properties. You should read MSDN documentation. Try this:

Local $oClassReturn = $oIE.document.getElementsByClassName("pageContainer page3")
If Not IsObj($oClassReturn) Then Exit ConsoleWrite("Error in $oClassReturn" & @CRLF)

MsgBox(0, "", $oClassReturn.length)

Local $oTagReturn = $oClassReturn.Item(1).getElementsByTagName("li")
If Not IsObj($oTagReturn) Then Exit ConsoleWrite("Error in $oTagReturn" & @CRLF)

MsgBox(0, "", $oTagReturn.length)

$oTagReturn.Item(1).click() ; Item(2) = "Employed"

:) As you can see its the same principle.

Link to comment
Share on other sites

Thanks again MichaelHB.

You'll see from my code I've commented out all of the _IEFormElementSetValue commands and am using Send which isn't ideal because it's slower and more prone to error if the focus is taken away from the window/element.

But when I tried _IEFormElementSetValue which does populate the relevant elements, once the Continue button is clicked the page returns an error as if the value is missing and Send is the only way I've been able to make it work.

Is this a problem you've ever encountered/know how to solve? ;)

Link to comment
Share on other sites

Hi Dent,

No doubt send is not the best aproach but in this particular form you will have to deal with that method or try to dissect all the java that deals with the data validation and try to build another function. As you probably saw the form is used with some java to validade some data and changes form depending on the options chosen.

So the problem is not with the IE UDF, is the way the form was coded.

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...