selenium - how to write below xpath in java -


//div[@ng-if="subnav.state == 'active'"] 

i tried below getting "invalidselectorexception":

string active = "subnav.state == 'active'"; driver.findelement(by.xpath("//div[@ng-if='"+active+"']")) 

<li class="active" on="subnav.state != '' && subnav.state != 'active'" ng-switch="" ng-repeat="subnav in navigation[activenav].pages | filter:subnavfilter(navigation[activenav].pages)">  	<div class="whereabouts ng-scope" ng-if="subnav.state == 'active'"></div>  	<span class="badge badge-active" aria-disabled="true" ng-if="subnav.state != 'complete'">6</span>  	<span class="ng-binding ng-scope" ng-switch-when="false">loan</span>  </li>

if there quotes used inside value should escape quotes.and suggest go double quotes close all. here's xpath

    string active = "subnav.state == 'active'";     driver.findelement(by.xpath("//div[@ng-if=\"" + active + "\"]")); 

Comments

Popular posts from this blog

Android : Making Listview full screen -

javascript - Parse JSON from the body of the POST -

javascript - Chrome Extension: Interacting with iframe embedded within popup -