boy233 Posted July 6, 2017 Posted July 6, 2017 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?
Danp2 Posted July 6, 2017 Posted July 6, 2017 Show us your code so we can see what you have tried thus far. Latest Webdriver UDF Release Webdriver Wiki FAQs
boy233 Posted July 6, 2017 Author Posted July 6, 2017 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!
Danp2 Posted July 6, 2017 Posted July 6, 2017 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. Latest Webdriver UDF Release Webdriver Wiki FAQs
boy233 Posted July 6, 2017 Author Posted July 6, 2017 What is the best way to solve it? Could you show me? Thank you
Danp2 Posted July 6, 2017 Posted July 6, 2017 Can't tell you for sure with the limited information provided this far. Can you either provide the site's URL so that we can view the underlying code or post the full HTML here? Latest Webdriver UDF Release Webdriver Wiki FAQs
boy233 Posted July 6, 2017 Author Posted July 6, 2017 I arrived in this code ... Local $oElements = _IETagNameGetCollection($oIE, "span") For $oElement In $oElements If $oElement.innerText == "I" Then $oClick = $oElement.id _IEAction($oClick, "click") EndIf Next I can not click, what can I do?
Danp2 Posted July 6, 2017 Posted July 6, 2017 If $oElement.innerText == "I" Then Don't you want to click the div, not the span? $oClick = $oElement.id _IEAction($oClick, "click") It doesn't work like that (you can't click on an element's ID property). Latest Webdriver UDF Release Webdriver Wiki FAQs
jdelaney Posted July 7, 2017 Posted July 7, 2017 (edited) 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 July 7, 2017 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.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now