Jump to content
UBot Underground

Selecting An Element Only If It Doesn't Have A Certain Style


Recommended Posts

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.

Link to post
Share on other sites

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!

Link to post
Share on other sites

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")
        }
    }
}
Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...