java - how can skip a test in same class- selenium web driver -


currently working on selenium webdriver , using java.. test run in firefox 26.0.. in eclipse using testng frame work..

  • if i'm running test name test.java. in have many filter section combination drop down values date picker , multi select box shown in image.

enter image description here

based upon filter section have written code follows:

log.info("clicking on visualization dropdown");  javascriptexecutor executor = (javascriptexecutor)driver; executor.executescript("document.getelementbyid('visualizationid').style.display='block';");    select select = new select(driver.findelement(by.id("visualizationid"))); select.selectbyvisibletext("week"); thread.sleep(6000);  log.info("clicking on period dropdown"); javascriptexecutor executor1 = (javascriptexecutor)driver; executor1.executescript("document.getelementbyid('periodid').style.display='block';"); select select1 = new select(driver.findelement(by.id("periodid"))); select1.selectbyvisibletext("last 4 weeks"); thread.sleep(6000);   log.info("clicking on apply filter button"); driver.findelement(by.id("kpifiltersubmit")).click();// 1 combination of filter section  //filter selection-2  log.info("clicking on visualization dropdown"); javascriptexecutor executor3 = (javascriptexecutor)driver; executor3.executescript("document.getelementbyid('visualizationid').style.display='block';"); select select3 = new select(driver.findelement(by.id("visualizationid"))); select3.selectbyvisibletext("icc"); thread.sleep(6000);   log.info("clicking on type dropdown"); javascriptexecutor executor02 = (javascriptexecutor)driver; executor02.executescript("document.getelementbyid('classificationid').style.display='block';"); select select02 = new select(driver.findelement(by.id("classificationid"))); select02.selectbyvisibletext("internal prs"); thread.sleep(6000);  log.info("clicking on priority dropdown"); javascriptexecutor executor5 = (javascriptexecutor)driver;     executor5.executescript("document.getelementbyid('priorityid').style.display='block';"); select select5 = new select(driver.findelement(by.id("priorityid"))); select5.deselectall(); select5.selectbyvisibletext("not urgent"); thread.sleep(6000);  log.info("clicking on apply filter button"); driver.findelement(by.id("kpifiltersubmit")).click(); thread.sleep(6000);// second combination of filter section. 

for example, if time can't able identify element or other issue means code stopped , showing error. in case want skip particular filter section , need move other combination of filter section. please me make code in better standard.. i'm learning java , selenium web driver..

in case want skip particular filter section , need move other combination of filter section blockquote

you can use 'verify' helper method.

wiki: http://docs.seleniumhq.org/docs/02_selenium_ide.jsp#assertion-or-verification

for example,

javascriptexecutor executor = (javascriptexecutor)driver; if(verifyelementpresent(by.id("visualizationid")){     executor.executescript("document.getelementbyid('visualizationid').style.display='block';")        select select = new select(driver.findelement(by.id("visualizationid")));     select.selectbyvisibletext("week");     thread.sleep(6000); } ...         public boolean verifyelementpresent(by by) {             try {               driver.findelement(by);               return true;             } catch (nosuchelementexception e) {               return false;             }           } 

btw, not decision use thread.sleep(6000);

you face different problems.

so try use waits. wiki: http://docs.seleniumhq.org/docs/04_webdriver_advanced.jsp


Comments

Popular posts from this blog

python - Subclassed QStyledItemDelegate ignores Stylesheet -

java - HttpClient 3.1 Connection pooling vs HttpClient 4.3.2 -

SQL: Divide the sum of values in one table with the count of rows in another -