java - Skipping over inputting value to drop down menu when not available -


depending on logs in page changes field having drop down menu field not having drop down menu , want program ignore field when drop down menu not available. have (customcoveragecell targets cell in excel)

select dropdown = new select(driver.findelement(by.xpath("//*[contains(text(), '"+ customcoveragecell +"')]/following::select")));             if((!customvaluecell.equals("") && !driver.findelements(by.xpath("//*[contains(text(), '"+ customcoveragecell +"')]/following::select")).isempty())){                 dropdown.selectbyvalue(customvaluecell); } 

but try change drop down menu. i've tried this

select dropdown = new select(driver.findelement(by.xpath("//*[contains(text(), '"+ customcoveragecell +"')]/following::select")));             if((!customvaluecell.equals("") && driver.findelements(by.xpath("//*[contains(text(), '"+ customcoveragecell +"')]/following::select")).isenabled())){//also tried isdisplayed , isselected see if                  dropdown.selectbyvalue(customvaluecell); } 

how not try input value without making sure value in excel blank?

here html in question: without drop down

<div class="wrap-padding-sm">    <div class="threecols">      <div class="colcontent">        <div class="sub-colcontent">          <span class="checkmark-grey">  												</span>          <span class="checktitle">third party (this need target , work from)  											</span>        </div>        <div class="sub-colcontent">limit:          <span class="amount-midcol">$$$$$$$$$$$$  												</span>        </div><span class="scroogemsg h7 mobile-show">some text</span>      </div>      <div class="colcontent">        <a data-toggle="collapse" class="margin-r10" data-target="#cust_standard_scrooge_0">          <span>what covers  										</span>        </a>        <a data-toggle="collapse" data-target="#cust_standard_scrooge_0" class="btn-accordian collapsed"> </a>      </div>    </div>    <div id="cust_standard_scrooge_0" class="scrooge-wrap collapse">      <p>some text      </p>    </div><span class="scroogemsg h7 mobile-hide">some text</span>  </div>

with drop down

<div class="wrap-padding-sm">    <div class="threecols">      <div class="colcontent">        <div class="sub-colcontent">          <span class="checkmark-grey">  												</span>          <span class="checktitle">third party  (this need target , work from)  											</span>          <span class="checktitle_sub">some text  											   </span>        </div>        <div class="sub-colcontent">          <div class="select-dropwrap">              <div id="h_abc194" class="form-group form-group-lg            "><label for="changescrooge:h_abc161:0:h_abc194:select-one-menu" class="control-label">limit: </label>              <div class="select-dropmenu  ">                <div class="selector uniform-select fixedwidth" id="uniform-changescrooges:h_abc161:0:h_abc194:select-one-menu"><span style="user-select: none;">1000000</span><select id="changescrooges:h_abc161:0:h_abc194:select-one-menu" name="changescrooges:h_abc161:0:h_abc194:select-one-menu" class="form-control input-lg  " size="1" onchange="mojarra.ab(this,event,'valuechange','changescrooges:custom_standard_scrooges','changescrooges:custom_standard_scrooges changescrooges:customacceptdeclinepnl',{'onevent':recommendedscroogeafterajax})">	      <option value="1000000" selected="selected">1000000</option>  	<option value="2000000">2000000</option>  </select></div>              </div>            </div>          </div>        </div><span class="scroogemsg h7 mobile-show">some text</span>      </div>      <div class="colcontent">        <a data-toggle="collapse" class="margin-r10" data-target="#cust_standard_scrooge_0">          <span>what text?  										</span>        </a>        <a data-toggle="collapse" data-target="#cust_standard_scrooge_0" class="btn-accordian collapsed"> </a>      </div>    </div>    <div id="cust_standard_scrooge_0" class="scrooge-wrap collapse">      <p>some text      </p>    </div><span class="scroogemsg h7 mobile-hide">sme text</span>  </div>
black spots text fields had blacked out enter image description here

this small trick used find existence of element.

if(driver.findelements(by.xpath("")).size()>0) {    //element exists    //do stuff } else {    //element doesn't exist    //do stuff if } 

hope helps you. thanks.


Comments

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

performance - Why is XCHG reg, reg a 3 micro-op instruction on modern Intel architectures? -

jquery - Responsive Navbar with Sub Navbar -