Finding elements in a HTML list based on another element in the list using Selenium RC - selenium-rc

<ul id="Group_00000000-0000-0000-0000-000000000001" class="xxxxxxxxx">
<li class="buttons">
<button class="button edit">Edit</button>
<button class="button addToOption">Add to option</button>
<button class="button removeFromOption" >Remove from option</button>
<button class="button addToGroup">Add to group</button>
<button class="button removeFromGroup">Remove from group</button>
</li>
<li class="content">
<div class="text">
<span id="Title_Of_The_Item" class="title"> QSE244</span>
<p class="description">A description about this item</p>
</div>
</li>
</ul>
<ul id="Group_00000000-0000-0000-0000-000000000002" class="xxxxxxxxx">
<li class="buttons">
<button class="button edit">Edit</button>
<button class="button addToOption">Add to option</button>
<button class="button removeFromOption" >Remove from option</button>
<button class="button addToGroup">Add to group</button>
<button class="button removeFromGroup">Remove from group</button>
</li>
<li class="content">
<div class="text">
<span id="Title_Of_The_Item" class="title"> QSE236 </span>
<p class="description">A description about this item</p>
</div>
</li>
</ul>
In the structure above I want to be able to click on the any button listed based on the titles like the QSE244 or QSE236 - ie clicking the corrosponding buttons. There is no point in using the id's Group_00000000-0000-0000-0000-000000000002 as they ll be replaced with dynamic GUIDs.

Since the only thing that differentiates these two blocks, and, presumably, many more like them, is the text of the <span class="title"> element, that's what you need to key off of. I'd try a locator something like this:
xpath=//ul[li[#class='content']/div/span[#class='title' and .='the_title_value']]/li[#class='buttons']/button[contains(#class, 'the_button_type']
which means "the button with class 'the_button_type' that is contained within the list with class 'buttons' which is contained within the unordered list that contains a list with class 'content' that contains a div that contains a span with class 'title' and the text 'the_title_value'. So you use the title value to locate the correct ul element, and then you navigate to the button from there.

Related

Links don't work inside Bootstrap Offcanvas

I have implemented an Offcanvas sidebar. It displays fine but none of the links in the sidebar actually work.
When I clicked on the links, nothing happens. I don't think I understand the mechanism well enough so any guidance here would be appreciated.
I'm using Laravel so this code is inside a view that is loaded for every page (like app.blade.php).
The sidebar works fine and can be properly toggled with the button but the links don't take me anywhere. What am I missing?
Here's the code. Link1 and Link2 are valid Laravel routes in my test app.
<body class="d-flex flex-column min-vh-100">
<a class="btn btn-primary float-end" data-bs-toggle="offcanvas" href="#offcanvas" role="button" aria-controls="offcanvas">
Toggle Menu
</a>
<nav class="offcanvas offcanvas-start show" tabindex="-1" id="offcanvas" data-bs-keyboard="false" data-bs-backdrop="true" data-bs-scroll="true">
<div class="offcanvas-header border-bottom">
<a href="/" class="d-flex align-items-center text-decoration-none offcanvas-title d-sm-block">
<h4>
My site
</h4>
</a>
</div>
<div class="offcanvas-body px-0" data-bs-target="experience-collapse" data-bs-toggle="collapse">
<ul class="list-unstyled ps-0">
<li class="mb-1">
<button
class="btn btn-toggle align-items-center rounded"
data-bs-toggle="collapse"
data-bs-target="#experience-collapse"
aria-expanded="true"
aria-controls="experience-collapse"
>
<i class="bi bi-list-ol"></i> Links
</button>
<div class="collapse show" id="experience-collapse" style="">
<ul class="btn-toggle-nav list-unstyled fw-normal pb-1 small">
<li><i class="bi bi-arrow-down-up"></i> Link 1</li>
<li><i class="bi bi-search"></i> Link2</li>
</ul>
</div>
</li>
</ul>
</div>
</nav>
</body>

How can I display vue.js data in blade

I am doing a small project with vue.js and laravel. I have a list of products, when I click on a specific product on "Quick view" button I want to show all data about that product in a modal but the data is not showing in the modal.
Can you help me please. Here is my code:
#extends('app')
#section('content')
<div id ="crud" class="row">
<div class="col-xs-12">
<h1 class="page-header">Lista de Articulo</h1>
</div>
<div class="wrap-icon right-section col-md-12" data-toggle="modal" data-target="#list" >
<div class="wrap-icon-section wishlist">
<a href="#" class="link-direction">
<i class="fa fa-heart" aria-hidden="true"></i>
<div class="left-info">
<span class="index">0 item</span>
<br>
<span class="title">Wishlist</span>
</div>
</a>
</div>
</div>
<div class="row">
<div v-for="keep in keeps" class="col-md-4" style="width:25%;" #mouseover="showByIndex = keep" #mouseout="showByIndex = null">
<div class="container">
<img :src="keep.foto" style="width:100%; max-width:150px;">
<button class="btn" v-show="showByIndex === keep" v-on:click.prevent="showKeep(keep)">Quick view</button>
</div>
<h3>
<b> #{{keep.nombre}}</b>
</h3>
<p> #{{keep.descripcion}}</p>
I fixed it. The error was because I called the modal file outside the div. Thanks to everybody.
you can't send data directly from vue in blade structure, you need to write a component for that.
https://v3.vuejs.org/examples/modal.html#modal-component

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']

How can i jump one cshtml page to another cshtml?

I have two .cshmtl pages used for registration. When user completes first registration page I want the controller to jump to another cshtml page without going to controller. How can I complete this task?
<div class="control-group form-actions pull-right">
<a href="~/Views/Registration/RegStep2" class="btn btn-primary">
Continue
<i class="fa fa-arrow-circle-right"></i>
</a>
</div>
When user click above continue button he will jump on another controller without controller...
Please see the below method using Partial views.
<div class="control-group form-actions pull-right">
<div id="first-div">
#Html.Partial("PartialView1")
</div>
<div id="second-div" style="display:none;">
#Html.Partial("PartialView2")
</div>
<a href="#" class="btn btn-primary" onclick="onclickContinue">
Continue
<i class="fa fa-arrow-circle-right"></i>
</a>
</div>
<script type="text/javascript">
function onclickContinue(e) {
$("#first-div").hide();
$("#second-div").show();
}
</script>

xpath of elemnts including same child

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']

Resources