0

I'm unable to click on Plus button and Minus button. My xpath is as //div[4]/span[2]

Even though my xpath is correct, I am getting an exception. I have also synced it using waits.

<!DOCTYPE html>
<html>
<link rel="stylesheet" href="css/ziprooms.min.css">
<head>
<body>
<div class="zr-container">
<div class="ng-scope" autoscroll="true" ng-view="">
<header class="ng-scope" scrolldata="" waypoint="">
<div class="header-home">
<div class="zr-loginBox ng-scope ng-hide" ng-show="modalbox" ng-include="'templates/loginbox.html'">
<div class="zr-login ng-scope ng-hide" validation="" ng-show="signinbox">
<div class="zr-signup ng-scope ng-hide" validateup="" ng-show="signupbox">
<h4>
<form class="clearfix ng-pristine ng-invalid ng-invalid-required ng-valid-email" novalidate="" ng-class="{'submitted': submitted2}" method="post" name="signup">
<label>
<label>
<label>
<label>
<label>
<label>
<input class="zr-book" type="submit" ng-click="submitted2=true; signupotp();" value="Sign Up" title="Sign Up" name="signup">
</label>
</form>
<p>
</div>
<div class="zr-fpwd ng-scope ng-hide" validatef="" ng-show="fpwdbox">
</div>
<div class="zr-overlay"></div>
<div class="zr-logo">
<div class="zr-contact">
<div id="videoContent">
<div class="zr-blueStrip">
<form class="clearfix ng-pristine ng-valid" date-cal="">
<div class="zr-zip-25">
<div class="zr-zip-15">
<div class="zr-zip-15">
<div class="zr-zip-15">
<span class="icon-minus" ng-click="minus('guest')"></span>
<input id="guest" class="zr-search" type="text" style="text-align:center" value="1 Guest" readonly="" name="guest">
<span class="icon-plus" ng-click="plus('guest')"></span>
</div>
<div class="zr-zip-15">
<div class="zr-zip-search">
</form>
</div>
</div>
</header>
<section class="zr-section-1 ng-scope">
<section class="zr-section-2 ng-scope">
<section class="zr-section-3 ng-scope">
<section class="zr-section-4 ng-scope">
</div>
<section class="zr-section-5 ng-scope" filtercity="" ng-include="'templates/seo.html'" ng-controller="TabController as tab">
<footer class="ng-scope" ng-include="'templates/footer.html'">
</div>
<script type="text/javascript">
<script src="js/libs/angular.min.js">
<script src="js/libs/angular-route.min.js">
<script src="js/libs/angular-carousel.min.js">
<script src="js/libs/angular-touch.min.js">
<script src="js/libs/pikaday.min.js">
<script src="js/libs/angular-scroll.min.js">
<script src="js/app.min.js">
<div class="pika-single is-bound is-hidden" style="position: static; left: auto; top: auto;">
<div class="pika-single is-bound is-hidden" style="position: static; left: auto; top: auto;">
</body>
</html>
  • 1
    Can you please share web driver code and html code of that button? – Helping Hands Dec 8 '15 at 8:25
  • <div class="zr-zip-15"> <span class="icon-minus" ng-click="minus('guest')"></span> <input id="guest" class="zr-search" type="text" style="text-align:center" value="1 Guest" readonly="" name="guest"> <span class="icon-plus" ng-click="plus('guest')"></span> </div> – Manju Patil Dec 8 '15 at 8:52
2

You can try the below xpath. Its more dynamic and less fragile.

Also the xpath you are using seems to be incorrect. It doesn't seem to be the fourth div.

If you are using a relative div (eg. //div) and a unique path ahead (like your are using span with a unique class name) then you don't need to give a number(sequence number) with the div.

for plus button - //span[@class = 'icon-minus']

for minus button- //span[@class = 'icon-plus']

  • (//span[@class = 'icon-minus'])[1] this is my xpath – Manju Patil Dec 9 '15 at 10:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.