Jump to content



Photo

Define From Button Not Working Correctly - But Separated In Tabs Works Fine?

define html nested tabs

  • Please log in to reply
17 replies to this topic

#1 unibotsi

unibotsi

    Advanced Member

  • Members
  • PipPipPip
  • 38 posts
  • OS:Windows 7
  • Total Memory:8Gb
  • Framework:v3.5 & v4.0
  • License:Developer Edition

Posted 18 November 2018 - 04:56 PM

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> &nbsp;&nbsp;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.

 

 

 



#2 HelloInsomnia

HelloInsomnia

    Advanced Member

  • Moderators
  • 3128 posts
  • OS:Windows 10
  • Total Memory:More Than 9Gb
  • Framework:v4.5+, unsure
  • License:Developer Edition

Posted 18 November 2018 - 07:00 PM

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).



#3 unibotsi

unibotsi

    Advanced Member

  • Members
  • PipPipPip
  • 38 posts
  • OS:Windows 7
  • Total Memory:8Gb
  • Framework:v3.5 & v4.0
  • License:Developer Edition

Posted 19 November 2018 - 07:20 AM

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 :-)



#4 HelloInsomnia

HelloInsomnia

    Advanced Member

  • Moderators
  • 3128 posts
  • OS:Windows 10
  • Total Memory:More Than 9Gb
  • Framework:v4.5+, unsure
  • License:Developer Edition

Posted 19 November 2018 - 10:46 AM

So only part of the commands are running?



#5 unibotsi

unibotsi

    Advanced Member

  • Members
  • PipPipPip
  • 38 posts
  • OS:Windows 7
  • Total Memory:8Gb
  • Framework:v3.5 & v4.0
  • License:Developer Edition

Posted 19 November 2018 - 01:15 PM

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?



#6 HelloInsomnia

HelloInsomnia

    Advanced Member

  • Moderators
  • 3128 posts
  • OS:Windows 10
  • Total Memory:More Than 9Gb
  • Framework:v4.5+, unsure
  • License:Developer Edition

Posted 19 November 2018 - 01:18 PM

It shouldn't happen, can you post your whole bot maybe there is something else wrong.



#7 Brutal

Brutal

    Advanced Member

  • Fellow UBotter
  • PipPipPip
  • 708 posts
  • OS:Windows 10
  • Total Memory:More Than 9Gb
  • Framework:v4.5+, unsure
  • License:Developer Edition

Posted 20 November 2018 - 04:07 AM

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 :-)



#8 unibotsi

unibotsi

    Advanced Member

  • Members
  • PipPipPip
  • 38 posts
  • OS:Windows 7
  • Total Memory:8Gb
  • Framework:v3.5 & v4.0
  • License:Developer Edition

Posted 28 December 2018 - 08:50 AM

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?!



#9 Brutal

Brutal

    Advanced Member

  • Fellow UBotter
  • PipPipPip
  • 708 posts
  • OS:Windows 10
  • Total Memory:More Than 9Gb
  • Framework:v4.5+, unsure
  • License:Developer Edition

Posted 28 December 2018 - 09:32 AM

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.



#10 unibotsi

unibotsi

    Advanced Member

  • Members
  • PipPipPip
  • 38 posts
  • OS:Windows 7
  • Total Memory:8Gb
  • Framework:v3.5 & v4.0
  • License:Developer Edition

Posted 28 December 2018 - 09:50 AM

Thanks for the input! I always appreciate that!

Though it is hard to "reproduce", as i do not know where you are referring to  :D

 

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  :blink:



#11 HelloInsomnia

HelloInsomnia

    Advanced Member

  • Moderators
  • 3128 posts
  • OS:Windows 10
  • Total Memory:More Than 9Gb
  • Framework:v4.5+, unsure
  • License:Developer Edition

Posted 28 December 2018 - 10:18 AM

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!")
    }
}


#12 unibotsi

unibotsi

    Advanced Member

  • Members
  • PipPipPip
  • 38 posts
  • OS:Windows 7
  • Total Memory:8Gb
  • Framework:v3.5 & v4.0
  • License:Developer Edition

Posted 02 January 2019 - 01:34 PM

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 by unibotsi, 02 January 2019 - 01:41 PM.


#13 Pete

Pete

    Advanced Member

  • Fellow UBotter
  • PipPipPip
  • 882 posts
  • LocationUK london
  • OS:Windows 10
  • Total Memory:More Than 9Gb
  • Framework:v3.5 & v4.0
  • License:Developer Edition

Posted 02 January 2019 - 07:59 PM

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



#14 unibotsi

unibotsi

    Advanced Member

  • Members
  • PipPipPip
  • 38 posts
  • OS:Windows 7
  • Total Memory:8Gb
  • Framework:v3.5 & v4.0
  • License:Developer Edition

Posted 06 January 2019 - 02:47 AM

thanks, i will try that out.

 

Is "outsourcing" the define generally a good idea?

Is it something what should always be done?



#15 HelloInsomnia

HelloInsomnia

    Advanced Member

  • Moderators
  • 3128 posts
  • OS:Windows 10
  • Total Memory:More Than 9Gb
  • Framework:v4.5+, unsure
  • License:Developer Edition

Posted 06 January 2019 - 03:42 PM

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?



#16 unibotsi

unibotsi

    Advanced Member

  • Members
  • PipPipPip
  • 38 posts
  • OS:Windows 7
  • Total Memory:8Gb
  • Framework:v3.5 & v4.0
  • License:Developer Edition

Posted 07 January 2019 - 10:27 AM

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.

 

  1. Why does it not work like i did it at the beginning?
  2. 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?


#17 HelloInsomnia

HelloInsomnia

    Advanced Member

  • Moderators
  • 3128 posts
  • OS:Windows 10
  • Total Memory:More Than 9Gb
  • Framework:v4.5+, unsure
  • License:Developer Edition

Posted 07 January 2019 - 12:27 PM

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")
}


#18 unibotsi

unibotsi

    Advanced Member

  • Members
  • PipPipPip
  • 38 posts
  • OS:Windows 7
  • Total Memory:8Gb
  • Framework:v3.5 & v4.0
  • License:Developer Edition

Posted 09 January 2019 - 05:16 AM

Thanks! I will adopt this in my workflow - i thought it has to be the opposite. First define the function, then call it.







Also tagged with one or more of these keywords: define, html, nested, tabs

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users