nuc63 27 Posted May 16, 2013 Report Share Posted May 16, 2013 ui stat monitor("login attempts", #loginattempt) set(#status, $nothing, "Global") set(#loginattempt, 0, "Global") set(#site, 0, "Global") ui open file("Sites to visit", #accounts) ui stat monitor("status", #status) create table from file(#accounts, &accounts) to do() define to do { loop($table total rows(&accounts)) { set(#url, $table cell(&accounts, #site, 0), "Global") login() increment(#site) } } define login { if($comparison(#loginattempt, "=", 3)) { then { set(#status, "3 Login Errors", "Global") } else { do login() } } } define do login { navigate(#url, "Wait") wait for browser event("DOM Ready", "") check login() } define check login { if($search page("Search Page")) { then { set(#loginattempt, 0, "Global") do task() } else { increment(#loginattempt) login() } } } define do task { load html("good") }I have created a sample bot. Basically I have created a bot that I want to make sure I am logged in. if not try again up to three times. Bot dies and does not continue in loop after three successful non logins. In the example above it navigates to a url in a table where you select file to use and then goes to site and searches for "search page" and if its not there it reloads the login script. is there a better way to do this as this is not working. Ubot studio Version 4.2.16 Problem solved Correction below ui stat monitor("site", #site) ui stat monitor("login attempts", #loginattempt) set(#status, $nothing, "Global") set(#loginattempt, 0, "Global") set(#site, 0, "Global") ui open file("Sites to visit", #accounts) ui stat monitor("status", #status) create table from file(#accounts, &accounts) to do() define to do { loop($table total rows(&accounts)) { set(#url, $table cell(&accounts, #site, 0), "Global") login() increment(#site) wait(2) } } define login { if($comparison(#loginattempt, "=", 3)) { then { set(#status, "3 Login Errors", "Global") set(#loginattempt, 0, "Global") } else { do login() } } } define do login { navigate(#url, "Don\'t Wait") wait(5) check login() } define check login { if($search page("Search Page")) { then { set(#loginattempt, 0, "Global") do task() } else { increment(#loginattempt) login() } } } define do task { load html("good") } Quote Link to post Share on other sites
AutomationNinja 194 Posted May 17, 2013 Report Share Posted May 17, 2013 It looks like it should work. What part is not working? Quote Link to post Share on other sites
Legend 181 Posted May 17, 2013 Report Share Posted May 17, 2013 Try replacing the: wait for browser event("DOM Ready", "") with something more substantial... DOM Ready is real quirky... Quote Link to post Share on other sites
nuc63 27 Posted May 17, 2013 Author Report Share Posted May 17, 2013 i replaced the wait for dom with a 5 second wait it was a simple error if($comparison(#loginattempt, "=", 3)) { then { set(#status, "3 Login Errors", "Global") set(#loginattempt, 0, "Global") ui stat monitor("site", #site) ui stat monitor("login attempts", #loginattempt) set(#status, $nothing, "Global") set(#loginattempt, 0, "Global") set(#site, 0, "Global") ui open file("Sites to visit", #accounts) ui stat monitor("status", #status) create table from file(#accounts, &accounts) to do() define to do { loop($table total rows(&accounts)) { set(#url, $table cell(&accounts, #site, 0), "Global") login() increment(#site) wait(2) } } define login { if($comparison(#loginattempt, "=", 3)) { then { set(#status, "3 Login Errors", "Global") set(#loginattempt, 0, "Global") } else { do login() } } } define do login { navigate(#url, "Don\'t Wait") wait(5) check login() } define check login { if($search page("Search Page")) { then { set(#loginattempt, 0, "Global") do task() } else { increment(#loginattempt) login() } } } define do task { load html("good") } 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.