java - Apply Button on Filter with cssSelector or xPath Selenium Web Driver? -


i have part in source:

<div class="cfapplybuttoncontainer" style="height: 21px;">    <button class="tab-button tab-widget disabled" style="max-width: 67px;" disabled="" type="button">       <span class="icon"></span>       <span class="label">cancel</span>    </button>    <button class="tab-button tab-widget disabled" style="max-width: 67px;" disabled="" type="button">       <span class="icon"></span>       <span class="label">apply</span>    </button> </div> 

and java part this:

// detect type of filter   if (type.equals("")) {             elementlist = driver.findelements(by.xpath("//div[@id='" + id + "_menu']//a[@class='fitext']"));         if (elementlist.size() > 0) {             if (driver.findelements(by.xpath("//div[@id='" + id + "_menu']//div[@class='cfapplybuttoncontainer']//span[@class='label'][text()='apply']/..")).size() > 0) {                 type = "multi_checkbox_with_apply";             }             else {                 type = "multi_checkbox_without_apply";             }         }     }   //if apply button enabled              element = wait.until(expectedconditions.elementtobeclickable(by.xpath("//div[@id='"+id+"_menu']//div[@class='cfapplybuttoncontainer']//span[@class='label'][text()='apply']/..")));             if (element.getattribute("disabled") == null) {             element.click();             //log("clicked on apply button");             waitforloadingspinner();         }         else {             //log("apply button disabled - no need click on it");         }          // close drop down menu         element = wait.until(expectedconditions.elementtobeclickable(by.xpath("//div[@class='tab-glass clear-glass tab-widget']")));         element.click();         //log("dropdown menu closed");     } 

is correct way find span contains "apply"? apply stop working , don't know else try?

the way can search text inside tag (other looking link text applies a tags) use xpath. below should want.

//div[@class='cfapplybuttoncontainer']/button/span[text()='apply'] 

to use did in question

if (driver.findelements(by.xpath("//div[@class='cfapplybuttoncontainer']/button/span[text()='apply']")).size() > 0) {     // found element, stuff } 

Comments

Popular posts from this blog

sequelize.js - Sequelize group by with association includes id -

android - Robolectric "INTERNET permission is required" -

java - Android raising EPERM (Operation not permitted) when attempting to send UDP packet after network connection -