botsimmer 16 Posted January 11, 2017 Report Share Posted January 11, 2017 Hi ubotters, I am having great trouble with looping next list item but I am getting all text on same line as opposed to new line. I would like to loop through each words 1 at a time until list is finished. The following code shows 2 words together despite setting new line: ui block text("WikiWord:",#wiki_words) clear list(%wiki_lists) add list to list(%wiki_lists,$list from text(#wiki_words,$new line),"Delete","Global") set list position(%wiki_lists,0) set(#navi,"https://www.wikipedia.org/","Global") loop($list total(%wiki_lists)) { navigate(#navi,"Wait") wait for browser event("Everything Loaded","") type text(<name="search">,#wiki_words,"Standard") wait(0.5) click(<class="pure-button pure-button-primary-progressive">,"Left Click","No") wait(5) navigate("{#navi}{$next list item(%wiki_lists)}","Wait") } Please can some one point me in the right direction to loop correctly. Thanks in advance. Quote Link to post Share on other sites
HelloInsomnia 1103 Posted January 11, 2017 Report Share Posted January 11, 2017 You are trying to search for all of the words in the box and so it will just put them together. Also, your navigate URL is slightly off. You can just go directly to the words you want. But if you want to search instead of just navigating then it will be different. If you just want to navigate you can do this: ui block text("WikiWord:",#wiki_words) clear list(%wiki_lists) add list to list(%wiki_lists,$list from text(#wiki_words,$new line),"Delete","Global") set list position(%wiki_lists,0) set(#navi,"https://en.wikipedia.org/wiki/","Global") loop($list total(%wiki_lists)) { set(#word,$next list item(%wiki_lists),"Global") navigate("{#navi}{#word}","Wait") wait for browser event("Everything Loaded","") wait(5) } Here is an example with searching instead: ui block text("WikiWord:",#wiki_words) clear list(%wiki_lists) add list to list(%wiki_lists,$list from text(#wiki_words,$new line),"Delete","Global") set list position(%wiki_lists,0) set(#navi,"https://en.wikipedia.org/wiki/","Global") loop($list total(%wiki_lists)) { set(#word,$next list item(%wiki_lists),"Global") navigate("https://www.wikipedia.org/","Wait") wait for browser event("Everything Loaded","") wait for element(<name="search">,"","Appear") type text(<name="search">,#word,"Standard") wait(1) comment("If the button exists and Wikipedia did not auto navigate us then click the search button") if($exists(<class="pure-button pure-button-primary-progressive">)) { then { click(<class="pure-button pure-button-primary-progressive">,"Left Click","No") comment("Here is where you can add in the logic to interact with the search results if you want") } else { } } wait(5) } Quote Link to post Share on other sites
botsimmer 16 Posted January 12, 2017 Author Report Share Posted January 12, 2017 You are trying to search for all of the words in the box and so it will just put them together. Also, your navigate URL is slightly off. You can just go directly to the words you want. But if you want to search instead of just navigating then it will be different. If you just want to navigate you can do this: ui block text("WikiWord:",#wiki_words) clear list(%wiki_lists) add list to list(%wiki_lists,$list from text(#wiki_words,$new line),"Delete","Global") set list position(%wiki_lists,0) set(#navi,"https://en.wikipedia.org/wiki/","Global") loop($list total(%wiki_lists)) { set(#word,$next list item(%wiki_lists),"Global") navigate("{#navi}{#word}","Wait") wait for browser event("Everything Loaded","") wait(5) } Here is an example with searching instead: ui block text("WikiWord:",#wiki_words) clear list(%wiki_lists) add list to list(%wiki_lists,$list from text(#wiki_words,$new line),"Delete","Global") set list position(%wiki_lists,0) set(#navi,"https://en.wikipedia.org/wiki/","Global") loop($list total(%wiki_lists)) { set(#word,$next list item(%wiki_lists),"Global") navigate("https://www.wikipedia.org/","Wait") wait for browser event("Everything Loaded","") wait for element(<name="search">,"","Appear") type text(<name="search">,#word,"Standard") wait(1) comment("If the button exists and Wikipedia did not auto navigate us then click the search button") if($exists(<class="pure-button pure-button-primary-progressive">)) { then { click(<class="pure-button pure-button-primary-progressive">,"Left Click","No") comment("Here is where you can add in the logic to interact with the search results if you want") } else { } } wait(5) }Hi mate, thank you so much for your support. You always over deliver.Thanks for pointing out the navigation. It was stuck in my mind to navigate in the loop then select 1x word with the New Line parameter. Thanks a bunch. 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.