Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Check Box (Website)
#1
Dear Friends,

How do I ascertain whether a website checkbox is checked or not?
Also, how do I change the current value, i.e. check it or uncheck it?

Thanks,
Philip
Best Regards,
Philip
#2
Macro Macro2132
Code:
Copy      Help
;test with:
;http://www.w3schools.com/html/tryit.asp?filename=tryhtml_form_checkbox
;in Internet Explorer

int w=wait(3 WV win("Tryit Editor v1.8 - Windows Internet Explorer" "IEFrame"))
Acc a.Find(w "CHECKBUTTON" "" "a:value=Bike" 0x3004 3)
if a.State&STATE_SYSTEM_CHECKED
,out "checked"
else
,out "unchecked"
a.DoDefaultAction ;;toggle
Macro Macro2123
Code:
Copy      Help
;test with:
;http://www.w3schools.com/html/tryit.asp?filename=tryhtml_form_checkbox
;in Firefox

int w=wait(3 WV win("Tryit Editor v1.8 - Mozilla Firefox" "Mozilla*WindowClass" "" 0x4))
Acc a.FindFF(w "INPUT" "" "value=Bike" 0x1004 3)
if a.State&STATE_SYSTEM_CHECKED
,out "checked"
else
,out "unchecked"
a.DoDefaultAction ;;toggle
Macro Macro2133
Code:
Copy      Help
;test with:
;http://www.w3schools.com/html/tryit.asp?filename=tryhtml_form_checkbox
;in Chrome

int w=wait(3 WV win("Tryit Editor v1.8 - Google Chrome" "Chrome_WidgetWin_1"))
Acc a.FindFF(w "input" "" "value=Bike" 0x1004 3)
if a.State&STATE_SYSTEM_CHECKED
,out "checked"
else
,out "unchecked"
a.DoDefaultAction ;;toggle
#3
Thanks Gintaras.

However, I am referring to the checkbox element directly.
Could you please check on the below code if I am doint it right...

Macro VISTA Order Amends
Code:
Copy      Help
;---- Recorded 29-Oct-13 6:06:04 PM ----
opt slowkeys 1; opt slowmouse 1; spe 100

int w1=act(win("Microsoft Excel - VISTA Amend" "XLMAIN"))

;Copy data from excel
'D ; 0.53    ;; Down Ctrl+C
;get selected cells in Excel
ExcelSheet es.Init
ARRAY(str) factoryOrderNum
es.CellsToArray(factoryOrderNum "sel")
'TT; 0.12
ARRAY(str) extColourTemp
es.CellsToArray(extColourTemp "sel")
str extColour = extColourTemp
'T; 0.12
ARRAY(str) trimColourTmp
es.CellsToArray(trimColourTmp "sel")
str trimColour=trimColourTmp
'T; 0.12
ARRAY(str) veneerTmp
es.CellsToArray(veneerTmp "sel")
str veneer=veneerTmp
'TT; 0.12
ARRAY(str) wheelTmp
es.CellsToArray(wheelTmp "sel")
str wheel=wheelTmp
'T; 0.12
ARRAY(str) roofTmp
es.CellsToArray(roofTmp "sel")
str roof=roofTmp
'T; 0.12
ARRAY(str) sideVentsTmp
es.CellsToArray(sideVentsTmp "sel")
str sideVents=sideVentsTmp
'T; 0.12
ARRAY(str) towBarTmp
es.CellsToArray(towBarTmp "sel")
str towBar=towBarTmp
'T; 0.12
ARRAY(str) rearEntTmp
es.CellsToArray(rearEntTmp "sel")
str rearEnt=rearEntTmp
'T; 0.12
ARRAY(str) seatTmp
es.CellsToArray(seatTmp "sel")
str seat=seatTmp
'T; 0.12
ARRAY(str) rearCoolerTmp
es.CellsToArray(rearCoolerTmp "sel")
str rearCooler=rearCoolerTmp
'T; 0.12
ARRAY(str) cruiseControlTmp
es.CellsToArray(cruiseControlTmp "sel")
str cruiseControl=cruiseControlTmp
'T; 0.12
ARRAY(str) steeringTmp
es.CellsToArray(steeringTmp "sel")
str steering=steeringTmp
'T; 0.12
ARRAY(str) soundSystemTmp
es.CellsToArray(soundSystemTmp "sel")
str soundSystem=soundSystemTmp
'TT; 0.12
ARRAY(str) cameraTmp
es.CellsToArray(cameraTmp "sel")
str camera=cameraTmp
'T; 0.12
ARRAY(str) darkAtlasTmp
es.CellsToArray(darkAtlasTmp "sel")
str darkAtlas=darkAtlasTmp
'T; 0.12
ARRAY(str) touchScreenTmp
es.CellsToArray(touchScreenTmp "sel")
str touchScreen=touchScreenTmp
'T; 0.12
ARRAY(str) parkAssistTmp
es.CellsToArray(parkAssistTmp "sel")
str parkAssist=parkAssistTmp


;Insert factory order number in website field
int w=wait(3 WV win("Find Orders - Windows Internet Explorer" "IEFrame"))
Htm e=htm("INPUT" "fromValue" "" w "0" 28 0x121 3)
e.SetText(factoryOrderNum)
;Click Search Button
Htm e1=htm("NOBR" "Search" "" w "0" 20 0x21 3)
e1.Click
;Click Maintain Orders button
int w2=wait(10 WV win("View Order - Windows Internet Explorer" "IEFrame"))
Htm e2=htm("NOBR" "Maintain Order " "" w2 "0" 7 0x21 3)
e2.Click
;Click Configurator button
int w3=wait(3 WV win("Maintain Order - Windows Internet Explorer" "IEFrame"))
Htm e3=htm("NOBR" "Configurator " "" w3 "0" 2 0x21 3)
e3.Click

;;;;;checking variable content and changing website values accordingly

int w4=wait(3 WV win("Vehicle Configuration - Windows Internet Explorer" "IEFrame"))
;changing exterior colour
Htm e4=htm("SELECT" "sel3" "" w4 "0" 8 0x121 3)

if extColour = "Santorini Black"
,e4.CbSelect("820 Santorini Black")
else if extColour = "Nara Bronze"
,e4.CbSelect("825 Nara Bronze")
else if extColour = "Aleutian Silver"
,e4.CbSelect("835 Aleutian Silver")
else if extColour = "Mariana Black"
,e4.CbSelect("860 Mariana Black")
else if extColour = "Barolo Black"
,e4.CbSelect("861 Barolo Black")
else if extColour = "Indus Silver"
,e4.CbSelect("863 Indus Silver")
else if extColour = "Havana"
,e4.CbSelect("865 Havana")
else if extColour = "Aintree Green"
,e4.CbSelect("866 Aintree Green")
else if extColour = "Fuji White"
,e4.CbSelect("867 Fuji White")
else if extColour = "Firenze Red"
,e4.CbSelect("868 Firenze Red")
else if extColour = "Luxor"
,e4.CbSelect("869 Luxor")
else if extColour = "Barossa"
,e4.CbSelect("871 Barossa")
else if extColour = "Corris Grey"
,e4.CbSelect("873 Corris Grey")
else if extColour = "Loire Blue"
,e4.CbSelect("942 Loire Blue")
else if extColour = "Scotia Grey"
,e4.CbSelect("943 Scotia Grey")
else if extColour = "Causeway Grey"
,e4.CbSelect("950 Causeway Grey")

;changing trim
Htm e5=htm("SELECT" "sel4" "" w4 "0" 9 0x121 3)

if trimColour = "Ebony Seats Ebony/Ebony Cirrus"
,e5.CbSelect("TKA Ebony Seats Ebony/Ebony Cirrus")
else if trimColour = "Ebony Seats Ebony/Ebony Ebony"
,e5.CbSelect("TKB Ebony Seats Ebony/Ebony Ebony")
else if trimColour = "Almond Seats Espresso/Almond Ivory"
,e5.CbSelect("TKC Almond Seats Espresso/Almond Ivory")
else if trimColour = "Cirrus Seats Ebony/Cirrus Cirrus"
,e5.CbSelect("TKE Cirrus Seats Ebony/Cirrus Cirrus")
else if trimColour = "Cirrus Seats Ebony/Cirrus Ebony"
,e5.CbSelect("TKF Cirrus Seats Ebony/Cirrus Ebony")

;changing veneer
Htm e6=htm("IMG" "images/,DanaInfo=www.jlrvista.franchise.jlrint.com+checkbox_red.gif" "" w4 "0" 68 0x921 3)

if veneer="Ebony Macassar"
,if e6.Checked
,,e6.Click
else if veneer="Grand Black Wood"
,if !e6.Checked
,,e6.Click


;changing alloy wheels

Htm e7=htm("IMG" "images/,DanaInfo=www.jlrvista.franchise.jlrint.com+config-selected.gif" "" w4 "0" 24 0x921 3) ;;20" Style 2
Htm e8=htm("IMG" "images/,DanaInfo=www.jlrvista.franchise.jlrint.com+checkbox_red.gif" "" w4 "0" 25 0x921 3)    ;;20" Style 3
Htm e9=htm("IMG" "images/,DanaInfo=www.jlrvista.franchise.jlrint.com+checkbox_red.gif" "" w4 "0" 26 0x921 3)    ;;21" Style 4
Htm e10=htm("IMG" "images/,DanaInfo=www.jlrvista.franchise.jlrint.com+checkbox_red.gif" "" w4 "0" 27 0x921 3)    ;;21" Style 5
Htm e11=htm("IMG" "images/,DanaInfo=www.jlrvista.franchise.jlrint.com+checkbox_red.gif" "" w4 "0" 28 0x921 3)    ;;22" Style 6

if wheel="20 Style 2"
,if !e7.Checked
,,e7.Click
else if wheel="Grand Black Wood"
,if !e6.Checked
,,e6.Click
else if wheel="Grand Black Wood"
,if !e6.Checked
,,e6.Click
else if wheel="Grand Black Wood"
,if !e6.Checked
,,e6.Click


opt slowkeys 0; opt slowmouse 0; spe -1
;---------------------------------------
Best Regards,
Philip
#4
It works wit the test website.
Macro Macro2134
Code:
Copy      Help
int w=wait(3 WV win("Tryit Editor v1.8 - Windows Internet Explorer" "IEFrame"))
Htm e=htm("INPUT" "Bike" "" w "2" 0 0x421 3)
if e.Checked
,out "checked"
else
,out "unchecked"
e.Click ;;toggle
But it must be "INPUT", not "IMG". Look for "INPUT" somewhere near the IMG.
#5
I am gettin an error message as below:
Error (RT) in VISTA Order Amends: 0x80004002, No such interface supported.

The cursor stops at the below shown code at the intended if line:
Also please see attachment.
I am unable to get an 'input'

Macro VISTA Order Amends
Code:
Copy      Help
;changing veneer
Htm e6=htm("IMG" "images/,DanaInfo=www.jlrvista.franchise.jlrint.com+checkbox_red.gif" "" w4 "0" 68 0x921 3)

if veneer="Ebony Macassar"
,if e6.Checked
,,e6.Click
else if veneer="Grand Black Wood"
,if !e6.Checked
,,e6.Click


Attached Files Image(s)
   
Best Regards,
Philip
#6
IMG is not checkbox. Checkbox elements have tag INPUT.
#7
I just noticed that the whole checkbox item is clickable including the description against the check box.
When I drag the control on to the description, it gives me the SPAN tag.

How do I go about this?

I mean how do I know if the this element is checked or not.

The only visual way is that the box is checked or not and the description turns red if unchecked...black if checked
check box is an image and it's name changes each time

Notice how the index number changes before and after the item is clicked:

Macro VISTA Order Amends
Code:
Copy      Help
;before checked
Htm e24=htm("SPAN" "  088EH Grand Black Wood (12) " "" w4 "0" 57 0x21 3)
;after checked
Htm e6=htm("SPAN" "  088EH Grand Black Wood (12) " "" w8 "0" 56 0x21 3)
Best Regards,
Philip
#8
Don't use the index, it will be unreliable.
Look maybe something in HTML of the element (IMG, SPAN, maybe some other) is different when checked and unchecked. Then can get HTML and use string functions.
If not, try "Find Image" dialog.
Also can try accessible object functions.
#9
I tried the accessible object method.

However, when running the code, it does not seem to find the object:
Could you please check on this website and suggest me the best method.
I really need your help on this.
I am bound by over 500 orders....

Macro VISTA Order Amends
Code:
Copy      Help
int w8=wait(3 WV win("Vehicle Configuration - Windows Internet Explorer" "IEFrame"))
Acc a.Find(w8 "TEXT" "  088EH Grand Black Wood (12) " "state=0x40 0x20000040" 0x3005 3)
Best Regards,
Philip
#10
At first see if it has "checked" state when checked. In "Find Accessible Object" dialog click Properties. If not, accessible object functions cannot be used. If yes, you can find HTML element and convert to accessible object.
#11
I did not follow that...
I have just sent you a PM with the company website details.
Could you please check on this...
Best Regards,
Philip
#12
I tried. The accessible object is not found...
I get stuck in the begining itself so can't go further to test the checkboxes
I tried the test button when the item is visible; it finds the object. But when I scroll to the begining of the page, 'test' does not find the accessible object.
How can I work around this limitation?
Below is the exact code that I am using.
I am using the object name as is from what I got while using the drag method
I even tried using * as well but no luck...

Macro VISTA Order Amends
Code:
Copy      Help
;changing veneer
int w8=wait(3 WV win("Vehicle Configuration - Windows Internet Explorer" "IEFrame"))
Acc a1.Find(w8 "TEXT" "  088EH Grand Black Wood (12) " "state=0x40 0x20000040" 0x3005 3 0 "parent previous first2")
Acc a2.Find(w8 "TEXT" "  088HF Shadow Walnut Veneer " "state=0x40 0x20000040" 0x3005 3 0 "parent previous first2")
Acc a3.Find(w8 "TEXT" "  088HY Grey Oak " "state=0x40 0x20000040" 0x3005 3 0 "parent previous first2")



str varTemp1 varTemp2 varTemp3
varTemp1=a1.WebAttribute("src")
varTemp2=a2.WebAttribute("src")
varTemp3=a3.WebAttribute("src")


if veneer="Ebony Macassar"
,if varTemp1="*+config-available.gif"
,,a1.DoDefaultAction
,if varTemp2="*+config-available.gif"
,,a2.DoDefaultAction
,if varTemp3="*+config-available.gif"
,,a3.DoDefaultAction
else if veneer="Grand Black Wood"
,if !varTemp1="*+config-available.gif"
,,a1.DoDefaultAction
else if veneer="Shadow Walnut"
,if !varTemp2="*+config-available.gif"
,,a2.DoDefaultAction
else if veneer="Grey Oak"
,if !varTemp3="*+config-available.gif"
,,a3.DoDefaultAction
Best Regards,
Philip
#13
Try to check "+invisible".

Also replace
varTemp="*+config-available.gif"
to
matchw(varTemp "*+config-available.gif")
#14
Yes, I will check on the matchw tommorow at office and will let you know.
But where do I use +invisible in my code and what does it do?

Thanks
Philip
Best Regards,
Philip
#15
It is in the Find Accessible Object dialog. It is flag 16. Replace 0x3005 to 0x3015.

Or find HTML element, convert to accessible object, then Navigate to the checkbox.
#16
Hi Gintaras,

I have been successfully using the codes mentioned in this post for a very long time now.
However, some text and elements changed in this website recently and I don't seem to get things working.
The ones in green (accessible objects) was working perfectly previously but it does not now.
Instead, I have used htm objects now and it finds the checkbox image perfectly.
So, how do I substitute the .webattribute part?

Macro VISTA Order Amends - L405
Code:
Copy      Help
,if veneer="Grand Black Wood"
,,;Acc a1.Find(w4 "TEXT" "*088EH*" "state=0x40 0x20000040" 0x3015 5 0 "parent previous first2")
,,Htm e10=htm("TABLE" "*088EH*" "" w4 "0" 34 0x21 5 3)
,,
,,wait 1
,,;varTemp1=a1.WebAttribute("src")
,,varTemp1=e10.Attribute("src")  ;;**************THIS GIVES MISMATCH************
,,if matchw(varTemp1 "*+config-selected.gif")=0
,,,;a1.DoDefaultAction
,,,e10.Click
,,,;mes F"Venner {veneer} is chosen" ""
,,,wait 4
,,,goto changingAlloyWheels
,,else if matchw(varTemp1 "*+config-selected.gif")=1
,,,;mes F"Venner {veneer} already chosen" ""
,,,;wait 2
,,,goto changingAlloyWheels
Best Regards,
Philip
#17
works here

Macro Macro2537
Code:
Copy      Help
int w=wait(3 WV win("msn - Internet Explorer" "IEFrame"))
Htm e=htm("IMG" "Carnufex carolinensis, or the ''Carolina butcher.''" "" w "0" 58 0x321 3)
str s=e.Attribute("src")
out s

Error "Type mismatch" when the element cannot have src attribute.


Forum Jump:


Users browsing this thread: 1 Guest(s)