Hi all,
I'm trying to expand the sub-option in the IE.
On this page:
http://www.tripadvisor.com/Hotels-g187791-Rome_Lazio-Hotels.html
there is a "span"-button called "More"
How can I expand Hotel class, Amenities, or Hotel brand?
I've tried this:
AutoIt
#include <IE.au3> Global $oIE _Main() Func _Main() ConsoleWrite('................................................................................' & @CRLF) _StartIE() ;Start Internet Explorer _LoadWebPage() ;Load webpage in the Internet Explorer _expandControl() ;expand the hotel class If IsObj($oIE) Then _IEQuit($oIE) ConsoleWrite('................................................................................' & @CRLF) EndFunc Func _StartIE() ConsoleWrite('> Info - Starting IE... please wait...' & @CRLF) $oIE = _IECreate() If @error Then ConsoleWrite('! Error - Starting IE failed... script will now be terminated...' & @CRLF) Exit EndIf ConsoleWrite('> Info - IE started successfully.' & @CRLF) EndFunc Func _LoadWebPage() Local $pageLoaded = False Do If NOT IsObj($oIE) Then ConsoleWrite('! Error - IE is no longer a valid object, script will now be terminated...' & @CRLF) MsgBox(BitOR(48, 262144), 'Error', 'IE is no longer a valid object.' & @CRLF & _ @CRLF & _ 'Script will be terminated...') Exit EndIf Local $the_url = 'http://www.tripadvisor.com/Hotels-g187791-Rome_Lazio-Hotels.html' ConsoleWrite('- Loading - Please wait, IE is navigating to: ' & $the_url & @CRLF) _IENavigate($oIE, $the_url) If @error Then ConsoleWrite('! Error - Page could not be loaded: ' & $the_url & @CRLF) If MsgBox(BitOR(3, 48, 262144), 'Error', 'Page: ' & @CRLF & _ $the_url & @CRLF & _ 'couldn''t be loaded.' & @CRLF & _ @CRLF & _ 'Would you like to try again?') = 7 Then Exit EndIf Else $pageLoaded = True EndIf Until $pageLoaded = True ConsoleWrite('+ Info - Page loaded successfully: ' & $the_url & @CRLF) EndFunc Func _expandControl() If NOT IsObj($oIE) Then ConsoleWrite('! Error - IE is no longer a valid object, script will now be terminated...' & @CRLF) MsgBox(BitOR(48, 262144), 'Error', 'IE is no longer a valid object.' & @CRLF & _ @CRLF & _ 'Script will be terminated...') Exit EndIf Local $allSpans = _IETagNameGetCollection($oIE, 'span') For $oneSpan in $allSpans If StringInStr($oneSpan.classname, 'hotel_filter more sprite-date_picker-triangle no_cpu') Then _IEAction($oneSpan, 'focus') _IEAction($oneSpan, 'click') Sleep(1000) ConsoleWrite('> Info - "MORE" span is opened' & @CRLF) MsgBox(BitOR(64, 262144), 'test', 'Just opened "MORE"') Local $allULs = _IETagNameGetCollection($oIE, 'ul') For $oneUL in $allULs If $oneUL.classname == 'expandFilterItems more' Then Local $allDivs = _IETagNameGetCollection($oneUL, 'div') For $oneDiv in $allDivs If $oneDiv.classname == 'nameItem sprite-filter-expand' Then ;Hotel class _IEAction($oneDiv, 'focus') _IEAction($oneDiv, 'click') ConsoleWrite('- Question - is "Hotel class" expanded??' & @CRLF) MsgBox(BitOR(64, 262144), 'test', 'Is "Hotel class" expanded?') ExitLoop 3 EndIf Next ExitLoop 2 EndIf Next ExitLoop EndIf Next EndFunc