emilix85 0 Posted April 14, 2013 Report Share Posted April 14, 2013 Hi guys i have need to follow a timer (in this format ex. 26.1) on a web page, when the timer reaches examples to 20 secondsshould I create a "if command"...My question is: How do I follow the timer by ubot until the condition occurs? Thanks Quote Link to post Share on other sites
LazyBotter 188 Posted April 14, 2013 Report Share Posted April 14, 2013 Use the scrape attribute function, to set a #var then check the condition using the set #var. Quote Link to post Share on other sites
LazyBotter 188 Posted April 14, 2013 Report Share Posted April 14, 2013 Here you go, take a look at this code it might give you some ideas. ui stat monitor("Current Time: ", "{#Scrape_Timer_Min}:{#Scrape_Timer_Sec}") ui drop down("Set Min", 04, #Min) ui drop down("Set Sec", "10,20,30,40,50", #Sec) ui button("Start") { set(#Start, $true, "Global") clear cookies navigate("http://ipadstopwatch.com/timer.html", "Wait") wait for browser event("Everything Loaded", "") click(<id="Done">, "Left Click", "No") wait(1) click(<id="Start">, "Left Click", "No") Scrape Time() } ui button("Stop") { set(#Start, $false, "Global") } define Scrape Time { loop while($comparison(#Start, "=", $true)) { set(#Scrape_Timer_Min, $scrape attribute(<id="Minutes">, "innertext"), "Global") set(#Scrape_Timer_Sec, $scrape attribute(<id="Seconds">, "innertext"), "Global") Check Statement() } } define Check Statement { if($comparison("{#Min}{#Sec}", ">=", "{#Scrape_Timer_Min}{#Scrape_Timer_Sec}")) { then { set(#Start, $false, "Global") alert("Reached Time!") } else { } } } Carl Quote Link to post Share on other sites
emilix85 0 Posted April 15, 2013 Author Report Share Posted April 15, 2013 (edited) Hi Carl Thanks for reply ok i have found the timer with scrapeattribute function and set a variable #Contatorebut now the problem is this when I insert the variable #contatore in the if does not recognize the value set(#Contatore, $scrape attribute(<outerhtml=w"<span id=\"contatore_*\"><span class=\"*\"> * </span></span>">, "innertext"), "Global") if($comparison(#Contatore, "<=", 25.4)) { then { click(<outerhtml=w"<input type=\"button\" id=\"*\" onclick=\"*\" value=\"Click\">">, "Left Click", "No") } } the value set on a variable #contatore is in this format: * (*=is a varible_value ex 25.4)When the #contatore is called by "if command" doesn't recognize it as a numeric value because there are these characters * How do I let him return only "*"? Thanks Edited April 15, 2013 by emilix85 Quote Link to post Share on other sites
LazyBotter 188 Posted April 15, 2013 Report Share Posted April 15, 2013 Can you provide a link? Quote Link to post Share on other sites
emilix85 0 Posted April 15, 2013 Author Report Share Posted April 15, 2013 yes i should follow the timer in this page http://bit.ly/104yq8g Quote Link to post Share on other sites
LazyBotter 188 Posted April 16, 2013 Report Share Posted April 16, 2013 You can scrape the attribute using "class" set(#Scrape, $scrape attribute(<class="bianco">, "innertext"), "Global") Quote Link to post Share on other sites
LazyBotter 188 Posted April 16, 2013 Report Share Posted April 16, 2013 Here you go: ui stat monitor("Current Time: ", #Scrape_Time) ui drop down("Set Sec", "20.1,20.2,20.3", #Time) ui button("Start") { set(#Start, $true, "Global") clear cookies navigate("http://www.prezzipazzi.com/prodotto/iphone-5.php?id=151953", "Wait") wait for browser event("Everything Loaded", "") Scrape Time() } ui button("Stop") { set(#Start, $false, "Global") } define Scrape Time { loop while($comparison(#Start, "=", $true)) { set(#Scrape_Time, $trim($scrape attribute(<class="bianco">, "innertext")), "Global") Check Statement() } } define Check Statement { if($comparison(#Time, ">=", #Scrape_Time)) { then { set(#Start, $false, "Global") alert("Reached Time!") } else { } } } Carl Quote Link to post Share on other sites
emilix85 0 Posted April 16, 2013 Author Report Share Posted April 16, 2013 ok thanks for your time work fine with this code: navigate("http://www.prezzipazzi.com/prodotto/iphone-5.php?id=151953", "Wait") set(#Contatore, $trim($scrape attribute(<outerhtml=w"<span id=\"*\"><span class=\"*\"> * </span></span>">, "innertext")), "Global") set(#Username, $scrape attribute(<outerhtml=w"<span id=\"*\">Offerta più alta:<br>*</span>">, "innertext"), "Global") loop while($comparison(#Contatore, ">=", 23)) { set(#Contatore, $trim($scrape attribute(<outerhtml=w"<span id=\"*\"><span class=\"*\"> * </span></span>">, "innertext")), "Global") if($comparison(#Contatore, "<=", 23)) { then { click(<id="bottone151953">, "Left Click", "No") } } } I have just 2 questionsHow do I start the loopwhile everytime the site restart the timer?I tried to insert in if two conditions: if("{$comparison(#Contatore, "<=", 23)}&&{$comparison(#Username, "!=", "Offerta più alta:<br>emilix85")}") { then { click(<id="bottone151953">, "Left Click", "No") } } } but when the conditions is true don't run the command.... Thanks Quote Link to post Share on other sites
LazyBotter 188 Posted April 16, 2013 Report Share Posted April 16, 2013 You nees to use define commands to call the command over and over. Quote Link to post Share on other sites
LazyBotter 188 Posted April 16, 2013 Report Share Posted April 16, 2013 if you are using two conditions in an if statement, you should use the $both function. Quote Link to post Share on other sites
LazyBotter 188 Posted April 16, 2013 Report Share Posted April 16, 2013 ui stat monitor("Current Time: ", #Scrape_Time) ui drop down("Set Sec", "20.1,20.2,20.3", #Time) ui button("Start") { set(#Start, $true, "Global") clear cookies navigate("http://www.prezzipazzi.com/prodotto/iphone-5.php?id=151953", "Wait") wait for browser event("Everything Loaded", "") Scrape Time() } ui button("Stop") { set(#Start, $false, "Global") } define Scrape Time { loop while($comparison(#Start, "=", $true)) { set(#Scrape_Time, $trim($scrape attribute(<class="bianco">, "innertext")), "Global") Check Statement() } } define Check Statement { if($comparison(#Time, ">=", #Scrape_Time)) { then { comment("Add your script between here") click(<value="PUNTA">, "Left Click", "No") comment("This will call the define again...") Scrape Time() } else { } } } Quote Link to post Share on other sites
jainteq 0 Posted April 20, 2013 Report Share Posted April 20, 2013 Thanks !! You guys just made my day bit easier, by giving good information. Keep it up 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.