concurrency - How to run browsers concurrently/simultaneously with Selenium Grid to search a list of strings in parts (in Java) -


i want able take list of strings, split list parts, , have each browser running search part of list (i.e. browser1 1/5, browser2 2/5...) in let's google (i happen using firefox).

how go doing using selenium grid. have set-up, , know how register hub , nodes hub, if helps explanation or solution involves different kind of instantiation, let me know. think other users reading have thrown in...

a step-by-step solution satisfy me though. can not selenium function browsers concurrently, 2 nodes. required use testng or mable or (i'm not familiar these)? wish 1 day have program developed win32 application (in c++/c#), can't run in "test suite" if can't encapsulate later distribution.

edit: here's framework of mean. not accomplish task, asking question now. don't know if require multiple drivers or multiple copies of same program running in memory, comment appropriately in code. in no way yet made concurrent-just task wish make concurrent on grid.

public void beginsearch(){      arraylist<string> searchterms=new arraylist<string>();     //pretend searchterms full of 100 strings!      //create new instance of firefox driver     capabilities=desiredcapabilities.firefox();      //let's have 1 webdriver object      try{         driver=new remotewebdriver(new url("http://localhost:4444/wd/hub"), capabilities);     }catch (malformedurlexception e){         e.printstacktrace();     }      //go google     driver.get("http://www.google.com");      for(int i=0; i<searchterms.size(); i++){           /*i put findelement() inside loop due experience           *not being able interact same element on different page when           *the url changes. think it's due xpath use internally in webelement           *class. ignore now.           */          element=driver.findelement(by.name("q"));          element.sendkeys(searchterms.get(i));          element.submit();     }      driver.quit; } /*let's hell of wanted do-how make perform  *this concurrently on grid!?  */ 

interesting... far know making connection webdriver in code no different connecting directly webdriver, in terms actual code use. can connect individual node in same manner in connect grid. grid responsible determining node hand off test , queue requests when there aren't available nodes. should able connect selenium grid2 using webdriver on individual thread without problems, long you're not sharing references. think general rule 1 webdriver per thread.

https://code.google.com/p/selenium/wiki/frequentlyaskedquestions

you don't absolutely need testng. testng contains lot of nice functionality ways of providing large data sets, advanced logging capabilities, test suites, etc.

http://en.wikipedia.org/wiki/testng

here incredibly basic idea. each test run on it's own thread each instance of webdriver running on it's own thread. i've not tested code.

public class tests {     public static void main(string[] args) {         for(int threadcount = 0; threadcount<5; threadcount++) {             new thread(new runnable() {                 public void run() {                     //create new instance of firefox driver                     capabilities=desiredcapabilities.firefox();                      //let's have 1 webdriver object                      try{                         driver=new remotewebdriver(new url("http://localhost:4444/wd/hub"), capabilities);                     }catch (malformedurlexception e){                         e.printstacktrace();                     }                      //go google                     driver.get("http://www.google.com");                      //quit driver                     driver.quit;                 }             }).start();         }     } } 

Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -