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

OpenCV OpenCL: Convert Mat to Bitmap in JNI Layer for Android -

android - org.xmlpull.v1.XmlPullParserException: expected: START_TAG {http://schemas.xmlsoap.org/soap/envelope/}Envelope -

python - How to remove the Xframe Options header in django? -