Jump to content



Photo

Clicking Java Elements Works In Define, But Not When Running

Javascript Click define

  • Please log in to reply
2 replies to this topic

#1 Sebastian Rooks

Sebastian Rooks

    Advanced Member

  • Members
  • PipPipPip
  • 40 posts
  • OS:Windows 10
  • Total Memory:4Gb
  • Framework:v4.5+, unsure
  • License:Professional Edition

Posted 18 January 2016 - 11:17 AM

This is Ubot Day 5 for me! My first bot made a lot of progress yesterday thanks to what I've learned from this forum, now I've run into another problem I haven't been able to figure out.

 

I'm working with Twitter. There are Javascript buttons and dropdown menus that need clicked. I'm experimenting with changing the attributes of selected elements (I don't understand best practices here). I've also experimented with using the click image option.

 

Through a combination of those things, in a DEFINE, I can click through and it does what it's intended to do. In this case, it's to start from the account's homepage, CLICK the profile and settings icon, then CLICK view profile, then CLICK edit profile, then CLICK on Change profile picture, Then CLICK upload photo from the drop down menu.

 

After that, it'll upload a photo from a table, but I didn't get that far yet.

 

The problem is that when I RUN NODE on each individual node of the define, it works. But when the bot calls the custom command when running through the program, it gets a step or two into it, then fails to complete, and moves on. There are appropriate WAITs in place.

 

I am certain that it's calling the DEFINE because it starts to work, it gets through the first step or two.

 

How can I best debug DEFINES while it's running because it doesn't expand the custom command node to show what commands went into i?

 

I could maybe solve my problem (poorly) by not using DEFINEs, but there's going to be a different one for each of 6 tasks, so it's going to be really difficult if I don't, and it'll really limit what I can do in the futre.. Also, I won't learn anything.

 

Any help in the right direction will be greatly appreciated!

 

Again, this works when run one node at a time. (Is there a better way to test run custom commands?)

Does not work properly when the bot calls it.

 

define Changeprofilepicture {
    click(<id="user-dropdown-toggle">,"Left Click","No")
    wait for element(<class="header-inner">,"","Appear")
    click(<class="account-summary account-summary-small js-nav">,"Left Click","No")
    wait($rand(#mintime,#maxtime))
    wait for element(<class="UserActions-editButton edit-button btn">,"","Appear")
    click(<image="___IMAGE___6___IMAGE___">,"Left Click","No")
    wait($rand(#mintime,#maxtime))
    wait for element(<class="ProfilePage-saveButton btn primary-btn">,"","Appear")
    click(<class="ProfileAvatarEditing-button u-boxShadowInsetUserColorHover">,"Left Click","No")
    wait($rand(#mintime,#maxtime))
    wait for element($element offset(<name="media[]">,0),"","Appear")
    click(<image="___IMAGE___3___IMAGE___">,"Left Click","No")
}

 



#2 HelloInsomnia

HelloInsomnia

    Advanced Member

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

Posted 18 January 2016 - 01:29 PM

Maybe try to scrape the buttons and such you are clicking on into variables and make sure the code is the same when the bot runs as when you step through it. 



#3 Sebastian Rooks

Sebastian Rooks

    Advanced Member

  • Members
  • PipPipPip
  • 40 posts
  • OS:Windows 10
  • Total Memory:4Gb
  • Framework:v4.5+, unsure
  • License:Professional Edition

Posted 18 January 2016 - 05:25 PM

Maybe try to scrape the buttons and such you are clicking on into variables and make sure the code is the same when the bot runs as when you step through it. 

 

I tried to scrape the buttons, but I don't really understand that yet. I'm sure I'll get my head wrapped around that soon enough.

 

Roughly 12 solid hours of trying to figure out this problem later, I got it. Turns out it had nothing to do with my code,  Javascript menus, or calling the define. For some reason, sometimes, when an account logs into Twitter, and clicks the icon for the drop down menu it goes straight to settings instead of toggling the menu.

 

Once I figured out where the problem actually was, I solved it by looping my click command while the dropdown menu did not exist, and then moving on.

 

I feel victorious, I just may get a hang of this programming thing.

 

Thanks for your help!


Edited by Sebastian Rooks, 18 January 2016 - 05:26 PM.






Also tagged with one or more of these keywords: Javascript, Click, define

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users