faustf Posted May 9, 2020 Share Posted May 9, 2020 (edited) hi guys i have in a page web this dropdown menu this is a code <a href="javascript:;" role="button" aria-expanded="true" aria-haspopup="true" data-toggle="dropdown" aria-owns="m2749.OptionMenu" aria-controls="m2749.OptionMenu" class="defer-store btn btn-s btn-ter ssixtyDays"><span class="gh-ar-hdn">Vedi gli ordini da</span><span class="filter-content"> Ultimi 60 giorni</span><span class="arrow-down"></span></a> i try to click over with Local $oBtns = $oIE.document.GetElementsByTagName("a") For $oBtn In $oBtns $id = String($oBtn.classname()) ConsoleWrite($id & @CRLF) If $id = "defer-store btn btn-s btn-ter ssixtyDays" Then _IEAction($oBtn, "click") ;_IEFormElementSetValue($oBtn, $sUser) EndIf Next but in console write not find class defer-store btn btn-s btn-ter ssixtyDays, why ? is possible click over > Ultimi 60 giorni</span> like call a text Edited May 9, 2020 by faustf Link to comment Share on other sites More sharing options...
Danp2 Posted May 9, 2020 Share Posted May 9, 2020 My crystal ball is telling me that you are trying to automate the My Ebay page. Is this correct? 🔮🧞♂️ If so, you could try something like this -- $oIE.document.parentwindow.execScript('jQuery("div.dropdown.period-menu>a").click()') Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
faustf Posted May 9, 2020 Author Share Posted May 9, 2020 your crystal ball work perfect , but the code where i insert i just did do $oIE.document.parentwindow.execScript('jQuery("div.dropdown.period-menu>a").click()') Local $oBtns = $oIE.document.GetElementsByTagName("a") For $oBtn In $oBtns $id = String($oBtn.classname()) ;ConsoleWrite($id & @CRLF) If $id = "filter-content" Then _IEAction($oBtn, "click") ;_IEFormElementSetValue($oBtn, $sUser) EndIf Next but not work Link to comment Share on other sites More sharing options...
Danp2 Posted May 9, 2020 Share Posted May 9, 2020 The code I posted was meant to open the dropdown menu, essentially replacing your section of code with this one line. "Doesn't work" is an insufficient description of the outcome, so you will need to provide a more detailed response if you want further assistance. Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
faustf Posted May 9, 2020 Author Share Posted May 9, 2020 sorry the code work open but not remaning open , but first i want understund your code this part of your code div.dropdown.period-menu>a identifies a correct menu , but where do you find that ? in inspect elements i dont saw or exist ? (and simply i dont saw ) Link to comment Share on other sites More sharing options...
Danp2 Posted May 9, 2020 Share Posted May 9, 2020 It's a jQuery selector used to locate a specific element. If you break it down, it does the following -- Find any div elements with class "dropdown" and class "period-menu" Then locate the first child link For more info, Google the phrase "jQuery selector" 😃 Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
faustf Posted May 9, 2020 Author Share Posted May 9, 2020 thankz again @Danp2 i look in google , and of course i ask you something Link to comment Share on other sites More sharing options...
faustf Posted May 9, 2020 Author Share Posted May 9, 2020 i ask some many questions sorry i saw in page ropdown.period-menu and a string with javascript start with <a but why you use > this char and not < ? second questions if i want click over some menu opened after , i dont understund how is possible to do that , sorry Link to comment Share on other sites More sharing options...
Danp2 Posted May 9, 2020 Share Posted May 9, 2020 As I previously stated, it's a jQuery selector. The ">a" part performs the 2nd step I outlined above. If you wanted child input elements instead of links, then you would change it to ">input". See here for a quick "cheat" sheet. Obviously lots of other good info out there if you search for it. 😉 Here's the complete code to open the dropdown and click one of the available options -- $oIE.document.parentwindow.execScript('jQuery("div.dropdown.period-menu>a").click()') $oIE.document.parentwindow.execScript('jQuery("div.dropdown.period-menu>ul>li>a:contains('2019')").click()') I'm sure this could be done without jQuery, but I'll not be a participant in that journey. 😜 faustf 1 Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
faustf Posted May 9, 2020 Author Share Posted May 9, 2020 you are super Link to comment Share on other sites More sharing options...
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