java - Selenium WebDriver. Select element from div list -


i have following area on html page:

<div class="t2-selector">       <div class="">           usa           <div>               <div>                   <div>                       <div class="selected" asset-id="129">google</div>                       <div asset-id="130">microsoft</div>                       <div asset-id="126">apple</div>                   </div>              </div>          </div>   </div>   <div class="inactive">       europe       <div>           <div>               <div>                   <div class="inactive" asset-id="127">bt</div>               </div>           </div>      </div>   </div>   <div class="">       currencies       <div>           <div>               <div>                   <div asset-id="135">eur/usd</div>                       <div asset-id="136" class="">gbp/usd</div>                       <div asset-id="137" class="">usd/jpy</div>                       <div asset-id="138" class="selected">usd/chf</div>                       <div asset-id="139">aud/usd</div>                       <div asset-id="140">usd/cad</div>                   </div>               </div>          </div>   </div>   

so need select desired element 1 of groups (that should not inactive, ok).
when i'm selecting group nothing occurs, no error , don't see the selected group opens. moment.
when i'm trying select element in clicked group receive

org.openqa.selenium.elementnotvisibleexception: element not visible   

error.
understand in moment i'm clicking on desired element not visible since group not appears open.
why?
, can resolve problem?
i'm using following code:

string selectedgroup = getvalue("group",'o');       string xpath1 = "//div[contains(text(),'" + selectedgroup + "')]";       driver.findelement(by.xpath(xpath1)).click();       webelement = driver.findelement(by.xpath(xpath1));       string classname = webelement.getattribute("class");       if(classname.contentequals("inactive"))           throw new elementinactiveexception("selected group appears inactive. exiting test");        string optionassetid = getvalue("assetid",'o');       string xpath2 ="//div[@asset-id='" + optionassetid + "']";        driver.findelement(by.xpath(xpath2)).click();   

the error occur on following line:

driver.findelement(by.xpath(xpath2)).click();   

when clicking on group or hovering on it looks in following way:
can see code selected / opened group receives "group-visible" class parameter.

when clicked on group or hovered on it looks so:

you can hover on drop down open , click on element

// simulate mouse movement dropdown  actions actions = new actions(driver); actions.movetoelement(driver.findelement(by.xpath(xpath1))).perform();  // wait element visible before clicking on webdriverwait wait = new webdriverwait(driver, 10); wait.until(expectedconditions.visibilityofelementlocated(xpath2)).click(); 

Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -