tooltrainer 12 Posted July 4, 2010 Report Share Posted July 4, 2010 Another case of down to the last tiny little tweaks to complete my bot, and I'm completely stuck. There is a field that this site uses, that keeps being auto-populated with the value from another field when UBot has set the contents. This doesn't happen if I manually enter the information however, even in UBot's browser. To be more specific... This is for a PPC ad network and there are a destination URL, and a Display URL fields. By default whatever you put in the destination URL field, is automatically copied over to the Display URL field, and you can then manually type whatever you want into the display URL field if you want it to be different. But when UBot either changes the value attribute of the display URL field, or sends keys to it, as soon as it's complete the field is again overwritten by the destination URL contents. I've even set up a while loop that just keeps changing the field to be what I want it to be, thinking that maybe it just needs a second or third try... but it doesn't matter, every single time UBot does its thing, its work is instantly dashed and replaced. Again if I manually type information in, everything works fine and what I type is not overwritten. I have no idea what else to try and this is an important part of my bot. Anyone have any clue what's going on here? Jonathan Quote Link to post Share on other sites
webautomationlab 21 Posted July 4, 2010 Report Share Posted July 4, 2010 If the js is in the body code, disable it. If that isn't the case, change the id of the second field, input your data and submit. If that doesnt work, change the id, input your data, change the id back, and see if the data sticks, then submit. hth Quote Link to post Share on other sites
tooltrainer 12 Posted July 4, 2010 Author Report Share Posted July 4, 2010 Well I fixed it... not sure what exactly was causing the problem but it was something to do with JS on the page that I couldn't control. After much hacking and slashing it's behaving properly now, so I'm satisfied. Thanks for the tips though! Jonathan Quote Link to post Share on other sites
tooltrainer 12 Posted July 5, 2010 Author Report Share Posted July 5, 2010 And of course I stand corrected. I fixed it partially but the same thing is still happening, if it's UBot that fills out the field, it gets overwritten by the default value. If it's a human being doing it, it works just fine. grrrrrrr. Jonathan Quote Link to post Share on other sites
tooltrainer 12 Posted July 5, 2010 Author Report Share Posted July 5, 2010 OK I'm at my wit's end... here's a video showing what's happening, maybe one of you brilliant folks can give me some ideas on where to go with this. http://screencast.com/t/MzIzN2QwY2Q Thanks!! Jonathan Quote Link to post Share on other sites
webautomationlab 21 Posted July 5, 2010 Report Share Posted July 5, 2010 Did you try my 3 suggestions? Quote Link to post Share on other sites
tooltrainer 12 Posted July 5, 2010 Author Report Share Posted July 5, 2010 Yeah I tried every permutation of messing with the JS that I could think of. Only one of the JS files being used on the page affects it at all, and if you remove it the entire field disappears so I can't do that. And when I change the ID of the field then the little "# of characters remaining" function stops working, and I really like that so don't want to lose it. Maybe I could find another # of characters remaining function to replicate that functionality and then change the ID of the field... I'll try that next. Any other suggestions? Jonathan Quote Link to post Share on other sites
tooltrainer 12 Posted July 5, 2010 Author Report Share Posted July 5, 2010 Crap what am I thinking... I can't replace the function because I don't have control over the network's own website. Crap crap crap!!!! I went and solved it for my own local copy of the page that I've been using to dev on, but of course that won't work in production because my new function and field values won't be present on the page. GRRRRRRRRRRRRRRR and here I thought I was so clever. Anyone else have any brighter ideas? Jonathan Quote Link to post Share on other sites
tooltrainer 12 Posted July 5, 2010 Author Report Share Posted July 5, 2010 Hey one question about this: "If that doesnt work, change the id, input your data, change the id back, and see if the data sticks, then submit." How can I change the ID of an element on a page I don't control? I must be missing something about your suggestion here... THanks! Jonathan Quote Link to post Share on other sites
UBotBuddy 331 Posted July 5, 2010 Report Share Posted July 5, 2010 Did you Clear Cookies? Quote Link to post Share on other sites
tooltrainer 12 Posted July 5, 2010 Author Report Share Posted July 5, 2010 Yeah... all that does is log me out of their site. The problem here is that they have a javascript on the page which is somehow interacting badly with UBot. Manual hand entry of data into the desired field works perfect, but not UBot. Jonathan Quote Link to post Share on other sites
alcr 135 Posted July 5, 2010 Report Share Posted July 5, 2010 Yeah... all that does is log me out of their site. The problem here is that they have a javascript on the page which is somehow interacting badly with UBot. Manual hand entry of data into the desired field works perfect, but not UBot. Jonathan Did you try putting your code in a subwindow/compile it? Quote Link to post Share on other sites
AKprogrammer 7 Posted July 6, 2010 Report Share Posted July 6, 2010 How can I change the ID of an element on a page I don't control? I must be missing something about your suggestion here... javascript of course. You can do 'run javascript' to define a function... function changeId(oldId, newId) { var elem = document.getElementById(oldId); elem.id = newId; } Then run javascript... changeId('{1}', 'blah'); Try changing the value. Then run javascript again....changeId('blah', '{1}'); Where {1} is UBot var of original id. BTW, have you tried a delay between setting the field values? Maybe UBot is so fast, all the fields get filled before the javascript to update the field is run. Quote Link to post Share on other sites
tooltrainer 12 Posted July 6, 2010 Author Report Share Posted July 6, 2010 WOW I had no idea you could change the ID of an element on the fly like that. Nice! That will probably work too. A delay isn't the solution, I can run the node while the bot isn't even running and it still overrides. ID changing is probably the answer. I'll let you know!! Jonathan Quote Link to post Share on other sites
tooltrainer 12 Posted July 6, 2010 Author Report Share Posted July 6, 2010 So it turns out that I need to get the element by name, not ID. But this isn't working as I thought it should: function changeName(oldName, newName) { var elem = document.getElementByName(oldName); elem.name = newName; } Have I got the wrong syntax? I know enough JS to be insanely dangerous and that's about all. Have I gone wrong with this somehow? By ID worked as far as changing the ID, but name isn't. Thanks! Jonathan Quote Link to post Share on other sites
tooltrainer 12 Posted July 6, 2010 Author Report Share Posted July 6, 2010 I see that for name it has to be getElements.ByName instead, and that it returns basically an array. I thought this would work: function changeName(oldName, newName) { var elem = document.getElementsByName(oldName)[0]; elem.name = newName; } But still no joy. Am I closer? Jonathan Quote Link to post Share on other sites
tooltrainer 12 Posted July 6, 2010 Author Report Share Posted July 6, 2010 I stand corrected it is working... the name is changing and the value is being entered, but I'm still getting the same overriding effect as before. I'll keep messing with it, I feel I'm close... but if anyone has a brainstorm, lay it on me! Jonathan Quote Link to post Share on other sites
tooltrainer 12 Posted July 6, 2010 Author Report Share Posted July 6, 2010 No matter what I do I can't seem to figure this out. I've gotten the change name code to work, and change ID works too... I've even changed them BOTH just for giggles and no matter what, every time UBot enters data into that field it is immediately overwritten by the page itself. alcr - can you explain what you mean by putting my code in a subwindow and compiling it? I'm afraid I don't follow but I'd sure like to. Thanks all... this one is just killing me as it's the only thing left to fix for this bot and it stops the entire project cold. Jonathan Quote Link to post Share on other sites
AKprogrammer 7 Posted July 6, 2010 Report Share Posted July 6, 2010 The text-input element that's used to overwrite the other field probably has an onchange event. Maybe you could try unregistering the onchange event? You could try getting the element (by name or id) and setting onchange to null... elem.onchange = null; Quote Link to post Share on other sites
tooltrainer 12 Posted July 6, 2010 Author Report Share Posted July 6, 2010 Nope, no onchange, nor onkeyup or onkeydown. Great idea though... any others? Any way to simply shut OFF javascript for a particular element all together or something?? Jonathan Quote Link to post Share on other sites
tooltrainer 12 Posted July 6, 2010 Author Report Share Posted July 6, 2010 Can't seem to find any way to disable JS completely for just one element. I've tried everything else I did find though... disabling the form from text entry changes nothing since that only locks out the human user from using their keyboard. Changing the IDs isn't working... using JS to set the value property directly isn't working. Messing with onchange hasn't worked. Nothing seems to be able to overcome this auto-form-fill thing that's going on. Still stumped and treading water... any other brilliant suggestions? I can't believe that none of the suggestions so far have made any difference at all, I really thought several of them were the answer! Jonathan Quote Link to post Share on other sites
AKprogrammer 7 Posted July 6, 2010 Report Share Posted July 6, 2010 Nope, no onchange, nor onkeyup or onkeydown. Great idea though... any others? Any way to simply shut OFF javascript for a particular element all together or something?? Jonathan Remove the element from the DOM... delay to make sure the element is removed (it should disappear), then right before submitting the form, re-insert the element? I didn't test this code, but something like this... var elem = null; var parent = null; function removeIt(someName) { elem = document.getElementsByName(someName)[0]; parent = elem.parentNode; parent.removeChild(elem); //if it doesn't disappear after this maybe there is another element with same name } function putItBack() { parent.addChild(elem); } Quote Link to post Share on other sites
tooltrainer 12 Posted July 6, 2010 Author Report Share Posted July 6, 2010 Another interesting suggestion. The removal part works and the field disappears, but putItBack doesn't seem to do anything. I assume I just call it via putItBack(); yes? It doesn't need to define what element name is being put back? Jonathan Quote Link to post Share on other sites
tooltrainer 12 Posted July 6, 2010 Author Report Share Posted July 6, 2010 GAH! Even removing the name and ID attributes completely doesn't work. Basically as soon as the page has loaded, whatever JS that's causing this auto-form-fill effect takes over and overrides anything UBot does no matter what. On the other hand if I remove the name & ID attributes at the page source itself (on my dev local copy of course) then the auto-fill is disabled and I can do what I want. Trouble is I don't have the luxury of modifying the page source on the actual live website. After so much time spent on this bot and coming SO close to completion... I just refuse to accept that there is no way to beat this. There must be! Any other ideas? Jonathan Quote Link to post Share on other sites
AKprogrammer 7 Posted July 6, 2010 Report Share Posted July 6, 2010 Another interesting suggestion. The removal part works and the field disappears, but putItBack doesn't seem to do anything. I assume I just call it via putItBack(); yes? It doesn't need to define what element name is being put back? Jonathan Yeah, I think it may be: function putItBack() { parent.appendChild(elem); } I almost always use jQuery for javascript, so I'm rusty in the "native" javascript I guess. 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.