yonatankra 1 Posted October 4, 2017 Report Share Posted October 4, 2017 Hi,I want to wait for an element.Problem is - the element is in the DOM.So essentially, I want to wait for the element to have "display: none" removed.How can this be done?Thanks Quote Link to post Share on other sites
HelloInsomnia 1103 Posted October 4, 2017 Report Share Posted October 4, 2017 You can scrape the style tag and see if it contains that text, then loop while it doesn't and have a wait to check every second or however long you want. Quote Link to post Share on other sites
yonatankra 1 Posted October 5, 2017 Author Report Share Posted October 5, 2017 Thanks. Could you please share a code sample?I'm not that proficient with Ubot methods. Quote Link to post Share on other sites
HelloInsomnia 1103 Posted October 5, 2017 Report Share Posted October 5, 2017 It would be easier probably to show you on the site you are trying to use it on but this is an example on the Ubot playground in order to demonstrate it though I had to add in some extra things so on the first loop it will not find a username then it will wait and fill in a username, on the second loop since the username is now filled in it will exit the loop and finish the program: navigate("https://ubotstudio.com/site/playground-simple-form/","Wait") if($exists(<name="baltimore-no">)) { then { click(<name="baltimore-no">,"Left Click","No") } else { } } set(#continue,"false","Global") loop while($comparison(#continue,"=","false")) { set(#username,$scrape attribute(<username field>,"value"),"Global") if($comparison($trim(#username),"=",$nothing)) { then { wait(3) type text(<username field>,"someuser55","Standard") } else { set(#continue,"true","Global") } } } alert("Now the username is filled in") So it's the same idea but in a different application since I can't think of any sites that change anything slowly enough to demonstrate it. Quote Link to post Share on other sites
yonatankra 1 Posted October 5, 2017 Author Report Share Posted October 5, 2017 Thanks.So let's say I'm trying to find an element that has an inline style with display: none;Let's say I have this: <a id="linkId" style="background-color: green; display: none; margin: auto;">Which after some user actions changes to: <a id="linkId" style="background-color: green; margin: auto;">How can I wait for this change? I want to whole thread to stop until the display: none is gone.Thanks! Quote Link to post Share on other sites
HelloInsomnia 1103 Posted October 5, 2017 Report Share Posted October 5, 2017 It would look like this, this will loop forever because its not going to change but if you apply it to the page you want to then it should work fine. Of course that page will have to have that id of "linkId" or you will have to change the scrape attribute: load html("<a id=\"linkId\" style=\"background-color: green; display: none; margin: auto;\">Link</a>") set(#continue,"false","Global") loop while($comparison(#continue,"=","false")) { set(#style,$scrape attribute(<id="linkId">,"style"),"Global") if($contains(#style,"display: none")) { then { wait(1) } else { set(#continue,"true","Global") } } } Quote Link to post Share on other sites
yonatankra 1 Posted October 5, 2017 Author Report Share Posted October 5, 2017 Thanks! 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.