Clicking a button using xpath

250 views
Skip to first unread message

dom...@computerlogy.com

unread,
Feb 3, 2016, 8:16:06 AM2/3/16
to Selenium Users
Can someone suggest the command to use to click the button:  When I inspect the element (bold) is highlighted:
<li style="" class="this object">
  <article class="left">
    <h2>Condition</h2>
    <p>You must be able to define a condition or set of conditions to ticker an action.  For example, cost Per Click (CPC) more than 0.5</p>
    <p>Multiple conditions must be generated more than one condition by clicking the ADD feature.  This can be shown under the blue gear on the top right corner.</p>
  </article>
  <article class="right">
    <div class="optional">
      <a ng-class="{'selected': optimize.valueIsNumber}" ng-click="optimize.useNumberValue()">
        <i class="fa fa-plus"></i>
        <p>Specific value</p>
        <div class="value">
          <label class="text" ng-click="$event.stopPropagation()">
            <input class="ng-pristine ng-untouched ng-valid ng-valid-min" min="0.01" step="0.01" ng-model="value_second" ng-change="optimize.selectNumberValue(value_second)" placeholder="Value" type="number">
          </label>
          <p class="small">(&nbsp;'Enter' to submit value&nbsp;)</p>
        </div>
      </a>
      <!-- ngRepeat: func_second in optimize.func.functions track by $index --><a class="ng-scope" ng-class="{'selected' : func_second == optimize.there.selected.value  }" ng-click="optimize.selectFunctionValue(func_second)" ng-repeat="func_second in optimize.func.functions track by $index">
        <i class="fa fa-line-chart"></i>
        <p class="ng-binding">Average value</p>
        <p class="ng-binding"></p>
      </a><!-- end ngRepeat: func_second in optimize.func.functions track by $index --><a class="ng-scope" ng-class="{'selected' : func_second == optimize.there.selected.value  }" ng-click="optimize.selectFunctionValue(func_second)" ng-repeat="func_second in optimize.func.functions track by $index">
        <i class="fa fa-area-chart"></i>
        <p class="ng-binding">Standard performance</p>
        <p class="ng-binding"></p>
      </a><!-- end ngRepeat: func_second in optimize.func.functions track by $index -->
    </div>
  </article>
  <div class="tool">
    <button class="next">Next<i class="fa fa-angle-right"></i></button>
    <button class="back gray"><i class="fa fa-angle-left"></i>Back</button>
  </div>
</li>

I have tried to use the following syntax:
driver.findElement(By.xpath("//a[@ng-click = 'ng-click=optimize.useNumberValue()']")).click(); but it says its not clickable

Uma D

unread,
Feb 3, 2016, 1:25:47 PM2/3/16
to Selenium Users
Hi,

Use the below x path:

driver.findElement(By.xpath("//p[text()='Specific value']")).click();
 

dom...@computerlogy.com

unread,
Feb 3, 2016, 11:10:07 PM2/3/16
to Selenium Users
This worked thanks
Reply all
Reply to author
Forward
0 new messages