Jump to content

How to click div and repeated class without id?


Recommended Posts

I need to click on the text "Batch submission" but I can not!

<div class="batchmenu2" onclick="Go('/lot/')" style="background-color: rgb(255, 255, 255);">
    <span class="iconep">l</span>
    <div class="menu">
        <b>Batch submission</b>
        <br>
        Bulk messages via file
    </div>
</div>

How could I do it?
How can I click the specific OnClick?

 

Link to comment
Share on other sites

I've tried that way ...

Local $oSubmit = _IEGetObjByName($oIE, "Go('/lot/')")
_IEAction($oSubmit, "click")

thereby...
 

$tags = $oIE.document.GetElementsByTagName("div")
$i = 1
  For $tag in $tags
        $class_value = $tag.GetAttribute("class")
        If $class_value = "menu" Then
            $_innertext = $tags.innertext
            If $i = 3 Then
                _IEAction($class_value, "click")
            EndIf
        $i = $i + 1
        EndIf
  Next

I do not know what else to do!

Link to comment
Share on other sites

There are a few issues with the code you posted. First, it looks like you are checking for the inner div (the one with class 'menu') when you really need the outer one (the one with class "batchmenu2". Second, you've getting innertext from $tags, which is the collection of divs elements. $tag (the singular element) is what you want in this instance. Then you don't actually compare the innertext value with the known good value.

Link to comment
Share on other sites

If you know how to make an xpath to the html dom object you want...you can use my signature, and it will do all the loops for you.

Yours would look like this:

$sXpath = "//div/span[.='I']/div/b[.='Batch submission']"

1st param to the function is your ie object (can be at any level of the DOM, searches are done relative to what you provide), second is the xpath above, the return is an array of DOM objects that match the xpath.

So you would then: _ieclick($oIE,$aReturn[0]) ; after validating the return is an array

Edited by jdelaney
IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.
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

×
×
  • Create New...