xpath of elemnts including same child - xpath

I want to click publish report button so I use this xpath->//button[#class='btn btn-success btn-block'].
I want to click that button who has href='http://www.jbalbertos.com', means that xpath should be like this //div/a[#href='http://www.jbalbertos.com/'] and //button[#class='btn btn-success btn-block']
if any one knows kindly give me right xpath statement.
<div class="search-business-description">
<div class="business-name ng-binding">J.B. Alberto's Pizza</div>
<div class="business-address ng-binding">
<div class="business-website">
<span class="ng-binding" ng-bind-html="getWebsite()"><a target="_blank" href="http://www.brchichago.com/">http://www.brchichago.com/</a>
</span>
</div>
</div>
<div class="business-website">
<span class="ng-binding" ng-bind-html="getWebsite()"><a target="_blank" href="http://www.jbalbertos.com/">http://www.jbalbertos.com/</a></span>
</div>
<div class="business-actions">
<button class="btn btn-success btn-block" ng-click="onPublish(result)">
</div>
</div>

if i understood correctly
//div[//a[#href='http://www.jbalbertos.com/']]/following-sibling::div[#class="business-actions"]/button[#class='btn btn-success btn-block']

Related

Laravel: Append using vue js

Im new in vue js and trying to explore it. I have button and that button has an event click, once the button clicked, it will add an input field in my specific div.
Vue file
<div class="item form-group">
<div class="col-md-6 col-sm-6 ">
<button type="button" class="btn btn-secondary" #click="addSchedule"><i class="fa fa-plus"></i>Add Schedule</button>
</div>
</div>
<div class="item form-group added-schedule">
<div class="col-md-4 col-sm-4 ">
<button type="button" class="btn btn-secondary"><i class="fa fa-plus"></i>Add qqqqqqq</button>
s
</div>
<div class="col-md-4 col-sm-4 ">
<button type="button" class="btn btn-secondary"><i class="fa fa-plus"></i>Add asdasd</button>
</div>
<div class="col-md-4 col-sm-4 ">
<button type="button" class="btn btn-secondary"><i class="fa fa-plus"></i>Add wwwwwww</button>
</div>
addSchedule(e){
e.preventDefault();
return false;
},
Scenario
User clicked the Add schdule,imagine the 3 buttons is my input fields
NOTE: The user can Add Schedule as many as the user like.
Question: How do I append the input fields in my class added-schedule once the button clicked?

Bootstrap 3 modal not opening in one click

my bootstrap 3 modal does not open up in one click everytime, sometimes it does not open up, sometimes it opens up after 2-3 mouse clicks, rarely it opens up in one click.
Basically I have trying to create a modal that will ask whether the user wants to delete it, if yes then send a post request to remove the value from the given database with the provided id in url.
It is a table of courses, all of them having its own delete button, and the id used is of the form id="deleteModal{{ $subtopic->subtopic_id }}"
this is my delete button
<td class="col-1"><a class="btn btn-danger btn-sm"><i class="fas fa-trash" data-toggle="modal" data-target="#deleteModal{{ $subtopic->subtopic_id }}"></i></a></td>
this is my modal
<div class="modal fade" id="deleteModal{{ $subtopic->subtopic_id }}">
<div class="modal-dialog modal-sm">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h4 class="modal-title">Delete Course ?</h4>
</div>
<div class="modal-body">
<div >
<h4>Are you sure!</h4>
<form action="{{ url('superadmin/allcourses/'.$course->course_id.'/'.$topics->topic_id.'/'.$subtopic->subtopic_id ) }}" method="post">
#csrf
{{ method_field('DELETE') }}
<div style="text-align: center;"><button class="btn btn-danger" type="submit"><i class="fas fa-check-double"></i>Yes</button>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
It should always open up in one click, please help me out I can't find any reason why it happens.
You need to change the html as below in the td.
<td class="col-1">
<a class="btn btn-danger btn-sm" data-toggle="modal" data-target="#deleteModal{{ $subtopic->subtopic_id }}">
<i class="fas fa-trash">
</i>
</a>
</td>
data-target does not work on <i></i>

Why href in button doesn't redirect to link?

I have a html view and this view displays list of elements. All elements have two buttons (edit and delete). When I click on delete all is working correctly but when I click on edit new view is not displayed. When I want to enter my direct url to edit it, all is working...
This is fragment of my code:
<div class="container">
<!-- topics -->
<div class="row topic" th:each="user : ${users}">
<div class="col-4">
<p>
<div class="input-group-addon" style="width: 2.6rem"><i class="fa fa-at"></i></div>
<a class="title " th:href="#{'/user/' + ${user.id}}" th:text="${user.email}"></a>
</p>
</div>
<div class="col-4">
<p>
<div class="input-group-addon" style="width: 2.6rem"><i class="fa fa-user"></i></div>
<a class="title " th:href="#{'/user/' + ${user.id}}" th:text="${user.fullName}"></a>
</p>
</div>
<div class="col-2">
<form action="#" th:action="#{'/user/drop/{id}'(id=${user.getId()})}" th:method="delete" >
<input type="hidden" name="_method" value="delete" />
<button type="submit" class="btn btn-danger">Usuń użytkownika</button>
</form>
</div>
<div class="col-2"></div>
<!--My failed button-->
<button type="submit" class="btn btn-warning" th:href="#{'/user/edit/' + ${user.id}}">Edycja</button>
</div>
</div>
</div>
A <button> has no href attribute. What you're looking for is a "link" (an <a> "anchor" tag to be specific):
<a class="btn btn-warning" th:href="#{'/user/edit/' + ${user.id}}">Edycja</a>
The reason your other button "works" is because it's part of a <form> and it submits that form. It doesn't follow any kind of href attribute. You could also make this button part of a form, but that doesn't appear to be the intended functionality. The intended functionality here is to direct the user to a new page, so a link is appropriate.

Laravel crash after adding a raw

Im displaying a treeview data and everything works perfecly.
But when i add the fourth raw, Laravel crash.
I want to post my code but i don't even know which one and where that came from..
view :
<div class="list-group">
<div class="col-md-12">
<div class="col-md-2">Departement</div>
<div class=" float-right">
<button class=" btn-primary" type="button" data-toggle="collapse" data-target=".multi-collapse" aria-expanded="false" aria-controls="multiCollapseExample1" >
<span class="glyphicon glyphicon-eye-open"></span></button>
<button type="submit" class="btn btn-warning " data-toggle="modal" data-target="#exampleModalposition"><span class="glyphicon glyphicon-plus-sign"></span></button> </div>
</div>
<div class="list-group-item" name="state">
#foreach($treeViewPosition as $departement)
<div class=" collapse multi-collapse collapse in " id="8" >
<div class="col-md-2"> {{ $departement->departement_name}}</div>
<div class=" float-right"><button class="btn btn-success" data-toggle="collapse" data-target="#{{ $departement->id}}8" aria-expanded="false" aria-controls="{{ $departement->id}}8">
<span class="glyphicon glyphicon-eye-open"></span></button></div>
<div class="list-group">
#if(count($departement->position))
#include('treeposition2',['position'=>$departement->position])
#endif
</div>
#endforeach
</div>
</div>
</div>

Robot Framework doesn't find element correctly by xpath

Robot framework doesn't identify the element by xpath.
Following is the code
<div id="sticky-actions-sticky-wrapper" class="sticky-wrapper" style="height: 100px;"><section class="content-header" id="sticky-actions" style="">
<h1>Curriculum</h1>
<div class="breadcrumb save-message hidden">
<label class="text-success">
<i class="flaticon flaticon-circle-check"></i>
Saved <span>a few seconds ago</span>
</label>
</div>
<div class="row p-t-15">
<div class="col-xs-12">
<button type="button" class="btn btn-primary add-task-btn" disabled="">Create New Task</button>
<div class="btn-group m-r-15">
<button type="button" class="btn btn-primary dropdown-toggle add-statement-btn" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" style="">
Create <span class="caret"></span>
</button>
<ul class="dropdown-menu">
<li><a tabindex="0" class="add-curriculum-btn">Curriculum</a></li>
<li><a tabindex="0" class="add-learning-area-btn hidden">Learning Area</a></li>
<li><a tabindex="0" class="add-topic-btn hidden">Topic</a></li>
<li><a tabindex="0" class="add-outcome-btn hidden">Outcome</a></li>
</ul>
</div>
<button type="button" class="btn btn-circle btn-xs blue link-statements-btn" disabled="" data-toggle="tooltip" data-placement="top" title="" data-original-title="Link selected statements">
<i class="fa fa-link"></i>
</button>
</div>
</div>
</section></div>
Xpath I used to for find "Create" button:
xpath=//*[#id="sticky-actions-sticky-wrapper"]/div[2]/div/div/button
xpath=//*[#id="sticky-actions"]/div[2]/div/div/button[.//text() = 'Create']
Robot Framework step:
click element xpath=//*[#id="sticky-actions-sticky-wrapper"]/div[2]/div/div/button
Error:-
ValueError: Element locator 'xpath=//*[#id="sticky-actions-sticky-wrapper"]/div[2]/div/div/button' did not match any elements.
According to your XML, there is a section element inside the first div which you didn't include in your XPath. It should work if you add it:
//*[#id="sticky-actions-sticky-wrapper"]/section/div[2]/div/div/button
or
//*[#id="sticky-actions"]/div[2]/section/div/div/button[.//text() = 'Create']

Resources