How to write xpath for blow code - selenium-webdriver

There are no of elements in a table this is 43 record and I want to click on this id and for this I am not able to identify the Xpath
please help me
My HTML code is as below :-
<a class="btn btn-gray btn-sm show-tooltip" href="/MCare_Test/Auhmc/Admin/Provider/AddDoctor/43" data-title="Add Doctor" data-original-title="" title="" aria-describedby="tooltip629994">
Thanks in Advance
Srinu M

Try below xpath
//a[#aria-describedby='tooltip629994']
OR
//a[#class='btn btn-gray btn-sm show-tooltip']
OR
//a[#aria-describedby='tooltip629994' and #class='btn btn-gray btn-sm show-tooltip']
Hope it will help you :)

Try the following XPath:
//a[#data-title='Add Doctor']

Related

Multiple condition in ngClass angularJs

I want to change class of button according to condition. Here is code:
<button class="btn btn-xs" type="button" ng-class="(oppdetail.status=='approved')?'btn-success':(oppdetail.status=='pending')?'btn-warning':(oppdetail.status=='rejected')?'btn-danger':'btn-warning'">{{oppdetail.status|ucWordFilter}}</button>
I don't know, is the good way for ng-class?
This is probably the easiest way:
ng-class="{'class1':<condition1>, 'class2': <condition2>}"

I am trying to click on "one arrow button" multiple times using ng-click but i am not able to click

Here is the code
<button type="button" class="btn btn-default btn-sm pull-right" ng-click="move(1)" tabindex="-1"><i class="glyphicon glyphicon-chevron-right"></i></button>
I have to click on arrow button 3 times using ng-click or class.
Pleas help me
Since, you have mentioned that's hidden element and Selenium does not interact with hidden element the only option you have is javascript. I would try the following and see if that does the work:
driver.execute_script("document.querySelector(\"[ng-click='move(1)']\").click();")
Or:
button = driver.find_element_by_css_selector("button[ng-click*=move]")
driver.execute_script("arguments[0].click();", button)

AngularJS Syntax Error when trying to parse an MongoDB ObjectId

I'm new to MEAN stack applications so I'm asking for help.
Everytime AngularJS tries to parse the following code
<button type="button" class="btn btn-link pull-right" ng-click="delete({{ post._id }});"><span class="glyphicon glyphicon-trash"></span></button>
Displays in the console the following error:
Error: [$parse:syntax] http://errors.angularjs.org/1.4.3/$parse/syntax?p0=%7B&p1=invalid%20key&p2=9&p3=delete(%7B%7B%20post._id%20%7D%7D)%3B&p4=%7B%20post._id%20%7D%7D)%3B
at Error (native) https://ajax.googleapis.com/ajax/libs/angularjs/1.4.3/angular.js:12330
at https://ajax.googleapis.com/ajax/libs/angularjs/1.4.3/angular.min.js:6:416
at Object.q.throwError (https://ajax.googleapis.com/ajax/libs/angularjs/1.4.3/angular.min.js:209:32)
at Object.q.object (https://ajax.googleapis.com/ajax/libs/angularjs/1.4.3/angular.min.js:208:327)
at Object.q.primary (https://ajax.googleapis.com/ajax/libs/angularjs/1.4.3/angular.min.js:205:335)
at Object.q.unary (https://ajax.googleapis.com/ajax/libs/angularjs/1.4.3/angular.min.js:205:174)
at Object.q.multiplicative (https://ajax.googleapis.com/ajax/libs/angularjs/1.4.3/angular.min.js:204:434)
at Object.q.additive (https://ajax.googleapis.com/ajax/libs/angularjs/1.4.3/angular.min.js:204:261)
at Object.q.relational (https://ajax.googleapis.com/ajax/libs/angularjs/1.4.3/angular.min.js:204:96)
at Object.q.equality (https://ajax.googleapis.com/ajax/libs/angularjs/1.4.3/angular.min.js:203:425) <button type="button" class="btn btn-link pull-right" ng-click="delete({{ post._id }});">
But when I inspect the delete button I can find this:
<button type="button" class="btn btn-link pull-right" ng-click="delete(55ba1c2d6411b92c1715490c);"><span class="glyphicon glyphicon-trash"></span></button>
Could some one help me to fix this problem?
Remove the{{ }} from the ng-click attribute, it is not required in this case:
ng-click="delete(post._id);"
Why?
https://docs.angularjs.org/api/ng/directive/ngClick
The ng-click directive accepts an expression which is evaluated on click.

Angular bootstrap returning setIsOpen is not a function

We've got the following HTML:
<div class="btn-group search-dropdown" dropdown is-open="gender.isopen">
<button type="button" class="btn btn-default dropdown-toggle" dropdown-toggle>
{{sex_temp=='F'?'Female':'Male'}} <span class="caret"></span>
</button>
<ul class="dropdown-menu" role="menu">
<li ng-class="{'dropdown-selected':sex_temp=='F'}">
<a ng-click="sex_temp='F'">Female</a>
</li>
<li ng-class="{'dropdown-selected':sex_temp=='M'}">
<a ng-click="sex_temp='M'">Male</a>
</li>
</ul>
</div>
In the console, we're getting the following error:
Error: setIsOpen is not a function #http://127.0.0.1/lib/bootstrap-ui/ui-bootstrap-tpls-0.12.1.js:1734:5
$RootScopeProvider/this.$get</Scope.prototype.$digest#http://127.0.0.1/lib/AngularJS/angular.js:12406:23
$RootScopeProvider/this.$get</Scope.prototype.$apply#http://127.0.0.1/lib/AngularJS/angular.js:12679:13
done#http://127.0.0.1/lib/AngularJS/angular.js:8279:34
completeRequest#http://127.0.0.1/lib/AngularJS/angular.js:8484:7
createHttpBackend/</xhr.onreadystatechange#http://127.0.0.1/lib/AngularJS/angular.js:8423:1 #debugger eval code:1:1
consoleLog/<#http://127.0.0.1/lib/AngularJS/angular.js:10062:18
$ExceptionHandlerProvider/this.$get</<#http://127.0.0.1/lib/AngularJS/angular.js:7363:7
$RootScopeProvider/this.$get</Scope.prototype.$digest#http://127.0.0.1/lib/AngularJS/angular.js:12426:19
$RootScopeProvider/this.$get</Scope.prototype.$apply#http://127.0.0.1/lib/AngularJS/angular.js:12679:13
done#http://127.0.0.1/lib/AngularJS/angular.js:8279:34
completeRequest#http://127.0.0.1/lib/AngularJS/angular.js:8484:7
createHttpBackend/</xhr.onreadystatechange#http://127.0.0.1/lib/AngularJS/angular.js:8423:1
We're using ui-bootstrap-tpls-0.12.1.js
I have tried adding $scope.gender={isopen:false} but that didn't help.
Any idea on what might be the problem here? The dropdown is working perfectly. I just want to get rid of these errors in the console.
I had the same issue, I believe it has something to do with the overlap of bootstrap's drop-down. Try removing the "dropdown-toggle" class from your button.
In my case it helped to simply remove the is-open attribute.
This is 2 years later, but updating your ui-bootstrap would fix this problem if you're using an older version (example 0.13 instead of 2.5)

AngularJS syntax error when calling the same method with different params from dynamic button click events

I have two buttons that are both wired to ng-click event, but with different parameters.
<button type="button" class="btn btn-default btn-large btn-block"
ng-click="makePick({{item.EventId}}, {{eventSchedule.MemberId}},
{{item.HomeId}})">
<button type="button" class="btn btn-default btn-large btn-block"
ng-click="makePick({{item.EventId}}, {{eventSchedule.MemberId}},
{{item.AwayId}})">
And both are calling the same method:
$scope.makePick = function (eventId, memberId, teamWinSelId) { //... };
When I kick up the project in my browser, I get the following error:
Syntax Error: Token 'item.EventId' is at column {2} of the expression [{3}] starting at [{4}].
Not sure whats going on, is it a matter of having the same method call on two different buttons? Not too sure whats going wrong. I'd appreciate some guidance.
When using ng-click you omit the {{}} for view variables, they're already being processed within the directive:
<button type="button" class="btn btn-default btn-large btn-block" ng-click="makePick(item.EventId, eventSchedule.MemberId, item.HomeId)">
<button type="button" class="btn btn-default btn-large btn-block" ng-click="makePick(item.EventId, eventSchedule.MemberId, item.AwayId)">
you dont need to use curly braces in params, since ng-click processes itself this for you. curly braces are not required for any of ng prefix directive
for example
ng-click="makePick(item.EventId,eventSchedule.MemberId,
item.AwayId)

Resources