selenium - How to use webdriver to randomly click on a button with precondication -
i'm trying write test script flight booking tickets scenario this: randomly click button description contains keyword "tax not included",then results shows; randomly click button not contains keyword, price shows.
for instance: go ebay.com , search "iphone",in search result page,randomly click url label contains keyword "buy now"...
anybody got clean solution that? in advance.
i have no clue handle case... here code:
public void flightschedule(){ if (be.istextpresent(locator.getvalue("tax_text"), 1000)){ //if keywords displays arraylist<webelement> lists = (arraylist<webelement>) be.getbrowsercore().findelements(contains(text(),'tax not included')); random random = new random(); int ra = random.nextint(lists.size()); webelement element = (webelement) lists.get(ra); }
the page source code is:
<div id="itembarxi151" class="avt_column avt_column_trans"> <div class="b_avt_lst"> <div class="avt_trans"> <div class="avt_column_1st"> <div class="avt_column_sp"> <p> <span class="highlight">new york city</span> (tax not included) </p> </div> <div class="avt_column_2nd"> </div> <div class="c6"> <div class="c7"> </div> <div class="c8"> <div class="a_booking"> <a id="openwrapperbtnxi147" class="btn_book" title="booking tickets" onfocus="this.blur();" hidefocus="on" href="##" data-evtdataid="xi147"> <span> <b>booking</b> </span> </a> </div> </div>
my xpath is:"//div[@class='avt_column avt_column_trans'] [contains(text(),'booking')]",but doesn't work.
Comments
Post a Comment