Jump to content

Problem with click on DIV element


Recommended Posts

Hello!

I faced with such problem - in HTML code exist two sets of DIV tags with similar attributes title.

I need click on div "Cayman Islands - George Town" in the second div sets. With my code it's always click on title in first set of divs.

 

HTML code (I need to click on div marked on yellow):

div.png

My code:

$objs = _IETagNameGetCollection($oIE, "div")
                            For $obj In $objs
                                If String($obj.title) = "Cayman Islands - George Town" Then
                                        _IEAction($obj, "click")
                                        _IELoadWait($oIE, 2000)
                                    ExitLoop
                                EndIf
                            Next

Tried this too:

$objs = _IETagNameGetCollection($oIE, "div")
                            For $obj In $objs
                                If $obj.classname == 'raceway canada' Then
                                        _IEAction($obj, "click")
                                        _IELoadWait($oIE, 1000)
                                    ExitLoop
                                EndIf
                            Next

Also tried code below but it's always click on div titled "Mexico - Ciudad Juarez":

$objs = _IETagNameGetCollection($oIE, "div")
                            $b = 0
                            For $obj In $objs
                                If String($obj.title) = "Cayman Islands - George Town" Then
                                    $b = $b+1
                                    If ($b==2) then
                                        _IEAction($obj, "click")
                                        _IELoadWait($oIE, 2000)
                                    EndIf
                                    ExitLoop
                                EndIf
                            Next

 

I can't find any correct solution.

Link to post
Share on other sites

Try this :

$oIE = _IECreate(......)
$oDiv2 = _IEGetObjById($oIE, "tab4-2")
If Not IsObj($oDiv2) Then Exit MsgBox($MB_SYSTEMMODAL, "", "not an object")
$objs = _IETagNameGetCollection($oDiv2, "div")
For $obj In $objs
  If $obj.title = "Cayman Islands - George Town" Then
    _IEAction($obj, "click")
    _IELoadWait($oIE, 2000)
    ExitLoop
  EndIf
Next

 

Edited by Nine
no need for string function
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
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...