Bot-Factory 602 Posted June 7, 2014 Report Share Posted June 7, 2014 Hello. I need to click a button on a website. There are multiple buttons of the same type. They have the exact same image and everything. The offset of the button I want to click changes all the time. It's structured as a table. And the only constant is that it's right after "results per page". So the table element where my button is located looks like: <tr class="list-row"> <td colspan="9" align="left" valign="center"> <form style="border: 0px; margin: 0px" class="myo_list_orders_search_form" onsubmit="return MYO.LO.DoAjaxSearchCall( this );"> <table align="left" cellpadding="3" cellspacing="0"><tbody><tr> <td class="tiny" align="center">Show</td> <td class="tiny" align="center"> <select name="itemsPerPage"> <option value="15" selected="">15</option> <option value="25">25</option> <option value="50">50</option> <option value="100">100</option> </select> <input name="statusFilter" type="hidden" value="Default"> <input name="showCancelled" type="hidden" value="0"> <input name="sortBy" type="hidden" value="OrderStatusDescending"> <input name="searchFulfillers" type="hidden" value="all"> <input name="searchDateOption" type="hidden" value="exactDates"> <input name="searchType" type="hidden" value="DateRange"> <input name="shipExactDateEnd" type="hidden" value="6/14/14"> <input name="searchKeyword" type="hidden" value=""> <input name="paymentFilter" type="hidden" value="Default"> <input name="orderType" type="hidden" value="All"> <input name="searchLanguage" type="hidden" value="en_US"> <input name="byDate" type="hidden" value="orderDate"> <input name="preSelectedRange" type="hidden" value="exactDates"> <input name="shipmentFilter" type="hidden" value="Default"> <input name="showPending" type="hidden" value="0"> <input name="shipSelectedRange" type="hidden" value="7"> <input name="isDebug" type="hidden" value=""> <input name="shipSearchDateOption" type="hidden" value="shipPreSelected"> <input name="shipExactDateBegin" type="hidden" value="4/22/14"> <input name="isSearch" type="hidden" value="1"> <input name="exactDateEnd" type="hidden" value="6/5/14"> <input name="exactDateBegin" type="hidden" value="6/5/14"> <input type="hidden" name="currentPage" value="1"> </td> <td class="tiny" align="center">results per page</td> <td class="tiny" align="center"><input type="image" src="https://images-na.ssl-images-amazon.com/images/G/01/abis-ui/buttons/go._V187564664_.gif" width="21" align="absmiddle" height="21" border="0"></td> </tr></tbody></table> </form> </td> </tr> The red part is my button. Scraping of that url is not a problem. I could also find the correct html tag via Regex or Xpath. But I don't know how to do it via click and the browser.I played around with child , parent and sibling a little bit. But I haven't used that a lot to know how to do it. Would be great if someone could tell me how to identify the button object that is right after "results per page". But without using offset. Thanks in advance for your help. Dan Quote Link to post Share on other sites
UBotBuddy 331 Posted June 7, 2014 Report Share Posted June 7, 2014 Dan, If you send me the site I will get the code for you that you need from a "$element offset" perspective. FYI to everyone else reading this I am putting the final videos together for an updated section on my site for Parent Child Sibling training along with coding examples. SO that will be next week for sure. Buddy Quote Link to post Share on other sites
Bot-Factory 602 Posted June 7, 2014 Author Report Share Posted June 7, 2014 Dan, If you send me the site I will get the code for you that you need from a "$element offset" perspective. FYI to everyone else reading this I am putting the final videos together for an updated section on my site for Parent Child Sibling training along with coding examples. SO that will be next week for sure. BuddySo you would recommend to work with element offset?Parent / Child is not useful here? I watched the training videos on your site, but still don't understand it 100% :-(Dan Quote Link to post Share on other sites
UBotBuddy 331 Posted June 7, 2014 Report Share Posted June 7, 2014 To be honest, element offset makes sense BUT the others my work too. I just need to see the site and I will tell you for sure. Just so you know the videos you watched are the old ones. You have not seen my new ones yet. I will be adding about 25 new ones next week. Buddy Quote Link to post Share on other sites
Marton 48 Posted June 7, 2014 Report Share Posted June 7, 2014 Hi Dan, try this: click($element from text("<{$find regular expression($document text, "(?<=results per page</td>\\s*<td class=\"tiny\"\\salign=\"center\"><input\\s)type=\\\"image\\\"")}>"), "Left Click", "No") Marton Quote Link to post Share on other sites
Bot-Factory 602 Posted June 7, 2014 Author Report Share Posted June 7, 2014 Hi Dan, try this: click($element from text("<{$find regular expression($document text, "(?<=results per page</td>\\s*<td class=\"tiny\"\\salign=\"center\"><input\\s)type=\\\"image\\\"")}>"), "Left Click", "No") MartonThanks Marton, but that's not working. The regex result is type="image"And that is then used as input for the "Element to click" field. The problem is, that there are multiple of those buttons on the page. I think I have to work with offset somehow. Dan Quote Link to post Share on other sites
Marton 48 Posted June 7, 2014 Report Share Posted June 7, 2014 Would be great if someone could tell me how to identify the button object that is right after "results per page". I think my code does exactly that. No matter where it's situated on the page, even if there are multiple buttons like that. Isn't that what you needed? EDIT: attached code I was playing with, no offset used as requested.test.ubot Quote Link to post Share on other sites
Bot-Factory 602 Posted June 7, 2014 Author Report Share Posted June 7, 2014 I think my code does exactly that. No matter where it's situated on the page, even if there are multiple buttons like that. Isn't that what you needed? EDIT: attached code I was playing with, no offset used as requested.The problem is probably that I need to click only one of the buttons. The one right below the "results per page" text. I found a solution that is working for me: clear list(%zzz)change dropdown(<name="itemsPerPage">, 100)add list to list(%zzz, $scrape attribute($element parent($element parent(<src=w"*buttons/go*">)), "outerhtml"), "Delete", "Global")loop($list total(%zzz)) { if($contains($next list item(%zzz), "results per page")) { then { click($element offset(<src=w"*buttons/go*">, $add($list position(%zzz), 1)), "Left Click", "No") } }} 1 Quote Link to post Share on other sites
Marton 48 Posted June 7, 2014 Report Share Posted June 7, 2014 The problem is probably that I need to click only one of the buttons. The one right below the "results per page" text. Doesn't my code do that? That's why I included the "results per page" in my regex. Obviously you could optimize the regex, but the one I posted should only click the one right after "results per page". Quote Link to post Share on other sites
Bot-Factory 602 Posted June 7, 2014 Author Report Share Posted June 7, 2014 Doesn't my code do that? That's why I included the "results per page" in my regex. Obviously you could optimize the regex, but the one I posted should only click the one right after "results per page". Doesn't it?No. The regex extracts type="image"And that is used as input for click element. But how should the click command know which of the 6 type="image" elements on the page it should click? The regex "only" extracts a text part of the element. But it's not something unique. type="image" is 6x on that page. The correct element offset is required to identify the right button element out of 6 on the page. Dan Quote Link to post Share on other sites
blumi40 222 Posted June 7, 2014 Report Share Posted June 7, 2014 Dan for what u need it? for submit the form? if so...why u dont use js to submit it? Quote Link to post Share on other sites
UBotBuddy 331 Posted June 8, 2014 Report Share Posted June 8, 2014 Well, when you are ready for the Parent/Child/Sibling/Offset just let me know what the website is. Good Luck in the mean time. Buddy Quote Link to post Share on other sites
Marton 48 Posted June 8, 2014 Report Share Posted June 8, 2014 Well, when you are ready for the Parent/Child/Sibling/Offset just let me know what the website is. Good Luck in the mean time. Buddy I like Dan's solution, but I too would like to see how you would do it. Like this? click($element child($element sibling($element sibling(<innertext="results per page">))), "Left Click", "No") EDIT: This works with the example script, I think this is what you were looking for Dan. Let me know if this works for you on your actual page. Quote Link to post Share on other sites
UBotBuddy 331 Posted June 8, 2014 Report Share Posted June 8, 2014 I don't like working from HTML shown like that. The absolute BEST way to generate good code is from seeing and touching the website firsthand. But that's me. With what I know about Parent/Child/Sibling coding something appears to be missing. Buddy 1 Quote Link to post Share on other sites
Bot-Factory 602 Posted June 8, 2014 Author Report Share Posted June 8, 2014 Well, when you are ready for the Parent/Child/Sibling/Offset just let me know what the website is. Good Luck in the mean time. BuddyHi Buddy, It's:https://sellercentral.amazon.comYou need an Amazon Seller account. And some Orders in the system to have access to the order overview page. Kindest regardsDan Quote Link to post Share on other sites
Marton 48 Posted June 8, 2014 Report Share Posted June 8, 2014 With what I know about Parent/Child/Sibling coding something appears to be missing. Buddy What do you mean? If you look at the example html you can notice that the needed element is the child of the next sibling. I needed to use next sibling twice because of the line break (<br>) which is also considered as a sibling in this case.My code seems to work with the example html even if you add some more buttons, but I can't do any further testing either, since I don't have an Amazon Seller Account. Dan, verdict? click($element child($element sibling($element sibling(<innertext="results per page">))), "Left Click", "No") Quote Link to post Share on other sites
Bot-Factory 602 Posted June 8, 2014 Author Report Share Posted June 8, 2014 What do you mean? If you look at the example html you can notice that the needed element is the child of the next sibling. I needed to use next sibling twice because of the line break (<br>) which is also considered as a sibling in this case.My code seems to work with the example html even if you add some more buttons, but I can't do any further testing either, since I don't have an Amazon Seller Account. Dan, verdict? click($element child($element sibling($element sibling(<innertext="results per page">))), "Left Click", "No") I can confirm thatclick($element child($element sibling($element sibling(<innertext="results per page">))), "Left Click", "No") is working fine. It's clicking exactly the right button in my case.Thanks a lot Marton for that. That's much easier than the loop offset thing I wrote. I still don't understand how that sibling stuff works but it works Dan Quote Link to post Share on other sites
Marton 48 Posted June 8, 2014 Report Share Posted June 8, 2014 I'm glad I could help, (especially after my initial silliness from yesterday, lol ). Anyway, that's all there's is to it: Marton Quote Link to post Share on other sites
UBotBuddy 331 Posted June 8, 2014 Report Share Posted June 8, 2014 Awesome! Glad it works. I tried the link Dan but my Amazon account does not work in that area...You must be "Special". LOL @Marton what I meant was it just looked off from my eyes. I would rather work from the site itself rather than embedded html like what Dan had placed in the original post. It's great to see others getting into Parent/Child/Sibling/Offset stuff. I have been the only one for the longest time. Buddy Quote Link to post Share on other sites
Marton 48 Posted June 9, 2014 Report Share Posted June 9, 2014 Awesome! Glad it works. I tried the link Dan but my Amazon account does not work in that area...You must be "Special". LOL @Marton what I meant was it just looked off from my eyes. I would rather work from the site itself rather than embedded html like what Dan had placed in the original post. It's great to see others getting into Parent/Child/Sibling/Offset stuff. I have been the only one for the longest time. Buddy Yeah I know, initially I think I learned about this stuff from your training, those are must see videos! I recommend them to everyone! All the best,Marton Quote Link to post Share on other sites
steelersfan 38 Posted December 23, 2014 Report Share Posted December 23, 2014 I have found this helpful for understanding offset a bit better. Posting so I have reference. Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.