John Marshall 8 Posted September 7, 2016 Report Share Posted September 7, 2016 Hi, I'm working on a bot that uploads files to various sites. The process is different the first time that a file is uploaded to when subsequent files are uploaded, for certain sites. How do I set up my bot so that it can handle this? I imagine that I'd need to indicate that it is a first time upload on my UI but I don't know what to do, thereafter. John Quote Link to post Share on other sites
Brutal 164 Posted September 7, 2016 Report Share Posted September 7, 2016 John you really didn't give us (the community) much information to work from. Put in your existing code snippets and it will be easier for more advanced users to help you get on the right track. Without knowing more - I would say create a define for each of the different upload requirements, and then run those defines inline or in threads 1 Quote Link to post Share on other sites
John Marshall 8 Posted September 7, 2016 Author Report Share Posted September 7, 2016 Thanks, Brutal. I appreciate your help. My apologies - I'm still learning and it obviously shows in my questions. I'll sort out some code and paste it here later today or tomorrow. Quote Link to post Share on other sites
John Marshall 8 Posted September 7, 2016 Author Report Share Posted September 7, 2016 OK, so, here a few more details, which I hope will help The bot uploads a PDF to a website for publication. I've replaced all references to the site in question with the word hidden in case they are not impressed. The process differs at line 18 in the 2nd code [comment("click UPLOAD top right hand corner")] and then follows a slightly different process, thereafter. The first PDF uploaded uses the first set of code and all subsequent PDFs the second lot of code. How would you normally deal with this situation? 1st Code: clear cookies navigate("http://hidden.com/","Wait") wait for browser event("DOM Ready","") wait(3) click($element offset(<login link>,1),"Left Click","No") wait(2) divider comment("Add login details") divider type text(<username field>,#hiddenLogin,"Standard") wait(2) type text(<password field>,#hiddenPassword,"Standard") wait(2) click($element offset(<login button>,3),"Left Click","No") wait for browser event("DOM Ready","") wait(5) divider comment("click Publish on hidden") divider click(<data-header-nav-track-internal="upload">,"Left Click","No") wait(5) divider comment("upload PDFvar which is the PDF file being distributed") divider click(<class="moduleWelcome__button ixu-button ixu-button--pronounced js-hackpathforloggedin">,"Left Click","No") wait for browser event("DOM Ready","") wait(5) divider comment("Upload PDFvar") divider change file field(<id="publish-select-btn">,#PDFvar) divider comment("Wait for the file to load. looks for Description Box.") divider wait for element(<id="description">,"","Appear") divider comment("Checks that the page has actually loaded after uploading the file.") divider wait(2) type text(<name="title">,#PDFTitlevar,"Standard") wait(2) type text(<id="description">,#PDFDescription,"Standard") wait(2) click(<class="btn btn-success sel-publish-mode-selector-button-submit js-submit">,"Left Click","No") 2nd Code: clear cookies navigate("http://hidden.com/","Wait") wait for browser event("DOM Ready","") wait(3) click($element offset(<login link>,1),"Left Click","No") wait(2) divider comment("Add login details") divider type text(<username field>,#hiddenLogin,"Standard") wait(2) type text(<password field>,#hiddenPassword,"Standard") wait(2) click($element offset(<login button>,3),"Left Click","No") wait for browser event("DOM Ready","") wait(5) divider comment("click UPLOAD top right hand corner") divider click(<data-header-nav-track-internal="upload">,"Left Click","No") wait(5) divider comment("upload PDFvar which is the PDF file being distributed") divider divider comment("Upload PDFvar") divider change file field(<id="publish-select-btn">,#PDFvar) divider comment("Wait for the file to load. looks for Description Box.") divider wait for element(<id="description">,"","Appear") divider comment("Checks that the page has actually loaded after uploading the file.") divider wait(2) type text(<name="title">,#PDFTitlevar,"Standard") wait(2) type text(<id="description">,#PDFDescription,"Standard") stop script wait(2) click(<class="btn btn-success sel-publish-mode-selector-button-submit js-submit">,"Left Click","No") Quote Link to post Share on other sites
LoWrIdErTJ - BotGuru 904 Posted September 7, 2016 Report Share Posted September 7, 2016 if run 1do thiselse do second way Quote Link to post Share on other sites
John Marshall 8 Posted September 8, 2016 Author Report Share Posted September 8, 2016 Thanks, Botguru. May I ask for just a little more detail, please? I can't quite figure out what to do from your answer. 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.