unibotsi 7 Posted November 18, 2018 Report Share Posted November 18, 2018 Hey there While finishing the first bot, i am running in more and more problems. Most of my defines will be fired by a button (html ui). But they run not completely through. I do not get the last alerts.In this example the #CollectorStatus will not be set, which i would like to use as an indicator of success or not.This is a search and collect profiles function. define gosearch { wait for browser event("DOM Ready","") navigate("https://www.xing.com/search/members?keywords={#search}","Wait") wait(4) loop(2) { set(#CollectorStatus,"<div class=\"alert alert-primary\" role=\"alert\"> <div class=\"loader\"></div> Visiting Profiles </div>","Global") add list to list(%ProfileUrlsCollector,$scrape attribute(<class="name-page-link">,"href"),"Delete","Global") click(<class="foundation-icon-shape-arrow-right">,"Left Click","No") wait for browser event("DOM Ready","") wait(2) } add list to list(%ToVisitProfilUrls,$list from text($replace(%ProfileUrlsCollector,"/profile","https://xing.com/profile"),$new line),"Delete","Global") set(#CollectorStatus,"<div class=\"alert alert-success\" role=\"alert\"> Done - besuche die Profile mit dem Profile Visitor. </div>","Global") wait(2) set(#botfolder,$folder exists("{$special folder("Desktop")}\\XngVisitor"),"Global") if(#botfolder) { then { save to file("{$special folder("Desktop")}\\XngVisitor\\tovisit.csv",%ToVisitProfilUrls) alert("FileSaved") } else { create folder($special folder("Desktop"),"XngVisitor") save to file("{$special folder("Desktop")}\\XngVisitor\\tovisit.csv",%ToVisitProfilUrls) alert("FileSaved") } } alert("EverythingDone") } This example should check if a specific text exists on the page - but the check does not happen.This is a login function. define login { navigate("http://login.xing.com","Wait") wait for browser event("DOM Ready","") ui text box("Account Email",#email) set table cell(&Creds,0,0,#email) type text(<email field>,#email,"Standard") ui password("Xing Passwort",#pass) set table cell(&Creds,1,0,$encrypt(#pass,"base64")) type text(<password field>,#pass,"Standard") save to file("{$special folder("Desktop")}\\XngVisitor\\settings.csv",&Creds) click(<name="button">,"Left Click","No") wait for browser event("DOM Ready","") wait(2) if($search page("Eingabe gerade leider nicht erkannt")) { then { set(#LoginStatus,"<div class=\"alert alert-danger\" role=\"alert\"> Bitte einloggen oder Email bzw. Passwort überprüfen. </div>","Global") } else { set(#LoginStatus,"<div class=\"alert alert-success\" role=\"alert\"> Yes - eingeloggt. Auf gehts! </div>","Global") } } } Does anyone see some mistakes i made? While starting/testing out my scripts in different tabs, everything worked out fine.As i combined all code in one tab now and structuring everything into commands - i get a lot of uncool behaviour. Quote Link to post Share on other sites
HelloInsomnia 1103 Posted November 19, 2018 Report Share Posted November 19, 2018 It looks good but maybe pull it out of the define and run it in a separate Ubot so you can see what is running (the node that is currently running has a purple highlight so use light theme if using X). Quote Link to post Share on other sites
unibotsi 7 Posted November 19, 2018 Author Report Share Posted November 19, 2018 Hm, working fine as tab-standalone script, but in a define function, it sometimes get stuck.It is an older Version (5) from a friend, which i use to check if ubot is the go-to tool for me - before investing almost 1k of dineros :-) Quote Link to post Share on other sites
HelloInsomnia 1103 Posted November 19, 2018 Report Share Posted November 19, 2018 So only part of the commands are running? Quote Link to post Share on other sites
unibotsi 7 Posted November 19, 2018 Author Report Share Posted November 19, 2018 Yes, sometimes it skips the first, sometimes the last commands. Sometimes it works perfectly fine, mainly after restarting ubot.Might this be a problem with the ubot version - or is this usual behaviour and can happen? Quote Link to post Share on other sites
HelloInsomnia 1103 Posted November 19, 2018 Report Share Posted November 19, 2018 It shouldn't happen, can you post your whole bot maybe there is something else wrong. Quote Link to post Share on other sites
Brutal 164 Posted November 20, 2018 Report Share Posted November 20, 2018 unibotsi says: It is an older Version (5) from a friend, which i use to check if ubot is the go-to tool for me - before investing almost 1k of dineros :-) Sounds a little suspicious... maybe you got the version of ubot that can detect that it has been cracked and as a defense it provides erratic results so that you cannot profit from it without first paying for it. But - I could be wrong :-) 2 Quote Link to post Share on other sites
unibotsi 7 Posted December 28, 2018 Author Report Share Posted December 28, 2018 Nope - still the same with the new, personally bought Ubot X Version.Works fine in a standalone tab, but bugging with whole script in one tab. Maybe this is an known error, maybe to much script per tab?The whole script is about 400 lines, 500 List items in two lists and maybe 15 different variables.So not much i guess?! Quote Link to post Share on other sites
Brutal 164 Posted December 28, 2018 Report Share Posted December 28, 2018 I see a couple of things wrong you may want to address before you continue. 1- you call for a browser wait event before you even call the browser....so you'll want to put that immediately after the navigate call... This isn't something that will cause a break, but it is useless the way you have it displayed via your posted code. 2- the next thing that comes to my attention is an if statement on the page.... you have it as: [if] #variable [then]..... that isn't how things work. Instead, you need to give the [if] statement something to work with... like, "contains", or "comparison", or "exists", else, I don't think it would ever save your file. 1 Quote Link to post Share on other sites
unibotsi 7 Posted December 28, 2018 Author Report Share Posted December 28, 2018 Thanks for the input! I always appreciate that!Though it is hard to "reproduce", as i do not know where you are referring to 1. If you are referring to the first wait event - this one looks weird, but it follows a navigate from the previous step. 2. I guess you are referring to the #botfolder variable - this one is a true or false variable (checking if the save folder is available) which i use very often, so i did store the value as boolean. All files are saving perfect. Btw, do you use Ubot X?Using it "brutally" since some hours, have to restart very often now as it crashes a lot Quote Link to post Share on other sites
HelloInsomnia 1103 Posted December 28, 2018 Report Share Posted December 28, 2018 2- the next thing that comes to my attention is an if statement on the page.... you have it as: [if] #variable [then]..... that isn't how things work. Instead, you need to give the [if] statement something to work with... like, "contains", or "comparison", or "exists", else, I don't think it would ever save your file. You can actually do that if the variable is true or false set(#bool,"true","Global") if(#bool) { then { alert("I am true!") } else { alert("I am false!") } } 2 Quote Link to post Share on other sites
unibotsi 7 Posted January 2, 2019 Author Report Share Posted January 2, 2019 (edited) Still having those Problems. I wrote this simple Script, where the Search should start by clicking the "Go" Button. Does not work, nothing runs. ui button("Go") { define Google Search { navigate("http://google.com","Wait") type text(<name="q">,"Hello World","Standard") click($element offset(<name="btnK">,1),"Left Click","No") } } Neither does this script run, if pressing the "Run" button in Ubot header. Also does "right click" in the define header and "Run node" not work. define Google Search { navigate("http://google.com","Wait") type text(<name="q">,"Hello World","Standard") click($element offset(<name="btnK">,1),"Left Click","No") } Am i missing something? Edited January 2, 2019 by unibotsi Quote Link to post Share on other sites
Pete 121 Posted January 3, 2019 Report Share Posted January 3, 2019 ui button("Go") { Google Search() } define Google Search { navigate("http://google.com","Wait") type text(<name="q">,"Hello World","Standard") click($element offset(<name="btnK">,1),"Left Click","No") } omg Try this, happy new year to all Quote Link to post Share on other sites
unibotsi 7 Posted January 6, 2019 Author Report Share Posted January 6, 2019 thanks, i will try that out. Is "outsourcing" the define generally a good idea?Is it something what should always be done? Quote Link to post Share on other sites
HelloInsomnia 1103 Posted January 6, 2019 Report Share Posted January 6, 2019 thanks, i will try that out. Is "outsourcing" the define generally a good idea?Is it something what should always be done? What do you mean by outsourcing? Quote Link to post Share on other sites
unibotsi 7 Posted January 7, 2019 Author Report Share Posted January 7, 2019 I mean not to write the whole define tasks into a button. I did: Button {the whole google search define command}The working solution: Button{just the custom command} Define {the google search command}With outsourcing i mean, not putting the search tasks as define into the button command.The define is on its own and the button just calls the custom command. Why does it not work like i did it at the beginning? Is it better to have a tab, where i write down all my defines and call them as custom commands in the main tab where i have my UI? Quote Link to post Share on other sites
HelloInsomnia 1103 Posted January 7, 2019 Report Share Posted January 7, 2019 You must call a custom command/function after you define it to use it. You can (and probably should) define your custom commands in other tabs which are labeled and organized and then call them from the main script. Example: comment("This part is ran") MyCommand() divider divider comment("You can call this as many times as you want") MyCommand() divider divider divider divider comment("This is the defined code it is only ran when you call MyCommand not when the script gets here (then it is skipped)") define MyCommand { alert("hi") } 1 Quote Link to post Share on other sites
unibotsi 7 Posted January 9, 2019 Author Report Share Posted January 9, 2019 Thanks! I will adopt this in my workflow - i thought it has to be the opposite. First define the function, then call it. 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.